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 Audition | |
include DataMapper::Resource | |
property :id, Serial | |
property :title, String | |
property :when, Time | |
property :where, String | |
property :description, Text | |
property :hash, String | |
# validates_present :name |
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
%w[rubygems dm-core].each { |g| require g.to_s } | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Something | |
include DataMapper::Resource | |
property :id, Serial | |
property :p1, String | |
property :p2, String |
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
$(document).ready(function(){ | |
$("a").click(function(event){ | |
event.preventDefault(); | |
$.get('http://localhost:8000/j', function(d,t) { | |
console.log(this); // <this> refers to the GET Object. How do I refer to the "a" that triggered the request? | |
}); | |
}); |
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
J'amasse et je m'écrie je suis ravi, je regarde sur quoi je suis assis, je m'extasie ! | |
Les gens sont si petits, hihihi, et mois me voilà si grand si roi assis tout au sommet de mon tas d'or de mon caca j'me sens si fort. Mes bras sont énormes ! Je les étends et j'amasse et je m'écrie, je regarde sur quoi je suis assis : je m'extasie ! | |
Avec des doigts si fins je pince vos têtes et je serre fort ! Le liquide qui suinte...mais c'est de l'or ! J'ai des déchets sur les bras. Des grands bras, plein de déchets, pas assez de bras, je fais un second tas ! un tas de déchets ! Ohhh oui un tas de gens ! Des jambes des bras des têtes d'enfants, ça dépasse et ça s'écroule, c'est pas solide les gens ! | |
Ce second tas pue vraiment trop, je lui tourne le dos. Que d'aventures ! Je suis si haut, si beau, si grand si gros ! Je bouge a peine , c'est confortable. Des pattes poussent à mes pièces-fourmis et elles vont chercher des copines ! Deux gros yeux endormis les observent : ils sont à moi ! Les yeux ! Les pièces ! Les gens ! |
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 Array | |
def each_slice_with_index(slice_size) | |
nb_slices = (self.size.to_f/slice_size).ceil | |
for i in 0...nb_slices | |
yield self[i*slice_size,slice_size], i | |
end | |
end | |
def each_slice_with_index_alt(slice_size) | |
slices = self.enum_slice(slice_size).map |
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 Animal | |
attr_reader :name, :color | |
def initialize(name,color) | |
@name = name | |
@color = color | |
end | |
def self.create_felix(color) | |
# Is this how I should refer to the newly created instance of Animal? |
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
# The purpose is to turn all special characters into ASCII | |
# é -> e | |
# à -> a | |
# etc... | |
require "iconv" | |
require "open-uri" | |
require "rubygems" | |
require "nokogiri" |
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 "iconv" | |
class String | |
def to_ascii | |
self.strip.to_ascii_ugly.tr("^a-zA-Z0-9 ","*").tr_s("*","") | |
end | |
# à => `a | |
# é => 'e | |
def to_ascii_ugly |
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
upstream domain1 { | |
server 127.0.0.1:3000; | |
server 127.0.0.1:3001; | |
server 127.0.0.1:3002; | |
} | |
server { | |
listen 80; | |
server_name www.domain.com; | |
rewrite ^/(.*) http://domain.com permanent; |
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
def try(x,bad_value, &block) | |
val = block.call | |
if val == bad_value | |
return (x <= 0) ? nil : try(x-1) { block.call } | |
else | |
return val | |
end | |
end |
OlderNewer