Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@deepak
deepak / ruby2_debugger_failure_with_vm_get_sourceline.txt
Created May 20, 2013 13:33
ruby2 debugger fails when i type where
(rdb:1) where
dyld: lazy symbol binding failed: Symbol not found: _rb_vm_get_sourceline
Referenced from: /usr/local/opt/rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/debugger-1.6.0/lib/ruby_debug.bundle
Expected in: flat namespace
dyld: Symbol not found: _rb_vm_get_sourceline
Referenced from: /usr/local/opt/rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/debugger-1.6.0/lib/ruby_debug.bundle
Expected in: flat namespace
@deepak
deepak / check gems on rails4.txt
Created May 20, 2013 07:53
check these gems on rails4
pg
haml-rails
haml
rpsec
ministry_of_state
kaminari
devise
simple_form
gem "pivotal-tracker", :git => "git://github.com/jsmestad/pivotal-tracker.git"
# TODO: add integration tests. to guard against rails updates and patches
# NOTE: http://blog.hasmanythrough.com/2011/6/1/limitless-strings-for-postgresql
# postgres extends the SQL standard to define "character" datatype
# without a limit.
# as per sql-standard character needs a limit.
# in postgres varchar is actually implemented as text with a limit
# constraint. so varchar might be a little slower than text.
# unlike mysql there is no performance penalty for text
# we can use text instead of string but some rails form generators
# will show a text-field for string and a text-area html element
@deepak
deepak / capistrano_hooks
Created May 8, 2013 11:01
docs about capistrano hooks
https://github.com/capistrano/capistrano/wiki/2.x-Default-Deployment-Behaviour
https://raw.github.com/mpasternacki/capistrano-documentation-support-files/master/default-execution-path/Capistrano%20Execution%20Path.jpg
@deepak
deepak / gist:5538759
Created May 8, 2013 07:07
Rails ActiveSupport tap
options = {}.tap {|x| x[:width] = width if width }
@deepak
deepak / ruby_metaclass_shadow.rb
Created May 7, 2013 08:52
method defined on the eigenclass shadows the instance method
# method defined on the eigenclass shadows the instance method
require 'pp'
class A
def foo; "A"; end
end
a1 = A.new
a2 = A.new
@deepak
deepak / README.md
Last active December 16, 2015 16:49
what was i smoking ? Some url resources are under a login ie. can only access them if a user is logged in. approaches: 1. maintain a previous url app-wide and redirect back after sign_in. for signout maintain a list of protected actions so we do not redirect back there have to make sure circular redirects do not happen 2. before redirecting to l…

what was i smoking ?

Some url resources are under a login ie. can only access them if a user is logged in.

approaches:

  1. maintain a previous url app-wide and redirect back after sign_in. for signout maintain a list of protected actions so we do not redirect back there have to make sure circular redirects do not happen

  2. before redirecting to login, store the back url and thereafter do not maintain "back" url.

@deepak
deepak / ruby_bigdecimal_and_float_benchmark.rb
Last active December 16, 2015 01:19
Benchmark Integer, Float and BigDecimal
require 'benchmark'
require 'bigdecimal'
$CYCLE = 10_000_000
# Integer and Floats are native types
# BigDecimal is like a wrapper over a string
# Float is also a native type but is imprecise
# BigDecimal is precise and can handle arbitrary precision
# but is slower
@deepak
deepak / spam_email
Last active December 14, 2015 02:09
spam email on the lcthw mailing list
Hi Anita,
Unfortunately the null pointer errors have made it difficult for me to dereference your location in Dakar. Please send eggs.
---
[redacted]
On Wed, Feb 20, 2013 at 2:29 PM, [redacted] wrote:
My Dear friend,
@deepak
deepak / test.txt
Created January 29, 2013 13:37
match a word in grep or ack
age=10
age=11
age = 12
age=13
hello. age = 14
message = "hello"