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
Array.new(2, ("fd" + SecureRandom.hex(5)).gsub(/([a-f0-9]{4})/, '\1:')).join(':/64 - ') + 'ffff::/64'
@jorrizza
jorrizza / color-log
Last active August 29, 2015 14:05
Colors standard syslog output and groups by service name
#!/usr/bin/env ruby
# Colors standard syslog output and groups by service name
require 'time'
services = []
STDIN.each_line do |line|
match = line.strip.match(/\A(?<timestamp>[\w]{3} \d+ \d\d:\d\d:\d\d) (?<hostname>[\w\d\-]+) (?<service>.+?): (?<message>.+)\z/)
if match
@jorrizza
jorrizza / crack.go
Last active August 29, 2015 14:05
Bcrypt (useless) dictionary attack
package main
import (
"bufio"
"code.google.com/p/go.crypto/bcrypt"
"encoding/csv"
"fmt"
"io"
"log"
"os"
@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)
@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: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: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 / 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 / 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 / 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