Skip to content

Instantly share code, notes, and snippets.

from __future__ import unicode_literals, print_function, generators
import doctest
# TODO:
# - 'do' notation
# - Py3 type annotations
# - More monadic types
class FormattedException(Exception):
def __init__(self, **kwargs):
@hcarvalhoalves
hcarvalhoalves / curry.py
Last active August 29, 2015 14:16
Currying decorator.
from functools import partial, wraps
import doctest
def curry(f):
"""
Allow partial evaluation of function (currying).
Returns a `functools.partial` until all arguments are specified:
>>> f = curry(lambda a,b: a + b)
export interface MonadI<T> {
lift<U>(transform: (v: T) => U): MonadI<U>;
bind<U>(transform: (v: T) => MonadI<U>): MonadI<U>;
}
export interface MaybeI<T> extends MonadI<T> {
isEmpty: boolean;
toString(): string;
get(): any;
}
Kerbal Space Program - 0.25.0.642 (OSXPlayer) Steam
OS: Mac OS X 10.10.0
CPU: Intel(R) Core(TM)2 Duo CPU P8800 @ 2.66GHz (2)
RAM: 8192
GPU: NVIDIA GeForce 320M OpenGL Engine (256MB)
SM: 30 (OpenGL 2.1 [2.1 NVIDIA-10.0.19 310.90.10.05b12])
RT Formats: ARGB32, Depth, ARGBHalf, RGB565, ARGB4444, Default, DefaultHDR, ARGBFloat, RGFloat, RGHalf, RFloat, RHalf, R8
import string
ALPHABET = 'ABCDEGHKLPQRSTUVWXYZ' + '23456789'
ALPHABET_REVERSE = dict((c, i) for (i, c) in enumerate(ALPHABET))
BASE = len(ALPHABET)
START_FROM = 1
def encode(n):
n = n * START_FROM
import string
ALPHABET = 'ABCDEGHKLPQRSTUVWXYZ' + '23456789'
ALPHABET_REVERSE = dict((c, i) for (i, c) in enumerate(ALPHABET))
BASE = len(ALPHABET)
START_FROM = 1
def encode(n):
n = n * START_FROM
@hcarvalhoalves
hcarvalhoalves / gist:2d4529d1502db87131a6
Created May 6, 2014 23:24
geoalchemy Geometry wrapper for simple "lat,lon" fields
from sqlalchemy import types
from sqlalchemy.sql.expression import func, text
from geoalchemy2 import functions as geofunc
from geoalchemy2.elements import WKTElement
class Coordinate(types.TypeDecorator):
impl = Geometry
def process_bind_param(self, value, dialect):
import System.Environment (getArgs, getProgName)
import System.Exit (exitFailure, exitSuccess)
import System.IO
import Network
import Control.Concurrent
import Text.Read
echoCommand :: Handle -> [String] -> IO ()
echoCommand handle cmd = do
hPutStrLn handle (unwords $ tail cmd)
$ tail -f /var/log/celery/live-celeryd.log
[2014-01-09 17:24:59,335: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-2288.xml
[2014-01-09 17:24:59,339: INFO/MainProcess] Generating OLX feed for negociaoimoveis.com.br...
[2014-01-09 17:25:00,207: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-2788.xml
[2014-01-09 17:25:00,210: INFO/MainProcess] Generating OLX feed for insigniaci.com.br...
[2014-01-09 17:25:02,054: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-3418.xml
[2014-01-09 17:25:02,057: INFO/MainProcess] Generating OLX feed for imoveisbaixada.com.br...
[2014-01-09 17:25:03,385: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-4174.xml
[2014-01-09 17:25:03,389: INFO/MainProcess] Generating OLX feed for mundialimoveis.net.br...
[2014-01-09 17:25:11,698: INFO/MainProcess] Saved OLX feed at /mnt/local/live/media/cache/feeds/olx-3354.xml
>>> from colibri.feeds.tasks import generate_olx_feed_task
>>> generate_olx_feed_task()
[09/Jan/2014 16:20:22] INFO Generating OLX feed for angelaalvesimoveis.com.br...
[09/Jan/2014 16:20:27] INFO Saved OLX feed at /Users/hcarvalhoalves/Projetos/colibri/media/cache/feeds/4086.xml
[09/Jan/2014 16:20:27] INFO Generating OLX feed for brewimoveis.com.br...
[09/Jan/2014 16:20:30] INFO Saved OLX feed at /Users/hcarvalhoalves/Projetos/colibri/media/cache/feeds/2944.xml
[09/Jan/2014 16:20:30] INFO Generating OLX feed for bomimoveis.com.br...
[09/Jan/2014 16:20:42] INFO Saved OLX feed at /Users/hcarvalhoalves/Projetos/colibri/media/cache/feeds/3409.xml
[09/Jan/2014 16:20:42] INFO Generating OLX feed for flavioelecyimoveis.com.br...
[09/Jan/2014 16:20:45] INFO Saved OLX feed at /Users/hcarvalhoalves/Projetos/colibri/media/cache/feeds/1446.xml