Wednesday, February 27, 2008

wed 11PM

rand number in JS:
var randomnumber=Math.floor(Math.random()*11)

for 0-10

in a range:
function getRandom(min, max) {
var randomnumber= Math.floor(Math.random()*(max-min))+min;
return randomnumber;

wednedday 3:08PM

You can either find out your IP address through the command line interface or through a Web-based interface that can determine your address for you.

Through command line interface:

Note: Root access may be required to run these commands. These commands will all be launched from the command line.

1. Launch a command line interface. (This will vary depending on operating system distribution.)

2. In the resulting command line window or screen, type ifconfig.

3. Press Enter. For example, typing ifconfig at the command line:

[sygny@linuxbox /home]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:10:5A:1A:DC:65
inet addr: Bcast: Mask:
RX packets:18940 errors:1 dropped:0 overruns:0 frame:2
TX packets:11554 errors:0 dropped:0 overruns:0 carrier:0
collisions:2 txqueuelen:100
RX bytes:4087250 (3.8 Mb) TX bytes:2499423 (2.3 Mb)
Interrupt:11 Base address:0xd000

In the example above, the IP address is labeled inet addr:
The subnet mask is listed as Mask:

wed 3:26 AM

iGoogle themes don't accept military times, just gringo times

wed 3:20 AM

Like JS split or java tokenizer - explode will split a string into an array based on a delimiter:

wedneday 3:02 AM

get all the files matching a pattern in a directory in a nice list:

ls 360cities_stuttgart_* > test.log

will output one on each line in the log file

wednesday 2:57 AM

php print, multiple lines, escaping as usual:

print "This spans
multiple lines. The newlines will be
output as well";

print "This spans\nmultiple lines. The newlines will be\noutput as well.";

print "escaping characters is done \"Like this\".";

wednesday 12:42 am

getpass is a python module that prompts you for a password and returns it to a var, e.g.
gd_client.password = getpass.getpass()

Tuesday, February 26, 2008

tuesday 1:41 PM

new emoticons for gtalk:

tuesday 1:27pm

replace line numbers with nothing, like when copying and pasting code from a codeviewer-
33: bla


tuesday 11:16 AM

find which process is on a port (e.g. 4148):

netstat -anp | grep 4148

tuesday 11:10 am

when you're looking for a process on a port-
ps -aux > bla.txt

search for command that started the srvice, then kill its PID

Monday, February 25, 2008

monday 10:46pm

(old news)
google code SVN can be propset to make HTML appear in trunk

to recursively propset:
find . -name '*.html' | xargs svn propset svn:mime-type text/html

monday 8:34AM

Javascript string matching:
To match strings like "2__ bla", "1__ ha":

Returns null if not found.

monday 7:53AM

python to find a substring in a string:

if row_str.find('GeoWiki') > 0:
print row_str

2/25/2008 7:48AM

python: to get the print statements to not be on a new line, just follow print statement with a comma: print 'bla',

2/25/2007: 6:30 AM

spreadsheets list feed: Underscores in column names from the UI will be stripped and replaced with '' when converted to list-feed-friendly column names.