This file contains 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
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?> | |
<!-- Edited by XMLSpy® --> | |
<catalog> | |
<cd> | |
<title>Empire Burlesque</title> | |
<artist>Bob Dylan</artist> | |
<country>USA</country> | |
<company>Columbia</company> | |
<price>10.90</price> |
This file contains 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 'rubygems' | |
require 'pp' | |
#require 'ap' # Awesome Print | |
class Object | |
# expects [ [ symbol, *args ], ... ] | |
def recursive_send(*args) | |
args.inject(self) { |obj, m| obj.send(m.shift, *m) } | |
end | |
end |
This file contains 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
# products: | |
# - _id | |
# - name | |
# - kraken_id | |
# - parent_id | |
class Product | |
include Mongoid::Document | |
include Mongoid::Kraken | |
field :name, :type => String | |
end |
This file contains 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
#!/usr/bin/env ruby | |
# | |
# Originally written by http://redartisan.com/tags/csv | |
# Added and minor changes by Gavin Laking | |
# Rewritten by Andrew Bennett for Ruby 1.9 | |
# | |
# Usage: ruby csv_to_fixture.rb file.csv [--json] | |
# | |
# "id","name","mime_type","extensions","icon_url" | |
# "1","unknown","unknown/unknown","||","/images/icon/file_unknown.gif" |
This file contains 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
resources :categories | |
## equivalent to: | |
get '/categories(.:format)' => 'categories#index', :as => :categories | |
post '/categories(.:format)' => 'categories#create' | |
get '/categories/new(.:format)' => 'categories#new', :as => :new_category | |
get '/categories/:id/edit(.:format)' => 'categories#edit', :as => :edit_category | |
get '/categories/:id(.:format)' => 'categories#show', :as => :category | |
put '/categories/:id(.:format)' => 'categories#update' |
This file contains 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
resources :categories, :constraints => { :id => /.+?/ } | |
## equivalent to: | |
get '/categories(.:format)' => 'categories#index', :as => :categories | |
post '/categories(.:format)' => 'categories#create' | |
get '/categories/new(.:format)' => 'categories#new', :as => :new_category | |
get '/categories/*id/edit(.:format)' => 'categories#edit', :as => :edit_category | |
get '/categories/*id(.:format)' => 'categories#show', :as => :category | |
put '/categories/*id(.:format)' => 'categories#update' |
This file contains 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
# paste into a rails console | |
# usage: 99.bottles.of_beer.on_the_wall.sing! | |
# alternate: 24.bottles.of_water.on_my_desk.sing! | |
class Bottle < ::ActiveSupport::BasicObject | |
attr_accessor :value, :type, :where | |
def initialize(value, type = nil, where = nil) #:nodoc: | |
@value, @type, @where = value, type, where | |
end |
This file contains 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
<!-- jQuery library for embedding gists in blog posts, etc. --> | |
<div id="1352696" class="gist"></div> | |
<!-- or --> | |
<div id="gist-1352696" class="gist"></div> | |
<script src="http://gist.pagodabox.com/jquery.gist.js"></script> |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script class="jsbin" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<!--[if IE]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<script src="https://raw.github.com/brandonaaron/jquery-mousewheel/master/jquery.mousewheel.js"></script> |
This file contains 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 'digest/md5' | |
def bson_id | |
[ | |
'%08x' % Time.now.utc.to_i, # 4 bytes | |
Digest::MD5.hexdigest(`hostname`.strip)[0..5], # 3 bytes | |
'%04x' % $$, # 2 bytes | |
'%06x' % rand(0..('f' * 6).to_i(16)) # 3 bytes | |
] # 12 bytes total | |
end |
OlderNewer