Skip to content

Instantly share code, notes, and snippets.

Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
>>> unicode
<type 'unicode'>
>>> def test():
... if type("x") == unicode:
... print "the if above fails only if the next two lines are present"
... if False:
... unicode = 23
...
>>> test()
I am a file at /tmp/${x} and the magic number is ${z}
@trehn
trehn / gist:2344589
Created April 9, 2012 16:31
btrfs intro
### Setup
uname -r # should be 3.2.x or later
aptitude install btrfs-tools
mkfs.btrfs /dev/sdb
mkdir /mnt/btrfs
mount /dev/sdb /mnt/btrfs
mount -t btrfs
df -h -t btrfs
btrfs filesystem df /mnt/btrfs
@trehn
trehn / damazon.py
Last active November 22, 2016 08:47 — forked from zakx/damazon.py
#!/usr/bin/python
# setup: pip install requests beautifulsoup4
from decimal import Decimal
import requests
from bs4 import BeautifulSoup
import sys
import getpass
class PrintProfiler(object):
"""
Will print profiling information.
Usage:
with PrintProfiler():
[code goes here]
"""
def __enter__(self):
@trehn
trehn / alphanumsort.py
Created June 26, 2014 15:38
This is basically another implementation of the "Alphanum Algorithm" from http://www.davekoelle.com/alphanum.html
#!/usr/bin/env python3
#
# This is basically another implementation of the "Alphanum Algorithm"
# from http://www.davekoelle.com/alphanum.html
#
# It accepts lines of strings on stdin and prints the sorted result to
# stdout.
#
import fileinput
from functools import cmp_to_key
#!/usr/bin/env python3
from datetime import datetime, timezone
from math import atan, atan2, degrees, floor, pi, radians, sin, sqrt
from skyfield.api import earth, JulianDate, now, sun
def earth_latlon(x, y, z, time):
"""
@trehn
trehn / pwget2vault.py
Created March 15, 2016 09:37
Helper to migrate from pwget to BundleWrap 2.3.1+
#!/usr/bin/env python
import base64
from os import getcwd
from os.path import exists, join
from subprocess import check_output, CalledProcessError
from sys import platform
def _ensure_secret(path):
secret_path = join(path, "pwget.secret")

Keybase proof

I hereby claim:

  • I am trehn on github.
  • I am trehn (https://keybase.io/trehn) on keybase.
  • I have a public key ASBNA3AH3RJZaCAPhrCrF3QNk6Ib4tF7RO2a_jX9IGacPwo

To claim this, I am signing this object: