Skip to content

Instantly share code, notes, and snippets.

View erubboli's full-sized avatar

Enrico Rubboli erubboli

View GitHub Profile
@erubboli
erubboli / image_to_array.rb
Created September 22, 2011 23:18
convert an image to c array
//Convert the 128x128 image with:
// convert image.jpg image.rgb
res=128
img_file = File.open(ARGV[0],'r')
puts "static char image[#{res*res}] = { "
img_file.bytes.each_slice(res) do |l|
puts " #{l.join(',')}"
end
@erubboli
erubboli / in_bash_profile.sh
Created December 4, 2011 11:27
add branch to PS1
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "["${ref#refs/heads/}"]"
}
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
#set ctrl+a as prefix (set CAPS LOCK as CTRL)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
#keys repetition
set repeat-time 0
set -s escape-time 0
2012/07/10 13:53:52 http: panic serving [::1]:49542: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/pkg/net/http/server.go:576 (0x512b1)
_func_003: buf.Write(debug.Stack())
/private/tmp/bindist454984655/go/src/pkg/runtime/proc.c:1443 (0x10b22)
/private/tmp/bindist454984655/go/src/pkg/runtime/runtime.c:128 (0x115ee)
/private/tmp/bindist454984655/go/src/pkg/runtime/thread_darwin.c:418 (0x1475e)
/Users/erubboli/projects/go/ggp/src/cache/cache.go:28 (0x27dcd)
Cache.Get: defer resp.Body.Close()
/Users/erubboli/projects/go/ggp/src/cache/cache.go:19 (0x27c6c)
Cache.ServeHTTP: fmt.Println(cache.Get(url))
require 'torquebox'
require 'torquespec'
torquebox = TorqueSpec::Server.new
torquebox.start(:wait => 120)
q = TorqueBox::Messaging::Queue.start('/queues/foo')
q.publish_and_receive('hello')
require 'spec_helper'
describe Nasreddin::Resource do
let(:foo) { double(:foo) }
before do
TorqueBox::Messaging::Queue.stub(:new).and_return(double().as_null_object)
end
@erubboli
erubboli / gist:3361197
Created August 15, 2012 16:00
undef_method
jruby-1.7.0.preview1 :001 > class A
jruby-1.7.0.preview1 :002?> end
=> nil
jruby-1.7.0.preview1 :003 > class Object
jruby-1.7.0.preview1 :004?> def to_json
jruby-1.7.0.preview1 :005?> raise "don't call me"
jruby-1.7.0.preview1 :006?> end
jruby-1.7.0.preview1 :007?> end
=> nil
jruby-1.7.0.preview1 :008 > a=A.new
@erubboli
erubboli / gist:3443461
Created August 23, 2012 23:28
ERROR OSX NRVM
Interval Since Last Panic Report: 1027 sec
Panics Since Last Report: 1
Anonymous UUID: 5819119A-06C2-4EDA-A6AB-4A80375269B2
Fri Aug 24 01:27:05 2012
panic(cpu 1 caller 0xffffff7f813e0947): NVRM[0/1:0:0]: Read Error 0x00000100: CFG 0xffffffff 0xffffffff 0xffffffff, BAR0 0xd2000000 0xffffff8112c51000 0x0a5480a2, D0, P3/4
Backtrace (CPU 1), Frame : Return Address
0xffffff80eeda2e70 : 0xffffff8000220792
0xffffff80eeda2ef0 : 0xffffff7f813e0947
0xffffff80eeda2f80 : 0xffffff7f814d0aa4
[1] pry(#<Bacon::Context>)> result
=> [200, {}, "bar"]
[2] pry(#<Bacon::Context>)> result == [200,{},"bar"]
=> true
[3] pry(#<Bacon::Context>)> result.should.equal([200,{},"bar"])
Bacon::Error: [200, {}, "bar"].==([200, {}, "bar"]) failed
from ~/.rvm/gems/jruby-1.7.0.preview1@nasreddin/gems/bacon-1.1.0/bin/../lib//bacon.rb:331:in `satisfy'
# Example of .jrubyrc
# Set compilation mode. JIT = at runtime; FORCE = before execution. (JIT, FORCE, OFF, OFFIR)
# compile.mode = FORCE
# Dump to console all bytecode generated at runtime.
# compile.dump = true
# Enable verbose JIT logging (reports failed compilation)
# jit.logging.verbose = true