Skip to content

Instantly share code, notes, and snippets.

View maxim's full-sized avatar
🛠️

Max Chernyak maxim

🛠️
View GitHub Profile
Problem AWS DigitalOcean
Network isolation Private Cloud/Security Groups tinc / n2n / freelan
Node initialization CloudInit/User Data ?
Node discovery EC2 API Serf
Pull app on scale More Like This Serf
Distributed config etcd etcd
@apeiros
apeiros / irb_drop.rb
Created April 24, 2010 16:58
Drop into irb from anywhere within your code
module Kernel
# usage:
# require 'irb_drop'
# ...do some stuff...
# irb_drop(binding) # irb will open here with the current local variables
# ...continue doing stuff...
def irb_drop(context=nil, *argv)
require 'irb'
require 'pp'
require 'yaml'
passenger nginx rails bundler status error
2.2.5 0.8.22 2.3.5 no OK
2.2.5 0.8.22 2.3.9 yes FAIL passenger not finding gems
2.2.5 0.8.50 2.3.9 yes FAIL couldn't compile
2.2.12 0.8.50 2.3.9 yes FAIL passenger not finding gems
2.2.13 0.8.50 2.3.9 yes FAIL PassengerHelper not starting
2.2.15 0.7.67 2.3.9 yes FAIL PassengerHelper not starting
2.2.15 0.8.50 2.3.9 yes FAIL PassengerHelper not starting
3.0.0.pre3 0.8.50 2.3.9 yes OK (requires libcurl4-openssl-dev)
@maxim
maxim / next_episodes
Created September 27, 2010 05:14
Outputs sorted times of upcoming episodes of shows fetched from IMDB.
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
require 'time'
# USAGE:
# Put ids of IMDB shows here:
movie_ids = %w(tt0773262 tt0121955 tt0182576 tt0460649 tt0903747 tt0412142)
anonymous
anonymous / gist:610665
Created October 4, 2010 23:41
be careful with method empty?
class Cart < ActiveRecord::Base
has_many :line_items
delegate :empty?, :to => :line_items
end
class User < ActiveRecord::Base
has_one :cart
end
@user = User.new
@apeiros
apeiros / gist:634082
Created October 19, 2010 12:01
Terminate current process the hard way (kill -9)
module Kernel
# Terminate the current process - the hard way
def t!
`kill -9 #{$$}`
end
module_function :t!
end
@steveklabnik
steveklabnik / after.rb
Created September 5, 2011 16:43
dont load rails!
require 'active_record'
require "#{Rails.root}/app/models/user"
describe User do
it "does something sweet"
it "does something cool"
end
@charleseff
charleseff / after_commit_with_transactional_fixtures.rb
Created October 21, 2011 23:45 — forked from dcuddeback/after_commit_with_transactional_fixtures.rb
Patch ActiveRecord to fire after_commit callbacks at the appropriate time during tests with transactional fixtures.
module ActiveRecord
module ConnectionAdapters
module DatabaseStatements
#
# Run the normal transaction method; when it's done, check to see if there
# is exactly one open transaction. If so, that's the transactional
# fixtures transaction; from the model's standpoint, the completed
# transaction is the real deal. Send commit callbacks to models.
#
# If the transaction block raises a Rollback, we need to know, so we don't
@SeanTAllen
SeanTAllen / gist:7cbb72339806f3decee2
Last active October 7, 2015 22:53
The Tech "People" Bookclub
Here's the idea,
You work in tech. You're in the NYC area.
You care about "people" issues. You think the hardest problem in computing is "people".
You are interested in how we work. How to structure work. How to work together.
How to help your colleagues succeed.
And...
There's so much to learn:
a = { foo: 'foo', bar: 'bar' }
b = { foo: 'fooo' }
# Reconcile duplicate keys
a.merge(b) {|k, old_v, new_v| [old_v, new_v].min}
# => { foo: 'foo', bar: 'bar' }
# Ever wanted Hash#map to return a hash? This is a workaround
a.merge(a) {|k, v| v.upcase}
# => { foo: "FOO", bar: "BAR" }