Skip to content

Instantly share code, notes, and snippets.

@iffyuva
iffyuva / defarg.rb
Last active August 29, 2015 14:06
joys of using same name for arg
class DefArg
def calc(str, val=val)
p val
end
def val
10
end
end
@iffyuva
iffyuva / gist:37cc5224a0506add9534
Created September 4, 2014 13:20
time comparison fun in ruby
:013 > nil <=> Time.current
=> nil
:014 > Time.current <=> nil
NoMethodError: undefined method `to_datetime' for nil:NilClass
from /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/core_ext/date_time/calculations.rb:161:in `<=>'
from /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/core_ext/time/calculations.rb:286:in `compare_with_coercion'
from /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/time_with_zone.rb:214:in `<=>'
from (irb):14
@iffyuva
iffyuva / gist:f26f2654aee83c95057a
Created August 3, 2014 12:38
rbkit-client bug: processing same event twice
main-window false
"tcp://127.0.0.1:5556" "tcp://127.0.0.1:5555"
Emitting signal with "tcp://127.0.0.1:5555"
Got "tcp://127.0.0.1:5556" "tcp://127.0.0.1:5555"
true
()
started
processing obj created : "Time" with id 140290326315160
processing obj created : "String" with id 140290326315120
processing obj created : "String" with id 140290326315080
@iffyuva
iffyuva / gist:3219d170a6c14e61fba1
Created July 29, 2014 19:23
compiling ruby extension with -O2
require 'mkmf'
with_cflags('-O2') do
if(have_func('rb_postponed_job_register_one') &&
have_func('rb_profile_frames') &&
have_func('rb_tracepoint_new') &&
have_const('RUBY_INTERNAL_EVENT_NEWOBJ') &&
have_library("zmq") &&
have_header("zmq.h") &&
have_library("msgpack") &&
have_header("msgpack.h"))
@iffyuva
iffyuva / gist:ba6c18332acb3c7b1be5
Created July 29, 2014 19:08
compiling ruby with -O2
$ CFLAGS='-O2 -fno-fast-math' ./configure
$ make
CC = clang
LD = ld
LDSHARED = clang -dynamic -bundle
CFLAGS = -O2 -fno-fast-math -pipe
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/x86_64-darwin13 -I./include -I.
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -fstack-protector -Wl,-u,_objc_msgSend -Wl,-pie -framework CoreFoundation
@iffyuva
iffyuva / gist:6636985
Created September 20, 2013 12:50
error i get after upgrading to xcode 5
/Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': dlopen(/Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.0.0/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/yuva/clients/ivrnet/central/vendor/ruby/2.0.0/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxml2/2.8.0/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.0.0/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 11.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.0.0/gems/nokogiri-1.6.0/lib/nokogiri/nokogiri.bundle
from /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from /Users/yuva/clients/ivrnet/op-central/vendor/ruby/2.0.0/gems/activesupport-4.0.0/lib/act
@iffyuva
iffyuva / gist:6636111
Created September 20, 2013 11:20
caching doesn't work with tax rates while precompiling
PG::Error: ERROR: relation "invoicing_tax_rates" does not exist
LINE 1: SELECT "invoicing_tax_rates".* FROM "invoicing_tax_rates"
^
: SELECT "invoicing_tax_rates".* FROM "invoicing_tax_rates"
/vendor/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `exec'
/vendor/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:768:in `exec_no_cache'
/vendor/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql/database_statements.rb:138:in `block in exec_query'
/vendor/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:425:in `block in log'
/vendor/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/vendor/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract_adapter.rb:420:in `log'