Skip to content

Instantly share code, notes, and snippets.

View keybase.md

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:

@trehn
trehn / pwget2vault.py
Created Mar 15, 2016
Helper to migrate from pwget to BundleWrap 2.3.1+
View pwget2vault.py
#!/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")
View sun_latlon.py
#!/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 / alphanumsort.py
Created Jun 26, 2014
This is basically another implementation of the "Alphanum Algorithm" from http://www.davekoelle.com/alphanum.html
View alphanumsort.py
#!/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
View gist:d27b30ee0e8de0095e1c
class PrintProfiler(object):
"""
Will print profiling information.
Usage:
with PrintProfiler():
[code goes here]
"""
def __enter__(self):
View damazon.py
#!/usr/bin/python
# setup: pip install requests beautifulsoup4
from decimal import Decimal
import requests
from bs4 import BeautifulSoup
import sys
import getpass
View gist:2344589
### 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
View foobar.newtxt
I am a file at /tmp/${x} and the magic number is ${z}
View gist:958938
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()