Skip to content

Instantly share code, notes, and snippets.

View Klowner's full-sized avatar
🤡
total bozo

Mark Riedesel Klowner

🤡
total bozo
View GitHub Profile
@Klowner
Klowner / colortemplate.py
Created February 11, 2012 07:59
Color template engine, useful for building collections of CSS files
#!/usr/bin/env python
import re
import colorsys
class ColorFunc(object):
MATCH = re.compile('^([a-z]+)\(([^\)]+)')
def __init__(self, value):
self.func_name, self.func_args = self.MATCH.match(value).groups()
self.func_args = [x.strip() for x in filter(lambda x:x, self.func_args.split(','))]
@Klowner
Klowner / starting_strength_weight.py
Created March 26, 2012 20:03
A script to generate increments for weight training
#!/usr/bin/env python
from decimal import Decimal
def fiveround(x):
return Decimal(int(5 * round(float(x)/5)))
def simplify(x):
result = []
curr_x = x
items = map(lambda x:Decimal(x), [45,35,25,10,5,2.5])
@Klowner
Klowner / netcfg2ctl.py
Last active December 16, 2015 01:49
Simple Python script for converting netcfg configs over to netctl configs, probably doesn't fix all cases but it at least removes most of the grunt work
#!/usr/bin/env python3
# NOTICE if you use this on a directory, it'll function recursively, back up your files first!
import os
import sys
WORDLIST = [
'addr',
'address',
'address6',
@Klowner
Klowner / README.txt
Last active March 4, 2017 21:27
Per-user systemd service file for Bittorrent Sync (initially developed for use with the bittorrent-sync from AUR)
Instructions for ArchLinux
- Place [email protected] in /etc/systemd/system
Then for each user:
- Create a .sync directory in the user's home directory
- Create a config file (eg: /usr/bin/btsync --dump-sample-config > ~/.sync/btsync.json)
- Change options:
"storage_path" : "/home/<username>/.sync"
@Klowner
Klowner / MyFitnessPal_CaloricFix.README
Last active December 17, 2015 16:09
MyFitnessPal Android app patch to fix weekly caloric average graph to be consistent with iPhone app (factors in negative net daily values). Also adds display of daily caloric average on weekly report.
net_caloric_avg_fix.patch
ProgressReport->valuesUsedToCalculateAverageWeeklyNetCalories() is currently
calculated using all DiaryDay->netCalories() values which are >0, this causes incorrect
results on days where netCalories < 0 due to exercise.
This patch changes the condition to check each DiaryDay->caloriesConsumed() > 0 and
then appends DiaryDay->netCalories() to the array for calculating the average weekly net calories.
This behavior is consistent with the iPhone version, and reflects the note at the bottom of the
#!/bin/bash
echo "Starting"
while [[ $(curl --user-agent "klowner" -s https://play.google.com/store/devices | grep -o "\(Nexus\ 5\)") == '' ]]; do
NOW=$(date)
echo "Waiting $NOW"
sleep 60
done
mailsend -to [email protected] -cc [email protected] -from [email protected] -ssl -smtp smtp.gmail.com -port 465 -sub "Nexus 5 ALERT HIGH PRIORITY" \
@Klowner
Klowner / dabblet.css
Created June 6, 2014 22:12
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
body {
background: #f06;
background: linear-gradient(45deg, #f0f, #f02);
min-height: 100%;
overflow: hidden;
height: 100%;
}
// Read the Google Services Account pkcs12 key and return the fingerprint.
// This is not important for functionality, but will allow the user to
// cross-reference their uploaded fingerprint with the one displayed in the
// Google credentials management page.
function get_google_services_key_fingerprint () {
global $google_services_key_path;
$certs = array();
openssl_pkcs12_read(file_get_contents($google_services_key_path), $certs, "notasecret");
if (sizeof($certs) > 0) {
$output = $certs['cert'];
@Klowner
Klowner / Auto-Dave.py
Last active August 29, 2015 14:09 — forked from exit99/Auto-Dave
import time
import urllib2
import random
from datetime import datetime
def do_dave():
while 15 < datetime.now().hour < 18:
time.sleep(5)
urllib2.urlopen(random.choice(['http://slashdot.org/', 'http://facebook.com/']))
@Klowner
Klowner / xintoggle.py
Created January 6, 2015 04:10
dmenu interface for toggling xinput devices written in python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# a simple python script for toggline xinput devices via dmenu
# Written by Mark "Klowner" Riedesel 2015
#
# License: MIT yadda yadda, do what you want
import subprocess
import re