Skip to content

Instantly share code, notes, and snippets.

View weapp's full-sized avatar
💸

Manuel Albarran weapp

💸
View GitHub Profile
# Usage: redis-cli publish message hello
require 'sinatra'
require 'redis'
conns = []
get '/' do
erb :index
end
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' }"
# http://www.rubytapas.com/episodes/7-Constructors
class RpsMove
def self.new(move)
@cache ||= {}
@cache[move] ||= super(move)
end
def initialize(move)
@move = move
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")
class Foo
class << self
def cls_method
"cls_method"
end
end
def ins_method
self.class.cls_method
end
// ==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"})
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|
#!/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;;
#!/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]] } }
@weapp
weapp / life.js
Last active August 29, 2015 14:26 — forked from faddah/life.js
function from Lea Verou's version of Conway's Game Of Life
(function() {
var buttons = {
next: $('button.next')
};
buttons.next.addEventListener('click', function() {
lifeView.next();
});