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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
worker_processes 4 | |
timeout 20 | |
preload_app true | |
listen ENV['PORT'].to_i, backlog: 10 | |
before_fork do |server, worker| | |
Signal.trap 'TERM' do | |
puts 'Unicorn master intercepting TERM and sending myself QUIT instead' | |
Process.kill 'QUIT', Process.pid |
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
box: wercker/nodejs | |
# Build definition | |
build: | |
# The steps that will be executed on build | |
steps: | |
# A step that executes `npm install` command | |
- npm-install | |
# A step that executes `npm test` command | |
- npm-test |
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
class Hash | |
def dig(dotted_path) | |
parts = dotted_path.split '.', 2 | |
first_part = parts[0] | |
match = self[first_part] || self[first_part.to_sym] | |
if !parts[1] || match.nil? | |
return match | |
else | |
return match.dig(parts[1]) | |
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
BASE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" | |
def random_string(length = 3) | |
length.times.map { BASE[rand(BASE.length)] }.join | |
end | |
puts 4.times.map { random_string }.join('-') |
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
Rails.application.routes.draw do | |
get '/(:locale)/products/(:category)/(page/:page).:extension', | |
:to => 'products#index', | |
:as => :products, | |
:constraints => { | |
:locale => /[a-z]{2}/, | |
:category => /.+?/, | |
:page => /\d+/ | |
}, |
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
my_objects.each do |my_object| | |
if my_other_objects.any?{|my_other_object| my_other_object.Name == my_object.name} | |
# do something if we found one | |
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
// used to verify characters and prevent incorrect input as the user is typing. | |
// TODO: detect special characters like period/comma/?/etc. in the first regexp | |
// USAGE: use the keydown event: "return dynamicVerify(e, '[0-9a-zA-Z]');" | |
// e = event, re = regexp for allowed characters, ce = regexp for allowed key codes | |
function dynamicVerify(e, re, ke) { | |
var key = e.keyCode || e.which; | |
var keychar = String.fromCharCode(key); | |
var rexp = new RegExp(re); | |
var kexp = new RegExp(ke); |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Mathieu 'p01' Henri <http://www.p01.org/releases/> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
OlderNewer