Archives for: April 2009
Determining if an IP is within a specific range: redux

I was reading Paul Gregg’s very clear explanation of “classless” ranges comparison when I realized that his code was not as “bare metal” as could be. So, here is the code I’ve been using in nextBBS. It only accepts ranges in the form “x.x.x.x/b” but it’s short and all I needed, really. ?View Code PHPfunction isSubnet($subnet, $ip) { // Classless [...]

By Chris with 0 comments
One-line variables swap in PHP, Ruby, Perl, Python and C
12944421_8795d22d42

Today’s fun and games: let’s swap a few variables without using more variables than necessary. Let me know if you disagree with any of this… ?View Code PHP$a = 1; $b = 2; list($a, $b) = array($b, $a); print "a=$a, b=$b\n"; ?View Code RUBYa = 1 b = 2 a, b = b, a puts "a=#{a}, b=#{b}\n" ?View Code PERLmy [...]

By Chris with 9 comments
Bespin in Titanium: From The Jaws Of Victory…

bespin is really an intriguing project. Since I’ve grown frustrated with the inconsistencies between the various code editors that I have been using — I work on Leopard at home and Ubuntu at work — I thought that creating my own editor would be the answer to that. Nothing fancy, mind you. Just something consistent. My first impulse was to [...]

By Chris with 0 comments
Data Recovery Software