Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require "rubygems"
# Take a copy of the arguments as rubygems or bundler modifies them
args = ARGV.dup
begin
gem "bundler"
rescue Gem::LoadError
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV["BUNDLE_IGNORE_CONFIG"] = 'true'
install_only = ARGV.to_a.map(&:to_sym)
install_only = [:host] if install_only.empty?
require 'bundler'
Bundler.configure
@bogdanRada
bogdanRada / irb_require_without_bundler_hack.rb
Created April 14, 2016 17:05 — forked from skojin/irb_require_without_bundler_hack.rb
workaround to load irb specific gem (loaded in .irbrc) in bundler environment, like rails3 console
# Add all gems in the global gemset to the $LOAD_PATH so they can be used in rails3 console with bundler
if defined?(::Bundler)
$LOAD_PATH.concat Dir.glob("#{ENV['rvm_path']}/gems/#{ENV['rvm_ruby_string']}@global/gems/*/lib")
end
@bogdanRada
bogdanRada / em-http-request with capturing and passing cookies on redirects.rb
Last active April 27, 2016 09:49 — forked from olivere/gist:877805
em-http-request with capturing and passing cookies on redirects
# Gemfile
source "http://rubygems.org"
gem 'eventmachine', '~>1.0.0.beta.3'
gem 'em-synchrony', '~>0.3.0.beta.1'
gem 'em-http-request', '~>1.0.0.beta3'
gem 'addressable', :require => 'addressable/uri'
# Capturing and passing cookies on redirects
require "rubygems"
require 'json'
require 'active_support/core_ext/numeric/bytes'
require 'delegate'
require 'forwardable'
require 'time'
require 'celluloid/io'
require 'websocket/driver'
require 'webmachine'
require 'webmachine/adapters/rack'
require 'celluloid/autostart'
@bogdanRada
bogdanRada / synchro.js
Created February 10, 2016 12:54 — forked from prozacgod/synchro.js
node.js synchronize multiple actions
/*
A simple and elegant function to synchronize multiple functions that expect callback as their last parameter.
example:
sync(func1, [parms], func2, func3, func4, [parms], callback);
Public domain!!
please leave me a comment if you like it!
*/
@bogdanRada
bogdanRada / asana.rb
Created January 27, 2016 18:20
Pull asana tasks/ids into git commit message file
require 'asana'
access_token = '12345678'
project_id = 12345678 # find this in your URL
user_id = 12345678 # found this by right clicking on my avatar in asana and inspecting element - it's in the URL there
COMMENT_CHAR = '#' # replace with your editor's comment character(s)
client = Asana::Client.new do |c|
c.authentication :access_token, access_token
end
@bogdanRada
bogdanRada / rack-and-mongo.rb
Created January 18, 2016 15:15 — forked from jackdoe/rack-and-mongo.rb
mongoid stored rack session Rack::Session::RackAndMongo
# inspired by https://github.com/biilmann/mongo_sessions
require 'rack/session/abstract/id'
class Session
include Mongoid::Document
field :sid
field :data
field :ts, type: Integer
index :sid, unique: true #dont forget Session.create_indexes
def Session.find_by_sid(sid)
Session.first(conditions: {sid: sid})
@bogdanRada
bogdanRada / decode_session_cookie.rb
Created January 6, 2016 18:23 — forked from pdfrod/decode_session_cookie.rb
A simple script to decode Rails 4 session cookies
@bogdanRada
bogdanRada / exit_handler.rb
Created January 5, 2016 06:50 — forked from nickelser/exit_handler.rb
exit_handler monkeypatch for pool
module Celluloid
module Supervision
class Container
# Manages a fixed-size pool of actors
# Delegates work (i.e. methods) and supervises actors
# Don't use this class directly. Instead use MyKlass.pool
class Pool
def initialize(options={})
@idle = []
@busy = []