View hal_builder_spec.js
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
/*globals describe, it, context*/ | |
/*jslint node: true, indent: 2*/ | |
'use strict'; | |
var HalBuilder, | |
chai = require('chai'), | |
should = chai.should(), | |
assert = chai.assert, | |
expect = chai.expect, |
View mustache-global-helper.js
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
function i18nLambda (text, render) { | |
text = dict[text] || text | |
return render(text) | |
} | |
var Context = mustache.Context | |
Context.prototype._lookup = Context.prototype.lookup | |
Context.prototype.lookup = function i18nLookup (name) { | |
return (name === 'i18n' ? i18nLambda : this._lookup(name) | |
} |
View gist:3592564
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
gem install haml hpricot ruby_parser slim haml2slim | |
rails generate devise:views | |
for i in `find app/views/devise -name '*.erb'` ; do html2haml -e $i ${i%erb}haml ; rm $i ; done | |
for i in `find app/views/devise -name '*.haml'` ; do haml2slim $i ${i%haml}slim ; done | |
for i in `find app/views/devise -name '*.haml'` ; do rm $i ; done |
View utf8encode.rake
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
desc "Manage the encoding header of Ruby files" | |
task :utf8_encode_headers => :environment do | |
files = Array.new | |
["*.rb", "*.rake"].each do |extension| | |
files.concat(Dir[ File.join(Dir.getwd.split(/\\/), "**", extension) ]) | |
end | |
files.each do |file| | |
content = File.read(file) | |
next if content[0..16] == "# coding: UTF-8\n\n" || |
View mongoid_invalid_date.rb
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
# class SomeModel | |
# include Mongoid::Document | |
# include Mongoid::DateField | |
# | |
# date_field :date_field1, Date | |
# date_field :date_field2, DateTime | |
# date_field :date_field3, Time | |
# end | |
module Mongoid |
View default.vcl
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
# /etc/varnish/default.vcl | |
# Define the list of backends (web servers). | |
# Port 80 Backend Servers | |
backend yourapp_webserver1 { | |
.host = "000.000.000.000"; | |
.port = "80"; | |
.max_connections = 250; | |
.connect_timeout = 5s; | |
.first_byte_timeout = 5s; | |
.between_bytes_timeout = 5s; |
View gist:4132382
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
# dumping a data subset | |
mongodump --port 8080 --out /tmp/collection_name -d database_name -c collection_name --query '{"created_at" : {"$gte" : {"$date" : 1353578400000} }}' | |
# exporting a data subset | |
mongoexport --port 8080 --out /var/collection_name.json -d database_name -c collection_name --query '{"updated_at" : {"$gte" : {"$date" : 1353578400000} }}' | |
# importing a data subset | |
mongoimport --port 8080 -d database_name -c collection_name --upsert --file /var/deny/collection_name.json |
View gist:4175595
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
sudo su - && yum update -y | |
yum groupinstall "Development Tools" | |
yum install wget -y | |
yum install openssl-devel.i686 openssl.i686 | |
cd /root && wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz | |
tar xvzf ruby-1.9.3-p194.tar.gz && cd ruby-1.9.3-p194 | |
./configure --disable-install-doc --with-opt-dir=/usr/lib/openssl | |
make && make install |
View callback_disabler.rb
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
# In spec/support/callback_disabler.rb | |
module CallbackDisabler | |
def self.store_callbacks(model, filters) | |
model = constantize(model) | |
filters.each do |filter| | |
model.send("_#{filter}_callbacks").each do |callback| | |
stored_callbacks[model] << { | |
filter: filter, kind: callback.kind, raw_filter: callback.raw_filter | |
} |
OlderNewer