Skip to content

Instantly share code, notes, and snippets.

berdario

Block or report user

Report or block berdario

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View calc.py
#! /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)
View friends.py
#!/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)
View helloclick.py
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)))
View buckets.py
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
View Main.hs
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
View ioexample.hs
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
View keybase.md

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:

View fold.scala
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()
View error.log
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 Dec 7, 2014
3to2 porting of the 2to3 porting of the 3to2 porting of https://gist.github.com/berdario/39313b94cd08ebe6b3fb portingception!
View dummyhttp.py
#! /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
You can’t perform that action at this time.