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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. |
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 bash | |
apt-get update | |
apt-get -y install git-core curl build-essential autoconf zlib1g-dev libssl-dev libxml2-dev libreadline6-dev sqlite3 libsqlite3-dev imagemagick libmagickwand-dev libxslt-dev postgresql libpq-dev golang libv8-dev | |
# install rbenv and ruby-build | |
sudo -u vagrant git clone git://github.com/sstephenson/rbenv.git /home/vagrant/.rbenv | |
sudo -u vagrant echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> /home/vagrant/.profile | |
sudo -u vagrant echo 'eval "$(rbenv init -)"' >> /home/vagrant/.profile | |
sudo -u vagrant git clone git://github.com/sstephenson/ruby-build.git /home/vagrant/.rbenv/plugins/ruby-build |
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
# Find me at https://gist.github.com/863277 | |
# Run me with "rails new myapp -J -m https://gist.github.com/raw/863277/rails3-template-with-devise-compass-and-friends.rb" | |
# You should visit | |
# http://everydayrails.com/2011/02/28/rails-3-application-templates.html | |
# http://railswizard.org | |
# http://stackoverflow.com/questions/4999207/rails-3-application-templates | |
# https://github.com/fnichol/rails-template-recipes | |
# for some inspiration about application templates. | |
# twitter.com/@clmntlxndr |
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
<%= form_for parent do |parent_form_builder| %> | |
<%= parent_form_builder.text_field :name %> | |
<% parent.children.each_with_index do |child, index| %> | |
<% parent_form_builder.fields_for :children, child do |child_form_builder| %> | |
<%= child_form_builder.select :age, (0..99).to_a %> | |
<%# generates "parent[:children_attributes][index][age]" as name for the input %> | |
<% end %> | |
<% end %> | |
<%= f.submit %> | |
<% 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
Array.prototype.shuffle = function( b ) { | |
var i = this.length, j, t; | |
while( i ) { | |
j = Math.floor( ( i-- ) * Math.random() ); | |
t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i]; | |
this[i] = this[j]; | |
this[j] = t; | |
} | |
return this; | |
}; |
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
Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) } |
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
# following DOES match "foobar", "fooadmin", "adminbar", "fooadminbar" but not "admin" as a whole word : | |
/^((?!\badmin\b)[^\s]*)$/ | |
# more reserved keywords : | |
/^((?!\badmin\b|\bteam\b)[^\s]*)$/ | |
# http://www.regular-expressions.info/wordboundaries.html | |
# http://www.regular-expressions.info/lookaround.html |
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
# http://rubyquicktips.tumblr.com/post/4601358354/using-try-with-a-hash-to-check-existence-of-a-key | |
hsh = { :existing_key => | |
{ | |
:existing_sub_key => :value | |
} | |
} | |
hsh.try(:[], :existing_key).try(:[], :existing_sub_key) | |
# => :value |
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
element.addEventListener('touchstart', function(e) { | |
e.preventDefault(); | |
}, false); | |
element.addEventListener('touchmove', function(e) { | |
e.preventDefault(); | |
}, false); |
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
"toto\ntiti".lines.map{|l| l.strip}.to_a.join(", ") |
OlderNewer