Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
***status goes here***

Winston (Winny) Weinert winny-

👋
***status goes here***
View GitHub Profile
@winny-
winny- / retrieve_notes.py
Created Jul 19, 2013
Because Notes.app blew up on me, and here is the solution. :)
View retrieve_notes.py
#!/usr/bin/env python
#
# Simple script to extract your notes from Notes.app's sqlite3 database. It
# places the HTML files in the current working directory. The database store
# should be located at:
#
# ~/Library/Containers/com.apple.Notes/Data/Library/Notes/NotesV1.storedata
#
# This file is released in the public domain.
@winny-
winny- / mc_change_spawn.py
Last active Dec 20, 2015
Because using a Bukkit plugin just to edit a NBT file is ridiculous! Tested on 1.5.x, see /setworldspawn on recent Minecraft releases.
View mc_change_spawn.py
#!/usr/bin/env python
#
# This file is placed in the public domain.
import struct
coordinate_name_map = {'x': 'SpawnX', 'X': 'SpawnX', 'SpawnX': 'SpawnX',
'y': 'SpawnY', 'Y': 'SpawnY', 'SpawnY': 'SpawnY',
@winny-
winny- / trap.py
Created Aug 20, 2013
Useful to see what signals your terminal emulator sends to its child "shell" process. It's poorly written and that's ok :).
View trap.py
import signal
import os
import psutil
def sighandler(signum, frame):
with open('/tmp/trapped', 'a') as f:
pid = os.getpid()
parent = psutil.Process(pid).parent
f.write('PID {3} captured signal {0}, parent {1} ({2}).\n'.format(signum,parent.name, parent.pid,pid))
@winny-
winny- / primes.py
Last active Dec 22, 2015
Implementation of Sieve of Eratosthenes in Python
View primes.py
# This file is in the public domain.
class MyNumber(int):
def __init__(self, x=0, base=10):
super(int, self).__init__()
self.marked = False
@winny-
winny- / fizzbuzz.py
Last active Dec 22, 2015
Fizz Buzz iterator python class and equivalent generator function.
View fizzbuzz.py
# This file is in the public domain.
class FizzBuzz(object):
def __init__(self, low, high=None):
if high is None:
self.high = low
self.current = 1
else:
@winny-
winny- / force-inet4-or-inet6.c
Last active Jan 30, 2019
Force IPv4 or IPv6 in applications such as Lynx
View force-inet4-or-inet6.c
/*
force-inet4-or-inet6.c - hack to force applications to use IPv4 or IPv6 exclusively
compilation: cc -fPIC -shared -DUSE_INET4 -o force-inet4.so force-inet4-or-inet6.c
cc -fPIC -shared -DUSE_INET6 -o force-inet6.so force-inet4-or-inet6.c
usage: LD_PRELOAD=/path/to/library.so program args ...
This file is in the public domain.
*/
@winny-
winny- / checksum.py
Last active Aug 29, 2015
Simple python tool for creating and checking digests. Useful on old Macs that don't have shasum(1), but have python with hashlib.
View checksum.py
#!/usr/bin/env python
# Makes me mad that I had to write this. Damn you mac os x 10.5.8.
# I, Winston Weinert, hereby put this file in the public domain.
import hashlib
class Checksum(object):
View minecraft_users
#!/usr/bin/env php
<?php
// Config:
// [minecraft_users]
// env.host awesomeserver.com
// env.port 25566
error_reporting(E_ERROR | E_PARSE);
$host = getenv('host');
View backup.sh
#!/bin/sh
now() {
date '+%F %T'
}
Tarsnap='/usr/local/bin/tarsnap'
Hostname="$(hostname -s)"
BackupTarget="$2"
JobName="$Hostname-$1"
BackupDate="$(date +%F)"
BackupName="$JobName-$BackupDate"
@winny-
winny- / emailproc.py
Last active Aug 29, 2015
Rough and MIME-ignorant attempt at processing my old Lavabit emails.
View emailproc.py
#!/usr/bin/env python
import collections
import os
def make_email_dict(email):
"""Make an email dictionary.