Skip to content

Instantly share code, notes, and snippets.

View guillermo's full-sized avatar
😍
Processing request ...

Guillermo Álvarez guillermo

😍
Processing request ...
View GitHub Profile
#!/usr/bin/env ruby
def trace(msg)
$stderr.puts msg
end
begin
require "rest"
rescue LoadError => e
trace("Install nap dependency")
@guillermo
guillermo / designer.html
Last active August 29, 2015 14:16
designer
<link href="../paper-toggle-button/paper-toggle-button.html" rel="import">
<polymer-element name="my-element">
<template>
<style>
#design_host {
position: absolute;
width: 100%;
height: 100%;
@guillermo
guillermo / domain_filter.rb
Created June 24, 2014 09:24
Rack Middleware for filtering domains
class DomainFilter
def initialize(app, domain, &block)
@external_app = app
@domain_app = Rack::Builder.new(&block)
@domain = domain
end
def call(env)
if env["HTTP_HOST"].match(@domain)
@domain_app.call(env)
@guillermo
guillermo / my_app.sh
Created January 15, 2014 08:27
This is a unix wrapper around the erlang vm.
#!/bin/bash
# This is a unix wrapper around the erlang vm. It provides the following functionality:
#
# * Spawns in foreground
# * Handle SIGHUP and call RELOADFUNC
# * Handle SIGTERM SIGQUIT and SIGINT telling to the vm to quit
# * Dies if the vm dies (for example kernel killing because out of memory)
#
# Forks and improvements are welcome.
@guillermo
guillermo / rsa_test.go
Created May 31, 2013 23:02
Simple test that reads a use a private key in pem format, to encrypt and decrypt with rsa a message
package rsa_test
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"encoding/pem"
"io"
"testing"
@guillermo
guillermo / editor.sh
Last active December 15, 2015 14:59 — forked from ttscoff/editor.sh
#!/bin/bash
case $1 in
*_EDITMSG|*MERGE_MSG|*_TAGMSG )
/usr/local/bin/vim $1
;;
*.md|*.txt )
/usr/local/bin/mmdc $1
;;
* )
@guillermo
guillermo / fosdem.sh
Created February 2, 2013 11:53
Open all fosdem streams with cvlc
#!/bin/bash
quit()
{
jobs -p | xargs kill
}
trap quit SIGINT
cvlc http://streaming.fosdem.org/fosdem/janson.webm.m3u &
cvlc http://streaming.fosdem.org/fosdem/k-auditorium.webm.m3u &
@guillermo
guillermo / gist:3131665
Created July 17, 2012 20:01
OpenStruct id method
$ cat test/test_id_method.rb
require 'test/unit'
require 'ostruct'
print "\n", RUBY_VERSION, "\n"
class TestIdMethod < Test::Unit::TestCase
def test_id_method
$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2)
Installing rake-hooks (1.2.3)
Using bundler (1.0.21)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
😳 15:35:21 guillermo@Guillermos-MacBook-Pro:/tmp/asdf ruby-1.9.2-p290
$ cat Gemf
Gemfile Gemfile.lock
😳 15:35:21 guillermo@Guillermos-MacBook-Pro:/tmp/asdf ruby-1.9.2-p290
[
{
"id": 1,
"name": {
"first": "Guillermo",
"last": "Alvarez"
},
"child": [
{
"name": "pepe",