Skip to content

Instantly share code, notes, and snippets.

View winny-'s full-sized avatar
👋
***status goes here***

Winston (Winny) Weinert winny-

👋
***status goes here***
View GitHub Profile
@winny-
winny- / retrieve_notes.py
Created July 19, 2013 23:12
Because Notes.app blew up on me, and here is the solution. :)
#!/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 December 20, 2015 00:39
Because using a Bukkit plugin just to edit a NBT file is ridiculous! Tested on 1.5.x, see /setworldspawn on recent Minecraft releases.
#!/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 August 20, 2013 19:29
Useful to see what signals your terminal emulator sends to its child "shell" process. It's poorly written and that's ok :).
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 December 22, 2015 19:19
Implementation of Sieve of Eratosthenes in Python
# 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 December 22, 2015 19:19
Fizz Buzz iterator python class and equivalent generator function.
# 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 November 30, 2023 00:27
Force IPv4 or IPv6 in applications such as Lynx
/*
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 August 29, 2015 13:56
Simple python tool for creating and checking digests. Useful on old Macs that don't have shasum(1), but have python with hashlib.
#!/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):
#!/usr/bin/env php
<?php
// Config:
// [minecraft_users]
// env.host awesomeserver.com
// env.port 25566
error_reporting(E_ERROR | E_PARSE);
$host = getenv('host');
#!/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 August 29, 2015 13:56
Rough and MIME-ignorant attempt at processing my old Lavabit emails.
#!/usr/bin/env python
import collections
import os
def make_email_dict(email):
"""Make an email dictionary.