This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am andreacrotti on github. | |
* I am andreacrotti (https://keybase.io/andreacrotti) on keybase. | |
* I have a public key ASAcH7o-UqMo87r8tJHWsJDJRgVb2tmovG-PLgdLZQ8NWAo | |
To claim this, I am signing this object: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn divides? | |
[n d] | |
(= 0 (mod n d))) | |
(defn remove-factor | |
[n d] | |
(if (divides? n d) | |
(remove-factor (/ n d) d) | |
n)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import atexit | |
import csv | |
import json | |
from collections import namedtuple | |
from django.test.client import Client | |
Line = namedtuple('Line', ['method', 'args', 'kwargs', 'status_code']) | |
class LoggingClient(Client): | |
df = [['method', 'args', 'kwargs', 'status_code']] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_last_tag(repo): | |
"""Return last tag object ordering by date of the commit | |
""" | |
try: | |
return sorted(repo.tags, key=lambda t: t.commit.authored_date, reverse=True)[0] | |
except IndexError: | |
raise NoTags("There are no tags in this repository, add a first valid one with `git tag 0.0.1`") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Use functools to declare the specification of inputs and validate | |
them on the fly with decorator. | |
It also only currently works with keyword arguments only, just to keep | |
it simpler (and because enforcing them might be a good idea anyway). | |
""" | |
import functools | |
import voluptuous as V |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Fun with toolz, wirting a decorator that merge dictionaries yielded from a genrator into a single result. | |
""" | |
import toolz | |
def merge_dicts(func): | |
"""Consume a generator that would yield dictionaries and merge them | |
all together |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import inspect | |
from importlib import import_module | |
from sqlalchemy import create_engine | |
from sqlalchemy.schema import CreateTable | |
from skim.slxmodels.meta import BaseModel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import multiprocessing | |
import threading | |
from pylibmc.test import make_test_client | |
import random | |
NUM_THREADS = 4 | |
NUM_PROCS = 4 | |
NUM_SETS = 1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# draw things out of a hat | |
from pprint import pprint | |
import re | |
import random | |
NAME_REGEXP = re.compile("(?P<name>\w+) (?P<last>\w+) <(?P<mail>.*?)>") | |
NAMES = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import play.api._ | |
import play.api.mvc._ | |
object Application extends Controller { | |
def is_cube(a: Int): Boolean = { | |
(1 to (a / 2)).exists(x => x * x * x == a) | |
} |
NewerOlder