Skip to content

Instantly share code, notes, and snippets.

View erubboli's full-sized avatar

Enrico Rubboli erubboli

View GitHub Profile
@erubboli
erubboli / ping.rb
Last active December 11, 2015 21:59
0.upto(255) do |n|
ip = "192.168.2.#{n}"
printf "ping #{ip}"
`ping -c 1 -q -o -t 1 #{ip} 2>/dev/null`
if $?.to_i == 0
printf " ok "
end
printf "\n"
end
require 'ohm'
require 'ohm/json'
module MyModule
class User < Ohm::Model
set :posts, :Post
attribute :name
def to_hash
super.merge( :name => name)
# Example of .jrubyrc
# Set compilaton mode. JIT = at runtime; FORCE = before execution. (JIT, FORCE, OFF, OFFIR)
#compile.mode = JIT
# Dump to console all bytecode generated at runtime.
# compile.dump = true
# Enable verbose JIT logging (reports failed compilation)
# jit.logging.verbose = true
# 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
[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'
@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
@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
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
require 'torquebox'
require 'torquespec'
torquebox = TorqueSpec::Server.new
torquebox.start(:wait => 120)
q = TorqueBox::Messaging::Queue.start('/queues/foo')
q.publish_and_receive('hello')
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))