Skip to content

Instantly share code, notes, and snippets.

@wladston
wladston / critic_to_tex.py
Created August 24, 2016 22:34
This converts <http://criticmarkup.com/> tags in a Markdown file to "equivalent" LaTex formatting.
#!/usr/bin/python
# This converts <http://criticmarkup.com/> tags in a Markdown file to
# "equivalent" LaTex formatting.
#
# By Wladston Filho <wlad@code.enegy>
import sys
import re
Verifying that +wladston is my blockchain ID. https://onename.com/wladston

Keybase proof

I hereby claim:

  • I am wladston on github.
  • I am wlad (https://keybase.io/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
wladston / pt.utf-8.spl
Last active August 29, 2015 14:25
Arquivo de correção ortográfica do VERO, v3.2
This file has been truncated, but you can view the full file.
@wladston
wladston / distcorr.py
Last active December 12, 2023 06:50
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/distcorr.py (gist aa3d19a12b74e9ab7941)
>>> a = [1,2,3,4,5]
@wladston
wladston / humanize_time.py
Created May 24, 2013 02:45
Python relative time
from datetime import datetime, timedelta
from dateutil import relativedelta
from datetime import datetime
from dateutil.tz 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.
/**
* 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
wladston / strip_database.py
Created February 6, 2013 20:59
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
wladston / dcmst.py
Created March 5, 2012 23:07
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