gem install rails
rails new my_app -T
| # Usage: rackup config.ru | |
| require 'gollum' | |
| require 'gollum/frontend/app' | |
| require 'puma' | |
| Precious::App.set(:gollum_path, Dir.pwd) | |
| Precious::App.set(:server, :puma) | |
| # http://docs.mongodb.org/manual/reference/bsondump/ | |
| fh = File.open("somefile.bson", "rb") | |
| while not fh.eof? do | |
| obj = BSON.read_bson_document fh | |
| id = obj.delete "_id" | |
| # assume Thing is a Mongoid::Document | |
| thing = Thing.new obj | |
| thing["_id"] = id.to_s | |
| thing.save |
| var AutocompleteView = Backbone.View.extend({ | |
| initialize: function() { | |
| this.availableTags = [ | |
| "ActionScript", | |
| "AppleScript", | |
| "Asp", | |
| "BASIC", | |
| "C", | |
| "C++", |
| // Use the browser's built-in functionality to quickly and safely escape the | |
| // string | |
| function escapeHtml(str) { | |
| var div = document.createElement('div'); | |
| div.appendChild(document.createTextNode(str)); | |
| return div.innerHTML; | |
| }; | |
| // UNSAFE with unsafe strings; only use on previously-escaped ones! | |
| function unescapeHtml(escapedStr) { |
| GC::Profiler.enable | |
| # your code | |
| puts GC::Profiler.result | |
| # GC.disable | |
| puts ObjectSpace.count_objects.inspect |
| #!/bin/sh | |
| set -e | |
| if [ -d "generated" ] ; then | |
| echo >&2 "error: 'generated' directory already exists. Delete it first." | |
| exit 1 | |
| fi | |
| mkdir generated |
| require 'aquarium' | |
| module Gizmo | |
| class ExceptionHandling | |
| include Aquarium::DSL | |
| types = ['Gizmo::FindAll', 'Gizmo::Find', 'Gizmo::Make', 'Gizmo::Modify', 'Gizmo::Delete'] | |
| around :calls_to => [:call], :in_types => types do |jp, operation, *args| | |
| puts "inside around advice.. | |
| jp.proceed |
| # usage: | |
| # $ chrome index.html | |
| function chrome() { | |
| open $@ --args --allow-file-access-from-files | |
| } | |
| # usage: | |
| # $ server | |
| alias server='open http://localhost:8000 && python -m SimpleHTTPServer' |