Skip to content

Instantly share code, notes, and snippets.

View etrepum's full-sized avatar
😎
Currently retired

Bob Ippolito etrepum

😎
Currently retired
View GitHub Profile

Keybase proof

I hereby claim:

  • I am etrepum on github.
  • I am etrepum (https://keybase.io/etrepum) on keybase.
  • I have a public key whose fingerprint is 0ADE DB65 BB14 2A89 3A2F 00A8 4F18 52C4 AD9C 3A69

To claim this, I am signing this object:

INPUT_TEXT="""\
Processor : Intel(R) Xeon(R) CPU E5-2420 v2 @ 2.20GHz (24 cores/threads)
Memory : 81877MB
Controller Slot : 0
BIOS : 3.0a 11/12/2013 3.1
IPMI FW rev : 2.20
@etrepum
etrepum / README.md
Last active August 29, 2015 14:02 — forked from mbostock/.block
-- version 3
import qualified Data.Set as S
import Data.List (partition)
import System.Environment (getArgs)
data LWG = LWG { _lion, _wolf, _goat :: {-# UNPACK #-} !Int }
deriving (Show, Ord, Eq)
lionEatGoat, lionEatWolf, wolfEatGoat :: LWG -> LWG
lionEatGoat (LWG l w g) = LWG (l - 1) (w + 1) (g - 1)
@etrepum
etrepum / QCFail.hs
Created June 7, 2014 20:16
QCFail.hs
import Data.Either (isLeft)
import Control.Exception (try, evaluate, SomeException)
import Test.QuickCheck (Property, quickCheck)
import Test.QuickCheck.Monadic (monadicIO, run, assert)
isFailure :: a -> IO Bool
isFailure = fmap isLeft . tryEval
where
tryEval :: a -> IO (Either SomeException a)
tryEval = try . evaluate
Welcome to Swift! Type :help for assistance.
1> func derp(a,b,c) { return a + b + c }
<REPL>:1:11: error: use of undeclared type 'a'
func derp(a,b,c) { return a + b + c }
^
<REPL>:1:13: error: use of undeclared type 'b'
func derp(a,b,c) { return a + b + c }
^
<REPL>:1:15: error: use of undeclared type 'c'
func derp(a,b,c) { return a + b + c }
{-# LANGUAGE OverloadedStrings, BangPatterns #-}
module Megahaskhal.Dictionary (
Dictionary,
addWord,
addAllWords,
findWord,
lookupIndex,
replicateM,
forM_,
@etrepum
etrepum / VimLexer.hs
Last active August 29, 2015 13:57
Vim log lexer, originally from http://www.drbunsen.org/vim-croquet/
import qualified Data.ByteString.Lazy.Char8 as LC
import qualified Data.List as DL
import qualified Data.List.Split as LS
import System.IO
-- | Reformat the Vim key log from stdin to stdout.
main :: IO ()
main = hSetEncoding stdout utf8 >>
LC.getContents >>= mapM_ putStrLn . process
>>> class Foo(object):
... pass
...
>>> def bar():
... class Bar(Foo):
... pass
...
>>> Foo.__subclasses__()
[]
>>> bar()
@etrepum
etrepum / badidea.py
Created March 15, 2014 15:57
Implementing CPython import as a function
## This is the implementation of the terrible hack
from sys import _getframe
from importlib import import_module
def import_(name, as_=None, globals_=None):
as_ = as_ or name.partition('.')[0]
globals_ = globals_ or _getframe(1).f_globals
globals_[as_] = import_module(name)
## This is what usage looks like: