Skip to content

Instantly share code, notes, and snippets.

View tarsisazevedo's full-sized avatar

Tarsis Azevedo tarsisazevedo

View GitHub Profile
/*
---
Port from the YUI3 event-simulate functionality to vanilla javascript.
...
*/
(function(global, document){
var mix = function(obj1, obj2){
for (var key in obj2){
obj1[key] = obj2[key];
@everton
everton / Bhaskara
Created April 6, 2011 13:45
Weird way to say Bhaskara in Ruby (or "((-b).± √ Δ(a, b, c))" / (2 * a) as a valid Ruby expression)
#!/usr/bin/env ruby
#-*- coding: utf-8 -*-
def √(n)
Math::sqrt(n)
end
class Numeric
def ±(n)
r = [self + n, self - n]
@douglascamata
douglascamata / tail.py
Created April 27, 2011 04:59
Tail Call Optimization in Python
#!/usr/bin/env python2.4
# This program shows off a python decorator(
# which implements tail call optimization. It
# does this by throwing an exception if it is
# it's own grandparent, and catching such
# exceptions to recall the stack.
import sys
class TailRecurseException:
@arthurfurlan
arthurfurlan / gist:947731
Created April 29, 2011 02:24
Example of the valvim's fabfile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# written by Arthur Furlan <[email protected]>
from __future__ import with_statement
from fabric.api import *
import socket
import time
@hernad
hernad / macosx_vim_ruby_python_support.md
Created June 3, 2011 17:31
macosx vim +ruby +python
@andrewsmedina
andrewsmedina / gist:1029865
Created June 16, 2011 18:21
align element vertically
.container {
line-height: 85px; /* container height */
}
.element {
display:inline;
display:inline-table;
display:inline-block;
vertical-align:middle;
}
@berinhard
berinhard / gist:1054748
Created June 29, 2011 19:50
Vim resizing windows
map <C-S-Left> <c-w><
map <C-S-Right> <c-w>>
map <C-S-Up> <c-w>-
map <C-S-Down> <c-w>+
@diofeher
diofeher / cc_validation.py
Created July 5, 2011 04:58
cc_validation
def sum_digits(num):
"""
@param: num number as string
"""
return sum([int(digit) for digit in num])
def validate(cc_number):
"""
@param: cc_number credit card number as string
"""
@tlrobinson
tlrobinson / gist:1073865
Created July 9, 2011 19:34
Autocomplete Makefile targets. Add this to your shell config file.
complete -W "\`grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' Makefile | sed 's/[^a-zA-Z0-9_-]*$//'\`" make
@fsouza
fsouza / div.c
Created September 19, 2011 03:20
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char const* argv[]) {
div_t divmod = div(8, 3);
printf("%d - %d", divmod.quot, divmod.rem);
return 0;
}