Skip to content

Instantly share code, notes, and snippets.

View nicotaing's full-sized avatar
🥐

Nico Taing nicotaing

🥐
View GitHub Profile
@nicotaing
nicotaing / gist:988202
Created May 24, 2011 06:09
Simple association
#app/model/user.rb
class User < ActiveRecord::Base
#Du coup tu peux appeler @user.address => Objet Address instancie
:has_one :address
end
#app/model/address.rb
class Address < ActiveRecord::Base
#Du coup tu peux appeler @address.user => Objet User instancie
:belongs_to :address
@nicotaing
nicotaing / gist:1000088
Created May 31, 2011 07:01
parisoma member template
<!-- Name of the Member -->
<h2>Jared Goralnick</h2>
<!-- Name of the Member Company -->
<a href="http://www.awayfind.com/en">AwayFind</a>
<div id="member-social-icons">
<a id="social-twitter" title="my twitter page" href="http://twitter.com/technotheory" target="_blank">
<img class="alignnone" src="http://parisoma.com/wp-content/themes/parisomav2/images/design/twitter_32.png" alt="Sondra's twitter page" width="32" height="32" />
</a>
<a href="http://technotheory.com/">
@nicotaing
nicotaing / gist:1003195
Created June 1, 2011 20:11
Jordan example inline css
<span style="font-size:10px;color:white;">Tip 1: Find Your Friends</span>
<br>
<p style="margin-left:20px;font-weight:bold;">
lorem ipsum...
</p>
@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)
@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:1258542
Created October 3, 2011 06:12
Hominid monkey patch
module Hominid
class API
def class
Hominid::API
end
end
end
@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: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: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 / 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