piyo's computer tips
2005/05/25
Output the CRC32 of a byte array in Ruby
Ruby

format("%0X", Zlib::crc32([0xAA, 0xBB,0xcc, 0xdd, 0x11,0x22].to_s))

Edit: 2006/01/31
Well this is incorrect. The above should be:

format("%0X", Zlib::crc32([0xAA, 0xBB,0xcc, 0xdd, 0x11,0x22].pack("CCCCCC")))
 
Ruby 1.8 on Debian Stable
Debian, Ruby

Ruby ruby ruby ruby ruby.
 
2005/05/19
Outlook Journal
Outlook

I just noticed that Outlook has been saving all the references to Word and Excel documents for who knows how long, in the Journal pane. Now I know which documents have been worked on.
 
2005/05/18
Excel and Array Formulas
Microsoft Excel

Suppose you wanted to calculate the total price of items from June to July in Excel. You have to play with Array Formulas, or formulas that look like {=SUM(IF(startDate,IF(endDate,valueRange),0),0))}. You enter them by pressing Control+Shift+Enter. This is totally wierd. Here's a real formula (enter without the braces, then hit Control+Shift+Enter).

=SUM(IF(DateF<=C2,IF(DateF>C3,CostF,0),0))
 
2005/05/13
Sleipnir mouse gestures (alternative input definition)
Sleipnir

Standard Gestures in Sleipnir (I deleted the others)

U D .. Refresh
U L .. Go to the upper directory
R .... Browser Forward
D .... New Window/Tab
D U .. Copy active window
D R .. Close active widnow
L .... Browser Back

Additional gestures to Sleipnir

L R .. Open URL in clipboard
 
Process Explorer (keyboard hotkey definition)
Windows, WinKey

I want to use Process Explorer more often. Here's my keyboard hotkey definition:

Windows Key + BkSp (Backspace)
 
2005/05/08
Google Web Accelerator is a bust
Google, Web Surfing

I tried that Google Web Accelerator for 1 surfing hour, and I saved 0.0 minutes. Well, I used it like this:

web client -> privoxy -> GWA -> internet

Perhaps privoxy is mitigating the advantages? I don't care. This product really seems to be losing other people's data, and I don't want to be another statistic. I uninstalled it.
 
2005/05/03
TCPdump and Ethereal: command line fun
Ethereal, TCPdump, Network

I found these information interesting.

tcpdump and/or ethereal (Score:3, Interesting)
by The AtomicPunk (450829) on 2004.04.08 12:49 (#8800258)
Like everybody else has said, you have those two, you're covered.

However, I find myself frequently using tcpdump to capture data, then downloading it and analyzing it in Ethereal on my workstation later.

tcpdump -w myfile.dump -s 2000

[ Reply to This ]

Re:tcpdump and/or ethereal (Score:3, Interesting)
by Autonin (322765) on 2004.04.08 13:14 (#8800418)
Actually -s 0 is better.

10/100BaseT Ethernet, which pretty much everyone uses these days, is limited to 1500 snaplen. But the good old FDDI was a whopping 4500!

With -s 0, it basically means "All" - you don't have to think about what transmission medium you're using.

I also usually name my packet captures with extention *.pcap, and just make Ethereal be the default *.pcap file handler.

I'll also use tcpdump to whittle my pcaps down. Say I capture for a long time and end up with a 500MB+ pcap. Opening this in most any workstation with Ethereal will cause you to wait awhile, and could actually crash your box (yay for WinXP pre-fetch!).

So when I've found a particular port or host I want to extract from a stream to make the pcap more managable, I'll do something like this:

tcpdump -s 0 -r infile.pcap -w outfile.pcap host x.x.x.x and port xxx

Sometimes, I'll use tethereal instead to go a little deeper. tethereal is ***SLOW*** compared to tcpdump, but the granularity is worth it sometimes. Just set it going, and go get a coffee or something.

When examining a capture of some malware trying to spread, often times it will SYN several hundred machines without getting a reply. Trolling through these can be a pain. But by using tethereal, you can make what I call "Jesus" pcaps (no SYN's). To make it complete, I also filter RST's like so:

tethereal -r infile.pcap -w outfile -R "tcp.flags.syn==0 && tcp.flags.reset==0"

There is a way to do this in tcpdump, but it's much more complicated. Besides, you need the break anyway, right? :)
 
2005/05/01
Wrestling with PostgreSQL 8.0, part 4
Cygwin, PostgreSQL, Windows

The service "PostgreSQL Database Server 8.0" has a shortname called "pgsql-8.0", so you can use the latter for "net start".

So how do you change the service command data directory? Look at this registry key:
HKLM\SYSTEM\ControlSet001\Services\pgsql-8.0\ImagePath
Value: "C:\Program Files\PostgreSQL\8.0\bin\pg_ctl.exe" runservice -N "pgsql-8.0" -D "Z:\Cliff\Data\postgres database\running\"

You can also see this info in the Mangage panel, Services sub-panel.
 
Wrestling with PostgreSQL 8.0, part 3
Cygwin, PostgreSQL, Windows

I finally figured out a way to move from 7.1.3 to 8.0.2, with a little help from the latest Cygwin PostgreSQL 7.4.5.

Save the database from 7.1.3 (Cygwin, custom compiled)
cygwin> export PGCLIENTENCODING=EUC_JP
cygwin> pg_dumpall -v --inserts --column-inserts > psql-dumpall-`sdate`-EUC_JP-cli745.sql


Then, load the database into 8.0.2 (Windows, standard English install)
cmd.exe> runas /user:postgres "c:\progra~1\postgresql\8.0\bin\initdb -E EUC_JP --no-locale -U Administrator -D c:\Progra~1\PostgreSQL\8.0\data"
Notice the --no-locale, which is necessary to avoid the = problem.
cmd.exe> net start "postgresql database server 8.0"
cmd.exe> set PGCLIENTENCODING=EUC_JP
cmd.exe> pg_dumpall --v --inserts --column-inserts > psql-dumpall-`sdate`-EUC_JP-cli745.sql

Done!
 
How I keep remembering new ways of using computers. My (computer-centric) new-optimization learning blog.

Name:
Location: Kobe, Hyogo, Japan
September 2003 / October 2003 / December 2003 / March 2004 / April 2004 / May 2004 / June 2004 / July 2004 / August 2004 / September 2004 / February 2005 / March 2005 / April 2005 / May 2005 / June 2005 / July 2005 / August 2005 / September 2005 / December 2005 / January 2006 / February 2006 / March 2006 / April 2006 /


Powered by Blogger