Skip to content

Instantly share code, notes, and snippets.

View jorrizza's full-sized avatar
🏠
Working from home

Joris van Rooij jorrizza

🏠
Working from home
View GitHub Profile
@jorrizza
jorrizza / srvstdout.go
Last active December 11, 2015 16:09
Serving stdout using websockets and Go.
package main
import (
"code.google.com/p/go.net/websocket"
"flag"
"log"
"net/http"
"os"
)
@jorrizza
jorrizza / gist:1555242
Created January 3, 2012 15:01
Module.class_variables
irb(main):001:0> class A
irb(main):002:1> @@variable = 'a'
irb(main):003:1> end
=> "a"
irb(main):004:0> class B < A
irb(main):005:1> end
=> nil
irb(main):006:0> B.class_variables
=> []
irb(main):007:0> B.class_variable_defined?(:@@variable)
@jorrizza
jorrizza / fix_system.sh
Created October 21, 2011 14:02
Debian broken package finder
#!/bin/sh
BROKEN=""
IFS="
"
for package in `dpkg -l | awk '{ if ($1 == "ii") { print $2 } }'`; do
STATUS="Okay"
printf "Checking %s..." $package
@jorrizza
jorrizza / README
Created August 1, 2011 13:42
ActiveRecord Shell
ActiveRecord SHell (or ARSH for short).
Here's the code that actually works. I have been working on a
half-baked pager for the shell, but the code's so ugly I'm not willing
to share it. At least this allows someone to continue the "project".
The original idea was this:
- ls should list available ActiveRecord classes and modules containing
ActiveRecord classes.
@jorrizza
jorrizza / README.md
Created June 27, 2011 15:54
Codebrawl entry

Pixelizer entry for Codebrawl

This example needs Ruby 1.9.

Two ways to run this:

$ ./pixelizer.rb infile.png > outfile.png
$ ./pixelizer.rb - > outfile.png < infile.png
@jorrizza
jorrizza / gist:1007821
Created June 4, 2011 11:27
New Server
$ lspci; cat /proc/cpuinfo ; dmesg; free -tm; uptime
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 13)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 13)
00:02.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 2 (rev 13)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 13)
00:04.0 PCI bridge: Intel Corporation 5520/X58 I/O Hub PCI Express Root Port 4 (rev 13)
00:05.0 PCI bridge: Intel Corporation 5520/X58 I/O Hub PCI Express Root Port 5 (rev 13)
00:06.0 PCI bridge: Intel Corporation 5520/X58 I/O Hub PCI Express Root Port 6 (rev 13)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 13)
00:08.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 8 (rev 13)
@jorrizza
jorrizza / gist:946074
Created April 28, 2011 09:19
Ruimt op.
# ViaViela Verkoop spamt graag
if message.from.email =~ /verkoop@viaviela.nl/
message.remove_label :inbox
message.add_label :spam
log "Verkoop spam: #{message.id}"
end
@jorrizza
jorrizza / gist:911500
Created April 9, 2011 16:01
Universal Tree Resolver FTW
#!/usr/bin/ruby1.9.1
results = [
{id: 4, data: "level2", pid: 3},
{id: 1, data: "level1", pid: 0},
{id: 0, data: "level0", pid: nil},
{id: 2, data: "level2", pid: 1},
{id: 2, data: "levelX", pid: 10},
{id: 3, data: "level1", pid: 0}
]
@jorrizza
jorrizza / gist:876371
Created March 18, 2011 16:30
Explaining monkey patching to friends
class String
def encode_to_i
result = 0
self.split.each_with_index do |c, i|
result += c.ord << (i * 8)
end
result
end
def ==(s)