Skip to content

Instantly share code, notes, and snippets.

@rb2k
rb2k / gist:8372402
Last active April 15, 2024 19:30
A jenkins script to clean up workspaces on slaves
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
for (node in Jenkins.instance.nodes) {
@rb2k
rb2k / ip_country.rb
Created August 15, 2013 19:06
IP country lookup generator thingy
require 'open-uri'
require 'ipaddr'
def generate_lookup_table
delegation_lists = [
'ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest',
'ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest',
'ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest',
'ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest',
'ftp://ftp.ripe.net/pub/stats/ripencc/delegated-ripencc-latest'
require "rubygems"
require 'rethinkdb'
require 'oj'
require 'multi_json'
include RethinkDB::Shortcuts
r.connect({:db => 'testing'}).repl
r.db_drop('test_db').run rescue nil
r.db_create('test_db').run
r.db('test_db').table_create('data', {:durability => 'soft'}).run
*** longjmp causes uninitialized stack frame ***: ruby terminated
======= Backtrace: =========
/lib/libc.so.6(__fortify_fail+0x37)[0x7fee7967e217]
/lib/libc.so.6(+0xff1a9)[0x7fee7967e1a9]
/lib/libc.so.6(__longjmp_chk+0x33)[0x7fee7967e113]
/usr/lib/libcurl.so.4(+0x91e5)[0x7fee75ae21e5]
/lib/libpthread.so.0(+0xf8f0)[0x7fee79dab8f0]
/lib/libpthread.so.0(pthread_cond_wait+0xcc)[0x7fee79da785c]
ruby(_ZN8rubinius7Channel15receive_timeoutEPNS_5StateERNS_11GCTokenImplEPNS_6ObjectEPNS_9CallFrameE+0x3f4)[0x6791e4]
ruby(_ZN8rubinius10Primitives15channel_receiveEPNS_5StateEPNS_9CallFrameEPNS_10ExecutableEPNS_6ModuleERNS_9ArgumentsE+0x100)[0x62c4f0]
@rb2k
rb2k / gist:1451396
Created December 9, 2011 12:47
threading problems?
*** longjmp causes uninitialized stack frame ***: ruby terminated
======= Backtrace: =========
/lib/libc.so.6(__fortify_fail+0x37)[0x7f1bc849d217]
/lib/libc.so.6(+0xff1a9)[0x7f1bc849d1a9]
/lib/libc.so.6(__longjmp_chk+0x33)[0x7f1bc849d113]
/usr/lib/libcurl.so.4(+0x91e5)[0x7f1bc5f001e5]
/lib/libpthread.so.0(+0xf8f0)[0x7f1bc8ff88f0]
/lib/libpthread.so.0(pthread_cond_wait+0xcc)[0x7f1bc8ff485c]
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x180d69)[0x7f1bc9386d69]
/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/libruby.so.1.9(+0x18549b)[0x7f1bc938b49b]
import numpy
#your regular array
myarray = [123, 221, 3, 16, 199, 0]
#convert that to 32 bit integers
tmp=numpy.array(myarray, numpy.int32)
@rb2k
rb2k / sum_mean.rb
Created April 21, 2011 16:28
sum and mean for the Array class
class Array
def sum
inject( nil ) { |sum,x| sum ? sum+x : x }
end
def mean
sum.to_f / size.to_f
end
end
class Foo
def self.doit
puts "nike"
end
def bar
Foo.doit()
end
def bar2
require "rubygems"
rack_app = Proc.new do |env|
[200, {"Content-Type"=>"text/html"}, env["REMOTE_ADDR"]]
end
run rack_app
@rb2k
rb2k / apple_tv_jailbreak
Created February 13, 2011 11:35
that's what it looks like from the terminal point of view
$ sudo greenpois0n.app/Contents/MacOS/greenpois0n
2011-02-13 12:22:09.632 greenpois0n[302:e07] Could not connect the action buttonPressed: to target of class NSApplication
2011-02-13 12:22:09.635 greenpois0n[302:e07] Could not connect the action buttonPressed: to target of class NSApplication
2011-02-13 12:22:09.636 greenpois0n[302:e07] Could not connect the action buttonPressed: to target of class NSApplication
2011-02-13 12:22:09.637 greenpois0n[302:e07] Could not connect the action buttonPressed: to target of class NSApplication
Initializing libpois0n
No matching processes were found
Device must be in DFU mode to continue
Device must be in DFU mode to continue
opening device 05ac:1227...