Malicious enjoyment derived from observing someone else’s misfortune
 

Tag Archives: programming

Finding bad JPEGs with Xorg hacks in Ubuntu

So, I have all these JPEGs, and I want to know which ones are corrupt (specifically, ones that end prematurely). qiv will spit out the following to STDERR when it finds one: Premature end of JPEG file So, this is nice, except it’s entirely unscriptable. The solution I found was using the following script to the display the images in sequence: perl -e ‘for(glob(“*.png *.jpg”)){$output = `qiv “$_” 2>&1;`; if($output =~ /Premature/){print $_, “\n”;}}’ All this does is mix STDERR [...]

Random Fun with NASM

I was on IRC tonight and someone was having trouble with their NASM homework. I decided to help them by learning NASM and coding up their homework problem for fun. It was pretty cool.

HAI WURLD! LOL

So, today I was stumbling around and I found an implementation of 99 bottles in LOLCODE! Wow, time to get the interpreter. I really need to make a deb for this, but that can wait. Anyway, first I tried some simple hello world sort of stuff: BTW OMFG A LOLCODE!!oen!111 BTW THIS IS WROTE BY ERIK GREGG 10/07/07 BTW LOL FROM HTTP://WWW.RALREE.INFO HAI VISIBLE “HAI WURLD! LOL” KTHXBYE Then I moved on to something even more awesome…

KLone – C on Rails!

Well, I was over at Debian Package of the Day when I noticed an article on KLone. It’s a little application framework that allows you to do XHTML templating in C! Then, you can compile it and send it off to any Linux machine (with a few dependencies of course) to run it. I got it, and it didn’t work for me at first. Then, for some reason, it started working. Here’s what I think did it: In Ubuntu, I [...]

Using seq to zero-pad strings in a series

I thought this was pretty cool: for i in `seq -f "%03g" 1 100`; do wget http://www.gozerog.com/images/Hawking_$i.jpg; done We were trying to do this the other night using bash, but to no avail since the square brackets only work for local file path expansion. I should have remembered seq. Also, this example shows how to 0-pad a series using seq and bash, noted by the *-f* option. Three cheers for seq!

SVN Log Made Easier

So, I got tired of typing in the dates to find a range of log messages. Here’s my solution: # In ~/.bashrc svn-log() { case $1 in yesterday | yes | y) svn log -r {`date -d yesterday +”%Y-%m-%d”`}:{`date +”%Y-%m-%d”`};; *) echo “Invalid Option: $1″;; esac } I plan to add more to this later.

Precaching Images with Javascript

Today, Will told me about some awesome image caching. I used it. //Do some image caching cached_image = Array(new Image(), new Image(), new Image(), new Image()); cached_image[0].src=”image1.jpg”; cached_image[1].src=”image2.jpg”; It’s amazing.

Not a sandwich, but a Vim Which!

I often find myself going to find scripts I’ve written that I want to edit, but I decided today I’d make things easier on myself: hank@rura-penthe ~ $ cat bin/vimwhich #!/bin/bash vim `which $1` All this does is shorten vim `which myscript` to vimwhich myscript. Helpful for just a couple lines of code.

Programmer Personality Test

This is an alright test. Here’s what I got. Your programmer personality type is: DLSC You’re a Doer. You are very quick at getting tasks done. You believe the outcome is the most important part of a task and the faster you can reach that outcome the better. After all, time is money. You like coding at a Low level. You’re from the old school of programming and believe that you should have an intimate relationship with the computer. You [...]

Learning Lua

I’m learning Lua! Here’s fibonacci: a,b=0,1 do while true do io.write(b) a,b = b, b+a if a>500 then io.write(“\n”); break end io.write(“, “) end Wow, this is kinda fun. I like Lua.