Monday, January 17, 2011

Thursday, January 6, 2011

Iterating through an array in bash

locations=( Roppongi Shibuya Ebisu )

for name in ${locations[@]}
do
echo $name
done

Generating random locations around a location

Handy.

def generateLocation(startlat, startlon, maxdist):

# converting them radians
startlat *= pi / 180
startlon *= pi / 180
rand1 = random.random()
rand2 = random.random()

maxdist = maxdist / earthradius
dist = acos(rand1*(cos(maxdist) - 1) + 1)
brg = 2*pi*rand2

lat = asin(sin(startlat)*cos(dist) + cos(startlat)*sin(dist)*cos(brg))
lon = startlon + atan2(sin(brg)*sin(dist)*cos(startlat), cos(dist)-sin(startlat)*sin(lat))

if lon < -pi:
lon = lon + 2 * pi

if lon > pi:
lon = lon - 2 * pi

lat *= 180 / pi
lon *= 180 / pi

return [lat, lon]

Tuesday, January 4, 2011

Turn off SpringSource Tool Suite Dashboard

SpringSource Tool Suite 2.3.2 boots really slowly and it can be even slower if it opens the Dashboard at startup.
Lucky you can turn it off, not trivial though.

Dashboard has 4 tabs on the bottom (Dashboard, Knowledge Base, Extensions and Configuration).
At the Configuration tab there is a checkbox, Show On Startup.

Sunday, December 26, 2010

Command-line tools on Mac OS X, Snow Leopard

allmemory, fs_usage, fuser, latency, sar, sc_usage, spindump: Display various system usage statistics.

bless, disklabel, disktool, diskutil, drutil, fsck, hdiutil, pdisk: Create, identify, manage, and fix Mac OS X disks, file systems, and disk images.

ioreg, kextstat: Show device drivers and other kernel extensions in use.

mDNS, dns-sd: Test Bonjour service discovery with these diagnostic tools.

open: Invoke launch services on an arbitrary document or application as if doubleclicking it in the Finder.

pbcopy, pbpaste: Move data between stdin/stdout and the Mac OS X pasteboard.

say: Convert text to audio output or a file via Speech Synthesizer.

shasum: Compute or validate SHA message digests.

sips: Manipulate the format and color space of bitmap images (for example, rotate,

sw_vers, uname: Display Mac OS X version information.

syslog and logger: Send, view, and manage system log messages with these modern

xattr: List, display, set, and delete file system extended attributes

You can find more information on apple.com in this documentation.

Tuesday, December 21, 2010

snoop file opens on Snow Leopard

Opensnoop tracks file opens.
sudo opensnoop

or you can watch only a process
sudo opensnoop -n Google Chrome

HTML5 heading elements

"In HTML 4, the only way to create a document outline was with the <h1>–<h6> elements. If you only wanted one root node in your outline, you had to limit yourself to one <h1> in your markup.
But the HTML5 specification defines an algorithm for generating a document outline that incorporates the new semantic elements in HTML5.
The HTML5 algorithm says that an <article> element creates a new section, that is, a new node in the document outline. And in HTML5, each section can have its own <h1> element."


more of Pilgrimさん's Dive into HTML5
or check the outline of your document with the HTML5 Outliner