Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env python
from enum import Enum
from numbers import Number
from operator import add, sub, mul, truediv, mod
class Operation(Enum):
PLUS = (add, 6)
MINUS = (sub, 6)
MULT = (mul, 7)
#!/usr/bin/env py.test
from collections import deque, defaultdict
class Friends:
def __init__(self):
self.graph = defaultdict(set)
def make_friend(self, name1, name2):
self.graph[name1].add(name2)
import click
@click.group()
def pew():
pass
mkvenv_command = lambda f: pew.command()(
click.option('--python', '-p', default='python')(
click.option('-i', multiple=True)(f)))
from __future__ import print_function
from numpy.random import binomial
from random import sample
from functools import partial
from operator import add, itemgetter
from itertools import takewhile
# Problem:
# You are given 10 opaque bags containing large numbers of red balls
import Paths_hdoit (version)
import Data.Version (showVersion)
import Options.Applicative
data Arguments = Arguments
{ version :: Bool,
argCommand :: Command
} deriving Show
data Command = Add (Maybe String) | Base deriving Show
import Data.Functor.Identity (runIdentity)
import Control.Monad (replicateM)
import Control.Monad.State.Lazy (state, evalState)
getInts :: IO [Int]
getInts = fmap (map read . words) getLine
f = do
n:q:_ <- getInts
els <- replicateM n getInts

Keybase proof

I hereby claim:

  • I am berdario on github.
  • I am berdario (https://keybase.io/berdario) on keybase.
  • I have a public key whose fingerprint is 3F8D 5351 8012 716C 4EEF 7DF6 7B49 8306 B3BF 75A0

To claim this, I am signing this object:

import scala.language.higherKinds
import scala.collection.generic.CanBuildFrom
import scala.collection.GenTraversableOnce
def map[A, This[A] <: Traversable[A], B, That](o: This[A])(f: (A) => B)(implicit bf: CanBuildFrom[This[A], B, That]): That = {
(o.foldLeft (bf.apply()) ({(a, b) => a += f(b)})).result()
}
def filter[A, This[A] <: Traversable[A]](o: This[A])(f: (A) => Boolean)(implicit bf: CanBuildFrom[This[A], A, This[A]]): This[A] = {
(o.foldLeft (bf.apply()) ({(a, b) => if (f(b)) a += b else a})).result()
dpkg-source: error: cannot represent change to .tox/py33/include/python3.3m:
dpkg-source: error: new version is symlink to /usr/include/python3.3m
dpkg-source: error: old version is nonexistent
dpkg-source: error: cannot represent change to .tox/py33/lib/python3.3/tempfile.py:
dpkg-source: error: new version is symlink to /usr/lib/python3.3/tempfile.py
dpkg-source: error: old version is nonexistent
dpkg-source: error: cannot represent change to .tox/py33/lib/python3.3/posixpath.py:
dpkg-source: error: new version is symlink to /usr/lib/python3.3/posixpath.py
dpkg-source: error: old version is nonexistent
dpkg-source: error: cannot represent change to .tox/py33/lib/python3.3/tokenize.py:
@berdario
berdario / dummyhttp.py
Created December 7, 2014 21:37
3to2 porting of the 2to3 porting of the 3to2 porting of https://gist.github.com/berdario/39313b94cd08ebe6b3fb portingception!
#! /usr/bin/env python
from __future__ import with_statement
import sys
import os
import locale
from collections import defaultdict
from socket import socket, AF_INET, SOCK_STREAM
from urlparse import urlparse