Skip to content

Instantly share code, notes, and snippets.

View bryant's full-sized avatar

bryant bryant

  • New York; Berlin
View GitHub Profile
\documentclass [11pt] {article}
\usepackage [margin=0.5in, letterpaper] {geometry}
\usepackage {lipsum}
\usepackage {tabularx}
\usepackage {color}
\newcommand {\header} [1] {{\color {YaleBlue} #1}}
\definecolor {YaleBlue} {RGB} {54, 95, 145} %{15, 77, 146}
deb http://us.archive.ubuntu.com/ubuntu/ precise main restricted multiverse universe
deb http://security.ubuntu.com/ubuntu precise-updates precise-security main restricted multiverse universe
/dev/sda:
Model=TOSHIBA MK8032GAX, FwRev=AB311E, SerialNo=65F20105A
Config={ Fixed }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=68
BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=156301488
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: sdma0 sdma1 sdma2 mdma0 mdma1 mdma2
@bryant
bryant / translate
Created August 5, 2012 02:19
Quickie CLI interface to Google Translate.
#!/bin/bash
USER_AGENT="Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Firefox/17.0"
translate () {
slang="$1"
tlang="$2"
shift
shift
phrase="$@"
@bryant
bryant / dpkg.min
Last active December 11, 2015 12:48
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================-==========================-============-======================================================================
ii adduser 3.113+nmu1ubuntu1 all add and remove users and groups
ii apt 0.9.7.5ubuntu5.2 amd64 commandline package manager
ii apt-utils 0.9.7.5ubuntu5.2 amd64 package managment related utility programs
ii aptitude 0.6.8.1-2ubuntu1 amd64 terminal-based package manager
ii aptitude-common 0.6.8.1-2ubuntu1 all architecture indepedent files for the aptitude package manager
@bryant
bryant / camel2underscore.py
Last active September 12, 2016 08:59
CamelCase -> camel_case
import re
_endpiecere = re.compile(r"[A-Z]+$")
_camelre = re.compile(r"([A-Z]+)(?=[0-9a-z])")
def camel2underscore(camel):
camel = _endpiecere.sub(lambda m: "_" + m.group(0).lower(), camel)
def insert(match):
m = match.group(0).lower()
return "_" + (m if len(m) == 1 else m[:-1] + "_" + m[-1])
@bryant
bryant / binexp.hs
Last active December 26, 2015 23:39
binary exponentiation. haskell.
import System.Environment (getArgs)
myPow x y
| y < 0 = error "neg."
| y == 0 = 1
| otherwise = pow' y x
where
pow' kth cur
| kth == 1 = cur
| odd kth = cur * pow' (kth `quot` 2) (cur * cur)
@bryant
bryant / mch2pgm.hs
Last active December 27, 2015 09:39
converts raw grayscale values into pgm format
import Data.List (intercalate)
import System.Environment (getArgs)
main = do
raw <- readFile =<< head `fmap` getArgs
putStrLn $ "P2 160 120 256\n" ++ rawToPGM raw
where
chunk width [] = []
chunk width xs = a : chunk width b
where (a, b) = splitAt width xs
data Genotype = AA | Aa | Xaa deriving Show
--data Poss = Poss Double Double Double deriving Show
type Poss = (Double, Double, Double)
mate :: Genotype -> Genotype -> Poss
mate AA AA = (1, 0, 0)
mate AA Aa = (0.5, 0.5, 0)
mate AA Xaa = (0, 1, 0)
mate Aa Aa = (0.25, 0.5, 0.25)
mate Aa Xaa = (0, 0.5, 0.5)
0000000000000000 <main>:
#include <memory>
#include <vector>
int main() { std::unique_ptr<int> p(new int(89)); return *p; }
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 53 push %rbx
5: 48 83 ec 18 sub $0x18,%rsp
9: bf 04 00 00 00 mov $0x4,%edi