Skip to content

Instantly share code, notes, and snippets.

wladston /
Created Aug 24, 2016
This converts <> tags in a Markdown file to "equivalent" LaTex formatting.
# This converts <> tags in a Markdown file to
# "equivalent" LaTex formatting.
# By Wladston Filho <wlad@code.enegy>
import sys
import re
View gist:a5ac098091439fc03796cb0ddc363162
Verifying that +wladston is my blockchain ID.

Keybase proof

I hereby claim:

  • I am wladston on github.
  • I am wlad ( on keybase.
  • I have a public key whose fingerprint is F19A E5A4 CB44 5708 0258 104B 57C2 4F99 7623 27EE

To claim this, I am signing this object:

wladston / pt.utf-8.spl
Last active Aug 29, 2015
Arquivo de correção ortográfica do VERO, v3.2
View pt.utf-8.spl
This file has been truncated, but you can view the full file.
wladston /
Last active Dec 25, 2020
Distance correlation with p-value
from scipy.spatial.distance import pdist, squareform
import numpy as np
import copy
def distcorr(Xval, Yval, pval=True, nruns=500):
""" Compute the distance correlation function, returning the p-value.
Based on Satra/ (gist aa3d19a12b74e9ab7941)
>>> a = [1,2,3,4,5]
wladston /
Created May 24, 2013
Python relative time
from datetime import datetime, timedelta
from dateutil import relativedelta
from datetime import datetime
from import tzutc, tzlocal
def humanize_time(time):
get a datetime object and return a relative time string like
"one hour ago", "yesterday", "3 months ago", "just now", etc.
View custom-submit.js
* Custom submit directive that will only submit when all the validation has passed
* for all the fields. This extends on the ng-submit directive provided by AngularJS.
* This directive will also remove the 'pristine' flag from all the fields when
* hitting submit, allowing the form to display no errors until the submit button
* is clicked/enter is pressed.
* The variable 'app' is the instance of a module.
* E.g. var app = angular.module('my-app', []);
wladston /
Created Feb 6, 2013
Strip all strings that exist in a MongoDB database. It will work recursively to strip **ALL** your strings. Binary data won't be affected.
# -*- coding: utf-8; -*-
from bson import Binary
from pymongo import Connection
from pymongo.database import Database
db = Database(Connection(), "yourdb")
def _clean_dict(x):
dic = {}
wladston /
Created Mar 5, 2012
Degree constrained minimum spanning tree with networkx
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
# This is the framework for graphs we use on this work
import networkx as nx
# Tool to determine wether elements are on the same set
from networkx.utils import UnionFind
# We need this in python to "clone" objects
import copy