Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@deepak
deepak / wrap_errors_for_generators.es.js
Created February 4, 2015 07:35
do not throw error directly for generator. always wrap in a callback ?
// works: https://gist.github.com/deepak/ffe01c81900d12f95658
// does not work: https://gist.github.com/deepak/9a7337d7a641f8af9c8b
// difference is that, if error is thrown directly from fucntion called in generator
// then it gives a "Generator is already running" error
// but if it is wrapped in a setTimeout callback then it works
// WORKS
let price = 10;
@deepak
deepak / next in yielded method.es.js
Created February 4, 2015 08:15
calling next in yielded method give a generator already running error
let price = 10;
let stockPrice = function () {
setTimeout(function() {
iterator.next(price++);
}, 300);
}
let badStockPrice = function () {
iterator.next(price++);
@deepak
deepak / consumer.es.js
Created February 5, 2015 08:04
where is the exports variable defined ?
export {Worker} from './package';
@deepak
deepak / homebrew segfault due to readline
Last active August 29, 2015 14:15
segfault with ruby's readline
➜ ~ brew upgrade wget
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/readline.bundle: [BUG] Segmentation fault
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
@deepak
deepak / migration_file_with_error.rb
Last active August 29, 2015 14:15
hstore throwing a warning for rails migration
class SetupHstore < ActiveRecord::Migration
def up
execute "CREATE EXTENSION IF NOT EXISTS hstore"
end
def down
execute "DROP EXTENSION IF EXISTS hstore"
end
end
@deepak
deepak / test.rb
Created April 14, 2015 10:46
including a module as private in ruby, does not change anything
# including a module as private in ruby, does not change anything
# to test
mixin_methods = Mixin.instance_methods
controller = SomeController.new
status = mixin_methods.each_with_object({}) { |x, acc| acc[x] = controller.respond_to?(x) }
status.select { |k,v| !v }.keys # will be empty
@deepak
deepak / rubygems-timeout.txt
Created June 16, 2015 09:41
gem fetch timeout
Gem::RemoteFetcher::FetchError: Errno::ETIMEDOUT: Operation timed out - connect(2) for "rubygems.org" port 443 (https://rubygems.org/gems/rspec-rails-3.3.1.gem)
An error occurred while installing rspec-rails (3.3.1), and Bundler cannot continue.
Make sure that `gem install rspec-rails -v '3.3.1'` succeeds before bundling.
Xzibit = Object clone do(
dawg = method(what,
"yo dawg" print.
what print.
"clone" print.
self
).
so_you_can = method(
"so you can print" print.
require 'rubygems'
require 'eventmachine'
require 'socket'
module RPCServer
include EM::P::ObjectProtocol
def post_init
@obj = Hash.new
end
def receive_object method
#!/usr/bin/env ruby
require "benchmark"
open('gdb-script', 'w') do |f|
f.puts <<-EOS
p ((unsigned int)rb_gc_stack_start - (unsigned int)$esp)
detach
quit
EOS