Skip to content

Instantly share code, notes, and snippets.

View galvez's full-sized avatar

Jonas Galvez galvez

View GitHub Profile
def try_sending_email():
import os, smtplib, mimetypes
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Encoders import encode_base64
gmail_user = '[user]@gmail.com'
gmail_password = '[password]'
recipient = '[recipient]'
msg = MIMEMultipart()
@galvez
galvez / __init__.py
Created November 30, 2010 17:50
Bootstrap code for a fabfile module that automatically loads all .py files and makes all pre-loaded libraries available to them
from __future__ import with_statement
from fabric.api import *
from code import interact
import os
import sys
import time
APP_ROOT = os.path.abspath(os.path.dirname(__file__))
@galvez
galvez / gist:735499
Created December 9, 2010 23:24 — forked from adamv/gist:735176
def print_warning(msg):
print fabric.colors.red("WARNING: ") + msg
def print_error(msg):
print fabric.colors.red("ERROR: ") + msg
def print_label(msg):
print fabric.colors.blue("==> ", bold=True) + msg
@galvez
galvez / deorphanize.js
Created July 6, 2012 12:30
deorphanize.js
var deorphanize = function(text, line_length) {
// alert(typeof line_length)
if(typeof line_length == 'undefined') {
line_length = 40;
}
text = $.trim(text);
if(text.length > line_length) {
if(text.length < (line_length*2)) {
line_length = text.length/3;
}
// Simple D3-based square graph generator
// To display accomplished pomodoros in each weekday
// Used in hire.jonasgalvez.com.br
function shuffle(array) {
// https://github.com/coolaj86/knuth-shuffle
var currentIndex = array.length, temporaryValue, randomIndex ;
while (0 !== currentIndex) {
#!/usr/bin/env python
from re import sub
from string import ascii_lowercase
from code import interact
from collections import defaultdict
from random import choice, shuffle
from itertools import groupby
VOWELS = list('aeiou')
+ 3000 Salary
- 100 Expense
- 200 Expense
- 50 Expense
= Group
- 100 Expense
- 200 Expense
import csv
import itertools
def match(file, fields):
records = {}
parsed = list(csv.reader(open(file, 'rU')))
columns = parsed[0]
indexes = {}
index_fields = list(itertools.chain(*[
f for f in fields if type(f) == list
import csv
import itertools
def match(file, fields):
records = {}
parsed = list(csv.reader(open(file, 'rU')))
columns = parsed[0]
indexes = {}
index_fields = list(itertools.chain(*[
f for f in fields if type(f) == list

Declare

$('.awesome').show(); // Error: cannot find name `$`

declare var $:any;
$('.awesome').show(); // Okay!

declare var $:{