piyo's computer tips
Output the CRC32 of a byte array in Ruby
Rubyformat("%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, RubyRuby ruby ruby ruby ruby.
Outlook Journal
OutlookI 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.
Excel and Array Formulas
Microsoft ExcelSuppose 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))
Sleipnir mouse gestures (alternative input definition)
SleipnirStandard 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, WinKeyI want to use Process Explorer more often. Here's my keyboard hotkey definition:
Windows Key + BkSp (Backspace)
Google Web Accelerator is a bust
Google, Web SurfingI 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.
TCPdump and Ethereal: command line fun
Ethereal, TCPdump, NetworkI 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? :)
Wrestling with PostgreSQL 8.0, part 4
Cygwin, PostgreSQL, WindowsThe 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, WindowsI 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!