Skip to content

Instantly share code, notes, and snippets.

@bogdanRada
bogdanRada / actor.rb
Created July 12, 2016 08:10 — forked from betawaffle/actor.rb
Ruby Actors
require 'fiber'
require 'eventmachine'
module Actor
class << self
def current
Mailbox.current
end
end
@bogdanRada
bogdanRada / install.txt
Created July 1, 2016 07:41 — forked from juniorz/install.txt
How to fix memory leak in capybara-webkit
webkit_server (capybara-webkit) leaks memory on the following environment:
* Mac OS X Mountain Lion (10.8.2)
* XQuartz 2.7.4
* Qt 4.8.3
How to fix:
1) Downgrade Qt to 4.7.4
brew unlink qt
cd `brew --prefix`
@bogdanRada
bogdanRada / gzip.rb
Created June 28, 2016 10:09 — forked from richardsondx/gzip.rb
Monkey patch to fix Authentication failure! invalid_credentials: OAuth2::Error jruby 8 , rails 3.2.13 devise 3.2.4 | Force faraday to 'uncompressed' gzip
# In Rails, add this to your Initializer/ folder
#
# Fix by @richardsondx - Richardson Dackam
#
# Thi monkey patch is not actually forcing farady to uncompress the response but it's telling it not to compress
# So it forces Faraday to avoid compressing the response.
# The gresponse from google had the header 'accept-encoding': 'gzip'
# unlike http.net, http.request doesn't automatically uncompress gzip request
# more info about http.request at https://github.com/ruby/ruby/blob/ruby_2_2/lib/net/http.rb
#!/usr/local/rvm/wrappers/ruby-1.9.3-p194/ruby
require "cgi"
require "uri"
require "socket"
SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 1024
cgi = CGI.new
unless ENV.include?('CI')
ENV['DISPLAY'] = ':99'
pid = Process.spawn('Xvfb :99 -ac', out: '/dev/null', err: '/dev/null')
at_exit { Process.kill(:SIGINT, pid) }
end
@bogdanRada
bogdanRada / gist:34bd83983c4bd51230d2f1c63bda419f
Created June 14, 2016 12:31 — forked from qsun/gist:1247402
ruby integer to/from ip address
require 'ipaddr'
IPAddr.new('1.2.3.4').to_i
IPAddr.new(16909060, Socket::AF_INET).to_s
@bogdanRada
bogdanRada / gist:e59a9747da7a63320687e7dc69b4eb70
Last active June 7, 2016 12:33 — forked from ryanlecompte/gist:1619490
Experimenting with forking and unix sockets in Ruby
#!/usr/bin/env ruby
require 'base64'
require 'socket'
require 'fileutils'
require 'securerandom'
# UnixSocketForker is an experiment of inter-process communication using
# plain unix sockets to communicate between forked processes and the
# parent process. This can also be done via IO.pipe. In this experiment,
@bogdanRada
bogdanRada / 12factor_rails.rb
Created June 6, 2016 05:31 — forked from bf4/12factor_rails.rb
code snippets from libraries that I find interesting
# https://github.com/heroku/rails_stdout_logging/blob/master/lib/rails_stdout_logging/rails.rb
module RailsStdoutLogging
class Rails
def self.heroku_stdout_logger
logger = Logger.new(STDOUT)
logger = ActiveSupport::TaggedLogging.new(logger) if defined?(ActiveSupport::TaggedLogging)
logger.level = Logger.const_get(log_level)
logger
end
@bogdanRada
bogdanRada / show_dependencies
Created June 3, 2016 15:40 — forked from mmrwoods/show_dependencies
Hacky script to show bundled dependencies of rails app
#!/usr/bin/env ruby
require 'bundler'
require 'hirb'
require 'csv'
lock_file = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))
def url_for(spec)
case spec.source
@bogdanRada
bogdanRada / gemfile_lock2geminabox.rb
Created June 3, 2016 12:14 — forked from flavio/gemfile_lock2geminabox.rb
Parse Gemfile.lock, download all gems from rubygems and then upload them to a local instance of geminabox
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
require 'fileutils'
require 'net/http'
require 'net/https'
require 'uri'
TMP_DIR = "/tmp/gems"