Skip to content

Instantly share code, notes, and snippets.

class Icu4c < Formula
desc "C/C++ and Java libraries for Unicode and globalization"
homepage "http://site.icu-project.org/"
url "https://ssl.icu-project.org/files/icu4c/58.2/icu4c-58_2-src.tgz"
mirror "https://fossies.org/linux/misc/icu4c-58_2-src.tgz"
mirror "https://downloads.sourceforge.net/project/icu/ICU4C/58.2/icu4c-58_2-src.tgz"
version "58.2"
sha256 "2b0a4410153a9b20de0e20c7d8b66049a72aef244b53683d0d7521371683da0c"
head "https://ssl.icu-project.org/repos/icu/trunk/icu4c/", :using => :svn
Verifying that "pauloalem.id" is my Blockstack ID. https://onename.com/pauloalem

Keybase proof

I hereby claim:

  • I am pauloalem on github.
  • I am pauloalem (https://keybase.io/pauloalem) on keybase.
  • I have a public key ASAbj_nL3q-sAtZFlZJh1BrQVabTyW96HyScZCis4fhHxQo

To claim this, I am signing this object:

@pauloalem
pauloalem / tornado_threads.py
Created October 27, 2016 16:49
Example of how to offload a blocking task in tornado using the threading module in python3
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, RequestHandler
from tornado.gen import coroutine, Task
import threading
from time import sleep
def do_block(callback, args):
def _callback():
// db.broken.drop();
var obj = {routes: []},
point = [-24.123, 24.213];
for(var i=0; i < 1696; i++) {
obj.routes.push({points: [point]});
}
db.broken.insert(obj);
db.broken.find({"routes.points.1": {$exists: 1}});
from collections import namedtuple
Point = namedtuple("Point", "x y")
def euclidean_distance(p1, p2):
return pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2)
def near(points, k, n):
def keyfunc(point):
return euclidean_distance(k, point)
$ time pypy sim.py
pypy sim.py 5992,70s user 51,08s system 356% cpu 28:16,16 total
$ time python sim.py
python sim.py 47894,93s user 145,11s system 354% cpu 3:45:33,97 total
@pauloalem
pauloalem / blocking_tornado.py
Last active March 28, 2016 23:34
Example of how to offload a blocking task to a threadpool to avoid locking tornado using tornado.gen and multiprocessing
# -*- coding: utf-8
from time import sleep, time
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
from tornado import gen
pool = ThreadPool(10)
@pauloalem
pauloalem / python json FloatEncoder
Created August 15, 2013 21:14
Custom python encoder for handling NaN, Infinity and -Infinity, which are non-valid JSON values and can possibly screw your json parser
import json
class FloatEncoder(json.JSONEncoder):
def __init__(self, nan_str="null", **kwargs):
super(FloatEncoder, self).__init__(**kwargs)
self.nan_str = nan_str
def iterencode(self, o, _one_shot=False):
"""Encode the given object and yield each string
@pauloalem
pauloalem / gist:5412570
Last active December 16, 2015 09:19
calculo e formatando "pace" em min/km
def ritmo(segs, ms):
kms = ms / 1000
mins = segs / 60
horas = mins / 60
ritmo_seg = segs / kms / 60
pace_min = ritmo_seg - ritmo_seg % 1
pace_seg = ritmo_seg % 1 * 0.6 * 100
pace_seg = pace_seg - pace_seg % 1;
return str(pace_min) + ":" + str(pace_seg) + "min/km";