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
# Usage: redis-cli publish message hello | |
require 'sinatra' | |
require 'redis' | |
conns = [] | |
get '/' do | |
erb :index | |
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
require 'rest_client' | |
require 'json' | |
require 'pp' | |
COUCHDB = "http://localhost:5984/dbname" | |
filters_doc = { | |
"_id" => "_design/app", | |
"filters" => { | |
"people"=> "function(doc, req) { return doc.type == 'person' }" |
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://www.rubytapas.com/episodes/7-Constructors | |
class RpsMove | |
def self.new(move) | |
@cache ||= {} | |
@cache[move] ||= super(move) | |
end | |
def initialize(move) | |
@move = move |
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 "ostruct" | |
obj = OpenStruct.new(a: "a", b: "b", to_ary: ["a", "b"] ) | |
a, b = obj | |
puts "a: #{a}" | |
puts "b: #{b}" | |
obj = OpenStruct.new(a: "a", b: "b") |
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 Foo | |
class << self | |
def cls_method | |
"cls_method" | |
end | |
end | |
def ins_method | |
self.class.cls_method | |
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
// ==UserScript== | |
// @name Enlaces Entradas | |
// @namespace http://use.i.E.your.homepage/ | |
// @version 0.1 | |
// @description enter something useful | |
// @match http://entradas/* | |
// @copyright 2012+, You | |
// ==/UserScript== | |
$("a[href^=\\/]").not("a[href^=\\/entradas]").css({"padding":"2.5px", "outline": "1px dashed #000", "border": "2.5px solid #DD0"}) |
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 "pp" | |
block_size = 4_096 | |
def tags_from_file(filename) | |
no_tag_or_tag = /([^<>]+)|(<\/[^<>]+>)|(<[^<>]+?\/>)|(<\!\[CDATA\[(?:.*?)\]\]>)|(<[^!a-zA-Z][^<>]+>)|(<[^<>]+>)/ | |
reg_exp = /\A(?<p>(?:#{no_tag_or_tag}))*\g<p>*/ | |
block_size = 4_096 | |
Enumerator.new do |enum| |
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
#!/bin/bash | |
cd ~/projects/ | |
echo -en '\033]2;'$1'\007' # set the title of the window | |
case "$1" in | |
wubytes) cd wubytes && foreman start;; | |
kiwitime) cd kiwitime && rails s -p 5000;; |
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 ruby | |
# require 'bundler/setup' | |
# Bundler.require(:default) | |
module F | |
ZERO = -> p { -> x { x } } | |
ONE = -> p { -> x { p[x] } } | |
TWO = -> p { -> x { p[p[x]] } } |
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() { | |
var buttons = { | |
next: $('button.next') | |
}; | |
buttons.next.addEventListener('click', function() { | |
lifeView.next(); | |
}); |
OlderNewer