jemnotesversion 2 / featuring tools or see all/search

Mar 8
Having spaces in filenames is, in general, reprehensible. However, if you’re dealing with something like an iPhoto Library, it’s not up to you. To deal with this in rsync, note the following, from this page.
# Copy three separate files on host to tmp.
rsync -av host:'file1 file2 file3' /tmp/

# Copy one file from host to tmp. ? matches any character.
rsync -av host:a?long?filename /tmp/
rsync -av host:'"a long filename"' /tmp/
rsync -av host:'a\ long\ filename' /tmp/
rsync -av host:a\\\ long\\\ filename /tmp/
Feb 24
Finally, a decent way of controlling preview on the mac via the apple remote. iRed Lite works well, and finally makes it possible to use the remote for texed presentations.
Feb 16
Apparently, “the memmon executable monitors a linux process and provides summary statistics about the memory usage of the process after it terminates.”
Jan 12
The geokit gem for ruby is extremely good. Within seconds of installing it I could use it to look up locations and distances. Now to apply this to analyzing tracks made by runkeeper, exported to gpx format, processed with hpricot, and bound together with much ruby goodness.
Oct 29
Some more details about using rake.
And this page talks about some options when you want the output folder to be different to the input.
Oct 20
Bash seems to contain more features than I could ever imagine. Check this out, for example:
# Both lines will produce the same output, but the first is a variable.
echo ~+
pwd
Oct 15
Surely rakefiles are the future. GNU Make just looks antiquated.
Update: not so sure. Rake seems like it’s not that great after all. I might try writing my own sometime.
Oct 15
Sep 23
Download a file, much like wget, but with curl:
curl -O http://example.com/file.sty
# equivalent to
wget http://example.com/file.sty
This is especially appropriate on mac, because curl comes with mac, unlike wget.
Sep 15
Converting a pdf to a png and making it 1000x1000 pixels:
convert -density 300x300 -resize 1000x1000 infile.pdf outfile.png
Jun 19
Sick of messages like this when logging in?
Last login: Thu May 21 23:31:00 2009
Simply
touch .hushlogin
and they’ll be all gone.
Jan 31
The letter k toggles keep mode in xdvi; with keep on, the horizontal and vertical page offset remains the same, even when switching pages.
Jan 30
Let’s say we want to remove the prefix one from a series of files. Use this:
for FILE in one* ; do mv $FILE `echo $FILE | sed 's/one//'` ; done
Or, use +rename+. Thanks to the reader who pointed out that, in Debian GNU Linux (for example), you can also use rename, as in
rename 's/^one//' one*
Much cleaner, if rename is available.
Sep 2
Expire a user’s password, requiring them to change it immediately upon their next login:
passwd -e username
Aug 21
Check for common memory errors in C with valgrind. Also profile cache misses and branch mispredictions.
Sample usage:
# Check memory accesses.
valgrind --tool=memcheck ./prog

# View cache and branch profiling information.
valgrind --tool=cachegrind ./prog
For more detailed output from valgrind, add the -g tag to your gcc compilation flags to add debugging information to the binary.
Aug 13
Use multiple processes (and hence cores) with make by using make -j.
Aug 13
Disconnect ssh quickly, even when ^d is not allowed, with ~..
Aug 11
A reminder of how tee works comes from hunterdavis.com.
./prog | tee >(gzip > logfile.tgz)
Aug 11
find and sed operate slightly differently on a mac. Here’s some code that replaces 4.3 with 4.4 in all Makefiles, recursively.
find . -name 'Makefile' -exec sed -i -e 's/4\.3/4.4/g' {} \;
Aug 4
To see the assembly instructions generated for a piece of C code, use this:
gcc -c -g -Wa,-ahl src.c
Find out the macros, and values, predefined by gcc (includes useful things like __INT_MAX__).
gcc -dM -E - < /dev/null
Jul 29
I’ve often tried to use find, but have never really got over its syntax. It seems that it’s one of those powerful tools that’s not necessarily obvious to use at first.
Here’s one way to use it. This:
find . -name '*.sw*' -print
prints filename which have .sw in them (say, leftover vim swapfiles).
You can combine this with grepping. This:
find . -name "*.bib" -exec echo {}; grep "tribute to" '{}'
looks for the words ‘tribute to’ in files with the extension .bib.
Jul 22
Version 4.3 of gcc, has some significant improvements (more info), including this nice feature:
>> gcc -c -Q -Os --help=optimizers
The following options control optimizations:
  -falign-jumps                         [disabled]
  -falign-labels                        [disabled]
  -falign-loops                         [enabled]
# ...
  -fwhole-program                       [disabled]
  -fwrapv                               [disabled]