Kaolin Fire with GUD Issues 0 + 1

kaolin fire presents :: software tips


Software tips

c/c++

I'm getting linker errors for variables that shouldn't be externalized...? Why is the linker looking for them?
Who knows? But if you make them static, then it'll know better regardless!

vim

Crazy goldmine of vim tips
"David Rayner (zzapper) 15 Years of Vi + 3 years of Vim and still learning" ((at the time of this link -- I'm only on about 1/2 year of vi, 6 years of Vim))

Admin tips

Windows administration

Windows host file locations
Windows XP = C:\WINDOWS\SYSTEM32\DRIVERS\ETC\
Windows 2000 = C:\WINNT\SYSTEM32\DRIVERS\ETC\
Win 98/ME = C:\WINDOWS\

Yahoo listservs

getting off of yahoo, getting the list archives back
http://www.tt-solutions.com/en/products/yahoo2mbox/

BSD

watch the output of a command run over and over
watch: it's like "top" for any command you want to watch
remove ^M characters from a DOS file
col -bx < dosfile > newfile [[from FreeBSD fortune file, via Dru <genesis@istar.ca>]]
I'm using mrtg and can tell "something" is soaking up my bandwidth. But I can't tell what it is. Can you help me?
trafshow -f -i {interface} "not(host {myip})" -- the "not(host {myip}) is important to keep your ssh/whatnot connection running trafshow to top out the charts. Don't know what interfaces you have? /sbin/ifconfig!
I want to verify two directories (recursively) on two machines have the exact same files. What's the quickest/easiest way to check?
What I find works well: make sure ls is NOT aliased on either box (unalias ls) [[or make sure they're aliased to the same thing... but if ls displays differently, the following will give you a lot of noise]]. Then, in the directory you want to compare, ls -lR > box1. On the other machine, ls -lR > box2. Then get those two files together, for the following:
    cat box1 | tr -s ' ' ' ' | cut -d ' ' -f 5,9 > box1.clean
    cat box2 | tr -s ' ' ' ' | cut -d ' ' -f 5,9 > box2.clean
    diff box1.clean box2.clean
  

tr substitutes characters of one sort for another... here, we're using a trick to compress (that's the -s) multiple spaces into a single space. Then we chop out just the important fields of the ls (5 == size, 9 == filename), and get the difference. Now, this won't catch if the files are different but have the same number of bytes. You could pass an md5 in, but that would probably take a find -exec or some such. this is just quick and relatively easy. :)

If you only want to see if the file names and directory structure are the same (don't care about file sizes) then you can leave off the "5" in the clean step, or you can run through a second clean step of cat boxn.clean | cut -d ' ' -f 2 > boxn.clean2.

Bourne shell tips
R125: UNIX Bourne Shell. case, if, test, do, while, for, [, variables...

also...

  • just redirect error: >&
  • tie stdout into stdin for later filtering: 2>&1 (i.e. runmydbupdate.sh 2>&1 | grep ERROR | head...)
sysctl
If you made changes to /etc/sysctl.conf and want them to take without rebooting, 'sysctl -p'
Wondering if a port is in use, or what's using it if it is?
lsof -i shows you exactly that! You can match the pids to running processes with ps.
Want to edit all files with a given word in them?
vim `grep -m 1 -r [searchterm] . | cut -d ':' -f 1` -- there's probably an easier way to do this, but whatever. :) "-m 1" tells grep to stop searching a file after the first match, -r is recursive, and the cut grabs just the filename from the grep results. (Piping the results through xargs) instead of (using the backticks and passing to vim directly) can cause strange artifacts, like losing the ability to pass a carriage return. Another way to do the grep that comes to mind a little easier but is the slightest bit more wasteful is grep -r [searchterm] . | cut -d ':' -f 1 | sort | uniq. Just a thought. :) NOTE: If you're wondering why grep is "taking soooooo long", make sure you put the period after the search term. That's the path it's supposed to recurse from; else it will be parsing your stdin, instead.
Want to just search and replace? perl is your friend! recursively, even.
find . -type f -exec /usr/bin/perl -pi -e 's/find/replace/g' {} \; -- what I've used this for a couple of times is moving an svn repository, or rather, cleaning up after doing so: find . -type f -name entries -exec /usr/bin/perl -pi -e 's#http://oldrepos/location#http://newrepos/newlocation#g' {} \;
syslog synchrony
put a minus "-" in front of the file-path in your syslog.conf and it won't sync to disk after every entry. [[Richard Huxton, from pgadmin list]]
remove " from a fileOld and save to fileNew:
cat fileOld | sed 's/\"//g' > fileNew
setting up ssh-agent
  • cd ~/.ssh (create .ssh directory)
  • rm identity
  • rm identity.pub
  • ssh-keygen -t rsa
  • scp id_rsa.pub [remotehost]:.ssh/authorized_keys2
pretty diffs
-u: the 'unified output format', seems also to be the most readable
making a non-definitive backup
Say you want to backup your user partition, but you don't want to waste time on their excessive mp3's and whatnot. tar has an excellent 'exclude' parameter, and mixed with {}'s replacing magic, you can tighten an exclude down to the following:
    tar cspzf backup.tgz "--exclude \"*.{mp3,mpg,avi,tgz}\" *
create an iso image; extract an iso from a cd
dd if=/dev/cdrom bs=2048 count=326239 conv=notrunc,noerror > file-name.iso
you might have to be root, and you might have to use whatever file /dev/cdrom is pointing to (ls -al /dev/cdrom). Grabbed from Yo Linux, which has a bunch of useful information about burning cds.

Postgresql

current running postgresql queries
SELECT datname,procpid,current_query FROM pg_stat_activity
Forget what your plpgsql function does?
select prosrc, pronargs, prorettype, proargtypes from pg_proc where proname = 'yourfuncname';
What is the SQL syntax for to do what the psql client can do?
If you run psql with the -E option and then do a \d tablename, the sql used to calculate the response will be displayed. That sql would be the right way to do what you want.
How do I tell what database files (/var/lib/pgsql/data/base) are associated with which database?
select datname, datid from pg_stat_database
How can I tell what encoding my database is using?
in psql, '\l', which (-E will tell you) looks a bit like:
    SELECT d.datname as "Name", u.usename as "Owner", pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding" FROM pg_catalog.pg_database d LEFT JOIN pg_catalog.pg_user u ON d.datdba = u.usesysid ORDER BY 1;
What should I use for money?
postgresql docs say NUMERIC. Though many would argue for whole numbers, shifted the appropriate fractional amount.
What users exist?
select * from pg_user. pg_group for groups.
Having to work on a different system?
http://www.oreilly.com/news/sqlnut_1200.html: common functions on mysql, oracle, postgresql, and MS SQL.
watch your sql connections from the process-side
watch --interval=1 "ps ax | grep post | grep -v watch | grep -v grep | sed 's/^ .\*?//' | tr -s ' ' ' ' | cut -d ' ' -f 5-"

SQL Server

How can I find all columns with a given name?
SELECT obj.name,col.name from databasename.dbo.syscolumns col join databasename.dbo.sysobjects obj on col.id = obj.id where obj.xtype = 'U' AND col.name like '%yourcolumn%'

website design

color selection
select a base color and automatically get a bunch of related colors for a color scheme

utter misc?

record a realplayer stream to disk
  1. mplayer -dumpfile [dumpfile] -dumpstream [dumpstream]
  2. mplayer -vo null -vc null -ao pcm -aofile [wav output] [dumpfile]
  3. lame [wav output] [mp3 output]








I am soooo fake pre-loading this image so the navigation doesn't skip while loading the over state.  I know I could use the sliding doors technique to avoid this fate, but I am too lazy.