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
PAYS = [ | |
{ :alpha2 => 'AF', :name => 'Afghanistan', :alpha3 => 'AFG', :numeric => '004' }, | |
{ :alpha2 => 'AL', :name => 'Albanie', :alpha3 => 'ALB', :numeric => '008' }, | |
{ :alpha2 => 'DZ', :name => 'Algérie', :alpha3 => 'DZA', :numeric => '012' }, | |
{ :alpha2 => 'AS', :name => 'Samoa Américaines', :alpha3 => 'ASM', :numeric => '016' }, | |
{ :alpha2 => 'AD', :name => 'Andorre', :alpha3 => 'AND', :numeric => '020' }, | |
{ :alpha2 => 'AO', :name => 'Angola', :alpha3 => 'AGO', :numeric => '024' }, | |
{ :alpha2 => 'AI', :name => 'Anguilla', :alpha3 => 'AIA', :numeric => '660' }, | |
{ :alpha2 => 'AG', :name => 'Antigua et Barbuda', :alpha3 => 'ATG', :numeric => '028' }, | |
{ :alpha2 => 'AR', :name => 'Argentine', :alpha3 => 'ARG', :numeric => '032' }, |
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
# coding: utf-8 | |
require 'sinatra' | |
set server: 'thin', connections: [] | |
get '/' do | |
halt erb(:login) unless params[:user] | |
erb :chat, locals: { user: params[:user].gsub(/\W/, '') } | |
end | |
get '/stream', provides: 'text/event-stream' do |
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 Egg | |
module Boilable | |
def boil | |
temperature.rise | |
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
# Immediate interpolation | |
firstname = 'John' | |
lastname = 'Doe' | |
fullname = "#{firstname} #{lastname}" | |
# Late interpolation (percent instead of pound sign) | |
fullname_template = "%{firstname} %{lastname}" | |
joey = {firstname: 'Joey', lastname: 'Ramone'} | |
deedee = {firstname: 'Dee Dee', lastname: 'Ramone'} | |
fullname = fullname_template % joey |
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
# This is quite common to have some local environment variables in | |
# a file called `.env` which is then ignored in your repository. | |
# This is for example a feature of `foreman`. | |
# Here is a small function which does this but for any command. | |
# Whatever the language or the command is, you just prepend | |
# your command with `dotenv` and it will load environment variables | |
# from your `.env` file. | |
# Comments are allowed in your `.env`. | |
dotenv() { |
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
# Here is a simple trick if you have a command line which | |
# needs to accept options on the command line of the form: | |
# $ mycommand domain=github.com ssl=true | |
defaults = { | |
domain: 'www.example.com', | |
port: 80, | |
ssl: false | |
} | |
o = defaults.merge( |
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
extern crate iron; | |
extern crate router; | |
fn main() { | |
use iron::prelude::*; | |
use iron::status; | |
use router::Router; | |
let mut control = Router::new(); | |
control |
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
# This is a very simple runner which assumes that all your | |
# tests match "test/test_*.rb" and what can be required is in "lib" and "test". | |
# It also assumes you use bundle. | |
# Run `mt api` if you want to run "test/test_api.rb". | |
# Just run `mt` if you want to run all tests. | |
mt() { | |
eval "bundle exec ruby -Ilib:test -e \"ARGV.reject{|f| f.match(/^-/)}.each{|f| require f.sub('test/','').sub('.rb','')}\" test/test_${1:=*}.rb --pride" | |
} |
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
module USA | |
extend self | |
def full_state_list | |
[ | |
self.state_list, | |
self.outlying_territories, | |
self.armed_forces | |
].reduce(&:concat) |
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
SRC_DIR = src | |
DST_DIR = build | |
CSS_DIR = $(DST_DIR)/css | |
SCSS_DIR = $(SRC_DIR)/scss | |
SCSS_INCLUDES_DIR = $(SCSS_DIR)/includes | |
SCSS_FILES = $(wildcard $(SCSS_DIR)/*.scss) | |
CSS_FILES=$(patsubst $(SCSS_DIR)/%.scss, $(CSS_DIR)/%.css, $(SCSS_FILES)) |
OlderNewer