Skip to content

Instantly share code, notes, and snippets.

View galvez's full-sized avatar

Jonas Galvez galvez

View GitHub Profile
import json
import re
import code
import pprint
from marshmallow import Schema
from marshmallow.schema import Schema
from marshmallow.fields import Str, Bool, Int, List, Nested, DateTime, URL
from werkzeug.routing import Map, Rule, NotFound, RequestRedirect
BASE = os.path.abspath(os.path.dirname(__file__))

Declare

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

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

declare var $:{
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
+ 3000 Salary
- 100 Expense
- 200 Expense
- 50 Expense
= Group
- 100 Expense
- 200 Expense
#!/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')
// 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) {
@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;
}
@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 / __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__))