Skip to content

Instantly share code, notes, and snippets.

View nicotaing's full-sized avatar
🥐

Nico Taing nicotaing

🥐
View GitHub Profile
Verifying I am +nicotaing on my passcard. https://onename.com/nicotaing
@nicotaing
nicotaing / Subway---Red-Line.markdown
Created August 28, 2013 09:09
A Pen by Carl Calderon.

Mocha/MiniTest integration

I think that the approach @tenderlove has suggested to avoid monkey-patching MiniTest (and the way MiniTest works) means that to use Mocha with MiniTest, you would either need to include the Mocha integration module into every test case, or define your own test case class inheriting from MiniTest::Unit::TestCase.

This works well for Rails (i.e. ActiveSupport), because it already defines a new test case class (ActiveSupport::TestCase) which is a suitable place to include the Mocha integration module.

If we were to go down this route, in non-Rails Ruby projects you'd need to do one of the following...

Option A

@nicotaing
nicotaing / steps.md
Last active December 12, 2015 03:48
Install rvm on mountain lion
$ curl -L https://get.rvm.io
$ rvm pkg remove
$ rvm requirements run
@nicotaing
nicotaing / gist:4034961
Created November 7, 2012 22:31
Find same integers of 2 arrays
#!/usr/bin/env ruby
a1 = [8, 2, 1, 5, 9, 10]
a2 = [7, 14, 2, 8, 1, 6, 3, 10]
# Sort arrays
a1.sort!; a2.sort!
i,j = 0,0
@nicotaing
nicotaing / gist:3903332
Created October 17, 2012 02:12
Beaneater API Draft
# Connection, Tubes, Jobs, Stats
@beaneater_connection = Beaneater::Connection.new(['localhost:11300'])
### Producer
@beaneater_tube = @beaneater_connection.tubes.find_or_create('tube2')
@beaneater_tube.put "data", :priority => 1000, :ttr => 10, :delay => 5
# => true
### Worker
@nicotaing
nicotaing / gist:1834943
Created February 15, 2012 10:37
Mongodb _id uniqueness constraint...
ruby-1.9.2-p290 :293 > Sideshow.find('4f2b35718de4984840000395').sync_items.map(&:id)
[
[ 0] BSON::ObjectId('4f2b35718de4984840000396'),
[ 1] BSON::ObjectId('4f2b35718de4984840000396'),
[ 2] BSON::ObjectId('4f2b35ad8de498484000039c'),
[ 3] BSON::ObjectId('4f2b35ad8de498484000039c'),
[ 4] BSON::ObjectId('4f2b35a28de498484000039b'),
[ 5] BSON::ObjectId('4f2b35a28de498484000039b'),
[ 6] BSON::ObjectId('4f2b35858de498484000039a'),
[ 7] BSON::ObjectId('4f2b35858de498484000039a'),
@nicotaing
nicotaing / gist:1258542
Created October 3, 2011 06:12
Hominid monkey patch
module Hominid
class API
def class
Hominid::API
end
end
end
@nicotaing
nicotaing / Passenger.txt
Created September 23, 2011 23:05
Lion Server Setup
Install Passenger in Lion
http://electronicholas.com/2011/08/passenger-prefpane-1-5-for-mac-os-x-lion-10-7/passenger-prefpane/
Enable web server in "Server App"
gem install passenger
rvmsudo passenger-install-apache2-module
copy commands from output to /etc/apache2/other/passenger.conf
Here's an example with ree@integrity gemset
@nicotaing
nicotaing / gist:1155819
Created August 19, 2011 01:56
YAML conversion to redis
["featured_sections.yml", "team.yml","press_articles.yml"].each do |yr|
text = File.read(Rails.root.join("config/#{yr}"))
$redis.set("yaml_record:" + yr, text)
puts "#{yr}: yes!" if text == $redis.get("yaml_record:" + yr)
end
["partner_shows.yml", "faq.yml"].each do |sf|
text = File.read(Rails.root.join("config/#{sf}"))
$redis.set("simple_yaml:" + sf, text)
puts "#{sf}: yes!" if text == $redis.get("simple_yaml:" + sf)