Skip to content

Instantly share code, notes, and snippets.

View mvrilo's full-sized avatar
🌳

Murilo Santana mvrilo

🌳
View GitHub Profile
package main
import (
"crypto/md5"
"crypto/sha1"
"encoding/hex"
"fmt"
"io"
)
func Shift(list []string) (string, []string) {
return list[0], list[1:len(list)]
}
function childFind(selector, which) {
if (!this || !this.length) return $([]);
which = (which || 'previous') + 'Sibling';
var element = this[0][which];
while (element && (element.nodeType !== 1 || !$(element).is(selector))) element = element[which];
return $(element);
@mvrilo
mvrilo / gitlab
Created October 23, 2012 17:36
gitlab init
#! /bin/bash
# GITLAB
# Maintainer: @randx
# App Version: 2.9
# from: https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab
### BEGIN INIT INFO
# Provides: gitlab
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
@mvrilo
mvrilo / gist:3814857
Created October 1, 2012 22:29
getting ruby and gemset from .rvmrc
sed -e 's/^rvm \(.*\)/\1/' .rvmrc | grep '@'
# separating emails by the host
hash = {}
%w{ mvrilo@gmail.com mvrilo+test@gmail.com }.each do |mail|
id, host = mail.split("@")
hash[host] ||= []
hash[host] << id
end
>> Resolv::DNS.new.getresources("gmail.com", Resolv::DNS::Resource::IN::MX).map { |dns| dns.exchange.to_s }
=> ["alt3.gmail-smtp-in.l.google.com", "alt4.gmail-smtp-in.l.google.com", "gmail-smtp-in.l.google.com", "alt1.gmail-smtp-in.l.google.com", "alt2.gmail-smtp-in.l.google.com"]
var i = 6,
list = {};
console.log('base: 16px');
console.log('-----------------');
while (i < 50) {
var px = i + 'px',
em = String(i/16) + 'em';
list[px] = em;
@mvrilo
mvrilo / gist:1455340
Created December 10, 2011 14:53
defining a function
var ben = require('ben');
var fn = ben(100000, function() {
var test = function() { return "test"; };
test();
});
var newFunction = ben(100000, function() {
var test = new Function('', 'return "test"');
test();
@mvrilo
mvrilo / sleep.sh
Created October 19, 2011 11:49
put mac os x to sleep
#!/bin/bash
osascript << EOT
tell application "System Events"
sleep
end
EOT