This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest_client' | |
url = "http://rubygems.org/gems?letter=" | |
('A' .. 'Z').each do |letter| | |
response = RestClient.get url + letter | |
total = response.to_s.match(/(\d+)<\/b> in total/)[1] | |
puts letter + " total " + total | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
require 'hardware' | |
class Mongodb < Formula | |
homepage 'http://www.mongodb.org/' | |
packages = { | |
:x86_64 => { | |
:url => 'http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.1.0.tgz', | |
:md5 => '8645b107c0e9342bfaab4e68281e0d9b', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mongoid' | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db("so_test") | |
end | |
class Client | |
include Mongoid::Document | |
belongs_to :contact | |
field :name, type: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume a document structure as follows: | |
db.test.insert( { epochs : [1331781663, 1331781670, 1331781795], otherData : "Hello" } ); | |
db.test.insert( { epochs : [1331721663, 1331721670, 1331721795], otherData : "Goodbye" } ); | |
map = function() { | |
var d = this.otherData; | |
this.epochs.forEach(function(epoch) { | |
// Pin the epochs to a certain date | |
var date = new Date(epoch * 1000); // js does timestamps in milliseconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Insert some data into mongo: | |
[{email: "[email protected]", user_id: "bob", artist_number: 24}, {email: "[email protected]", user_id: "bob", artist_number: 22}, {email: "[email protected]", user_id: "joe", artist_number: 24}, {email: "[email protected]", user_id: "susan", artist_number: 21}, {email: "[email protected]", user_id: "susan", artist_number: 24}, {email: "[email protected]", user_id: "joe", artist_number: 22}].forEach(function(d) { db.artists.insert(d); }); | |
// Declare map and reduce | |
map = function () { | |
emit({artist:this.artist_number, user:this.user_id}, 1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PKFactory | |
def create_pk(row) | |
puts "creating #{row.inspect}" | |
row['_id'] = row['name'] | |
row | |
end | |
end | |
Mongoid.configure do |config| | |
puts config.inspect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Epping Club", | |
"id": "13092989", | |
"hasExposureProducts": false, | |
"listingType": "Business", | |
"reportingId": "eyJzb3VyY2UiOiJZRUxMT1ciLCJwcm9kdWN0SWQiOiIxODQ3Nzg5MzIiLCJwcm9kdWN0VmVyc2lvbiI6IjEifQ", | |
"primaryAddress": { | |
"state": "NSW", | |
"type": "PHYSICAL", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if $('#your_form_id').length > 0 | |
$.rails.ajax = (options) -> | |
options.success = -> | |
# do some stuff | |
# hide the first div, show the second | |
$.ajax(options) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TypekitConfig = { | |
kitId: '<YOUR KIT ID HERE>' | |
}; | |
(function() { | |
var tk = document.createElement('script'); | |
tk.src = '//use.typekit.com/' + TypekitConfig.kitId + '.js'; | |
tk.type = 'text/javascript'; | |
tk.async = 'true'; | |
tk.onload = tk.onreadystatechange = function() { | |
var rs = this.readyState; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --disable-bundled-ppapi-flash --user-datadir=/Users/$USER/Library/Application\ Support/Google/Chrome\ Canary/ 1> /dev/null 2> /dev/null &" > ~/Chrome.command | |
chmod 775 ~/Chrome.command |
OlderNewer