Skip to content

Instantly share code, notes, and snippets.

@wvdschel
wvdschel / gist:425776
Created June 4, 2010 18:30
An example parentation
(presentation :output "foo.pdf" :width 1024 :height 768
(slide
(title "foo")
(image "foo.png" :width 200 :height 200 :caption "A typical foo."))
(slide
(title "bar")
(ulist
"test 1"
"test 2"))
@wvdschel
wvdschel / gist:743280
Created December 16, 2010 10:53
Duke says "Go ahead, make my day" once news about my scholarship is in.
while(true) do if( curl http://www.iwt.be/nieuws/feed/92 2> /dev/null | grep "Dec 2010" ); then amixer sset Master,0 80%,80%; curl http://www.wavsource.com/snds_2010-11-21_1584521671331348/video_games/duke/make_day.wav > alert.wav; mpg123 alert.wav; break; fi; sleep 2; done
@wvdschel
wvdschel / gist:792977
Created January 24, 2011 08:41
IRC proxy/download throttler combo script
require 'gserver'
require 'timeout'
require 'thread'
class ForwardThread < Thread
MAX_DATA = 1000 * 1024
TIME_SLOT = 0.3
@@lock = Mutex.new
@@data_sent = 0
@wvdschel
wvdschel / gist:2037681
Created March 14, 2012 16:31
mips memset
### memset2 ###
.macro f_fill64 dst, offset, val, fixup
9: sw \val, (\offset + 0 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous
9: sw \val, (\offset + 1 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous
9: sw \val, (\offset + 2 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous
9: sw \val, (\offset + 3 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous
9: sw \val, (\offset + 4 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous
9: sw \val, (\offset + 5 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous
9: sw \val, (\offset + 6 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous
9: sw \val, (\offset + 7 * 4)(\dst); .section __ex_table,"a"; .word 9b, \fixup; .previous
@wvdschel
wvdschel / gist:2049788
Created March 16, 2012 12:05
memset/memcpy benchmarks
OLD MEMSET: 170963885 loops, 2 bytes/loop, 10 sec, 32 MB/sec
NEW MEMSET: 238815611 loops, 2 bytes/loop, 10 sec, 45 MB/sec
====================================
OLD MEMSET: 182202651 loops, 4 bytes/loop, 10 sec, 69 MB/sec
NEW MEMSET: 177544626 loops, 4 bytes/loop, 10 sec, 67 MB/sec
====================================
OLD MEMSET: 197814868 loops, 8 bytes/loop, 10 sec, 150 MB/sec
NEW MEMSET: 177487994 loops, 8 bytes/loop, 10 sec, 135 MB/sec
====================================
OLD MEMSET: 177510297 loops, 16 bytes/loop, 10 sec, 270 MB/sec
@wvdschel
wvdschel / gist:2250827
Created March 30, 2012 11:09
Trigraph trickery
/* Always change a */
// Do we need to change a??/
if(aChanged)
foo->a = a;
/* Never change a */
// Do we need to change a??/
if(aChanged) foo->a = a;
[Fri Apr 13 11:14:09.029 2012] A4 00070.912.781 errApp: 301 errapp/nfr/cpu (01307) Less than 100000 filehandles left!
[Fri Apr 13 11:14:09.031 2012] A4 00070.918.151 errApp: 301 errapp/nfr/cpu (01244) Process /usr/sbin/udevd (pid: 180) has 12 file handles open.
[Fri Apr 13 11:14:09.033 2012] A4 00070.918.854 errApp: 301 errapp/nfr/cpu (01244) Process /philips/tools/ostracefiforeader (pid: 225) has 21 file handles open.
[Fri Apr 13 11:14:09.035 2012] A4 00070.920.217 errApp: 301 errapp/nfr/cpu (01244) Process /philips/apps/amApp (pid: 276) has 105 file handles open.
[Fri Apr 13 11:14:09.036 2012] A4 00070.931.222 errApp: 301 errapp/nfr/cpu (01289) /proc/trcext: 4 descriptors
[Fri Apr 13 11:14:09.039 2012] A4 00070.931.429 errApp: 301 errapp/nfr/cpu (01289) /mnt/jffs0/boot/am: 4 descriptors
[Fri Apr 13 11:14:09.041 2012] A4 00070.931.581 errApp: 301 errapp/nfr/cpu (01289) /dev: 61 descriptors
[Fri Apr 13 11:14:09.042 2012] A4 00070.931.628 errApp: 301 errapp/nfr/cpu (01289) anon_inode: 6 descriptors
[Fri Apr 13
@wvdschel
wvdschel / gist:2595804
Created May 4, 2012 16:09
CATS parsing magic
Dir['*.log'].each do |fname|
log = Log.parse(fname)
symbol = log.symbols.values.sort_by { |s| -s.charcount }.first
line = log.lines.values.sort_by { |s| -s.charcount }.first
puts "#{log.cats_charcount}/#{log.charcount} in #{log.name}, most offensive: #{symbol.name} (#{symbol.charcount}), #{line.name} (#{line.charcount})"
end
# Output:
# 2169/21484 in regexp-info.log, most offensive: -/legacy/printf (983), -/legacy/printf:0000 (983)
# 212132/227923 in teraterm.log, most offensive: amApp/resmgmt (22885), amApp/resmgmt:0850 (16423)
@wvdschel
wvdschel / gist:2627572
Created May 7, 2012 12:47
Cats parser
# Stats about a single log
class Log
# Load a file and parse every line as a print.
def self.parse(file_path)
Log.new(file_path, File.readlines(file_path))
end
# Number of lines in the file and number of lines that are valid CATS prints
attr_reader :linecount, :cats_linecount,
# Number of characters that are in the file, part of CATS prints and part of CATS header overhead, respectively
@wvdschel
wvdschel / mkswapimg.sh
Created June 4, 2012 07:45
Swap image creator
#!/bin/bash
SIZE=`expr $1 \* 1024`
if [[ x$SIZE == x ]]
then
MEM=`free | grep Mem | sed -e "s/[^0-9]*\([0-9]\+\).*/\1/"`
SIZE=`expr $MEM + $MEM / 4`
echo "No size provided, using 125% of memory size (${SIZE}KB)"
fi
COUNT=`expr $SIZE / 4`