Skip to content

Instantly share code, notes, and snippets.

View rizumu's full-sized avatar
:octocat:

Thomas Schreiber rizumu

:octocat:
View GitHub Profile
npub1857yljp0gyd22gwpfqhhu9a86mn8p6eue79re0pe7cvvdwzvrwzshktw9u
@rizumu
rizumu / wavtosnd.py
Created December 2, 2023 07:07 — forked from tattlemuss/wavtosnd.py
A very simple and hacky Python3 script to convert 16-bit uncompressed WAV files to MPC-3000 .SND files.
#!/usr/bin/env python3
"""
A very simple and hacky Python3 script to convert 16-bit uncompressed WAV
files to MPC-3000 .SND files.
The output is modelled to copy the output of Wav2Snd
(http://www.mpc3000.com/wavsnd.htm) but this might be a bit more portable
to run on modern machines.
@rizumu
rizumu / sitecrawler.py
Created October 17, 2017 02:02
A simplistic website crawler that extracts links recursively using breath first traversal
#!/usr/bin/env python
# Assumes the BeautifulSoup4 and Requests libraries are installed.
# pip install bs4 requests
import requests
from bs4 import BeautifulSoup
from requests.compat import urljoin
width = models.PositiveIntegerField(_("height"), db_index=True)
height = models.PositiveIntegerField(_("width"), db_index=True)
def is_horizontal(self):
if float(self.height) / self.width <= 0.7:
return True
def is_vertical(self):
if float(self.height) / self.width > 0.7:
return True
import os
import envdir
from pathlib import Path
from celery import Celery
from django.conf import settings
from configurations import importer
from datetime import timedelta
from time import sleep
from celery.task import task
from django.core.management.base import BaseCommand, CommandError
from django.utils import timezone
@task
def add(x, y):
@rizumu
rizumu / pre-commit
Created July 8, 2013 15:21
pep8 git pre-commit hook
#!/bin/sh
# Auto-check for pep8 so I don't check in bad code
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -e '\.py$')
if [ -n "$FILES" ]; then
flake8 --max-line-length=100 $FILES
fi
""" Python Command and Character list
(from Learn Python the Hardway by Zed Shaw)
expanded from Lesson 22
"""
#Character / Command What it's called What it does example example2
pydoc <something> #pydoc gives you the manual page for something you want to know about in python pydoc sys
help() #help function use when running python to find help on an object
print() #print function prints to the console whatever is next print(“Hello World!”) print(1 + 2)
@rizumu
rizumu / university_locator.py
Created October 22, 2011 16:30
university_locator.py
from BeautifulSoup import BeautifulSoup
from urlparse import urlparse
import re
import urllib2
if __name__ == "__main__":
""" driver code """
# extract html
url = 'http://www.utexas.edu/world/univ/alpha/'
usock = urllib2.urlopen(url)
@rizumu
rizumu / fab.py
Created September 21, 2011 23:50
install irssi
def install_irssi():
sudo("apt-get install -y screen irssi bitlbee libcrypt-dh-perl libcrypt-openssl-bignum-perl libcrypt-blowfish-perl")
# libtime-duration-perl libnotify-bin irssi-plugin-otr bitlbee-plugin-otr")
server_ip = env.host_string.split(":")[0]
local("rsync --links -e 'ssh -p {0}' -avzp ~/.irssi/ {1}@{2}:{3}.irssi/ \
--exclude='*.log'".format(settings.SSH_PORT, settings.DEPLOY_USERNAME, server_ip, settings.DEPLOY_HOME))
sed("{0}.irssi/config".format(settings.DEPLOY_HOME), "BITLBEE_PASSWORD", os.environ["BITLBEE_PASSWORD"])
with fab_settings(warn_only=True):
put("~/.screenrc", os.path.join(settings.DEPLOY_HOME, ".screenrc"))
put("~/dotfiles/bitlbee.conf", "/etc/bitlbee/bitlbee.conf", use_sudo=True)