Skip to content

Instantly share code, notes, and snippets.

@raidzero
raidzero / datemath.py
Created March 3, 2014 20:26
Determine if a date is within a given number of days or past (designed for OS X certificates)
#!/usr/bin/python
# defaults to 45 days if number of days is not given
# USAGE: datemath.py Aug 17 18:24:44 2014 GMT 45
import time, datetime, sys
NOW = datetime.datetime.now().strftime("%s")
END = time.mktime(datetime.datetime.strptime(sys.argv[1], "%b %d %X %Y GMT").timetuple())
if len(sys.argv) > 2:
WARN_DAYS = int(sys.argv[2])
@raidzero
raidzero / passgen.c
Created March 3, 2014 20:59
Password generator. Takes password requirements as arguments using getopt()
/*
* USAGE: passgen [-u UPPER] [-l LOWER] [-n NUMBER] -s [SPECIAL] -a LENGTH
* The approach is take the desired length, and set aside positions in the result
* string for the required characters, then fill in the other positions
* with random characters
*/
#include <stdio.h>
#include <sys/time.h>
#include <stdlib.h>
#include <unistd.h>
@raidzero
raidzero / pypiaud.py
Created March 5, 2014 23:14
D-bus Audacious Pidgin Status Daemon
#!/usr/bin/python
# Set pidgin status to currently playing audacious track with configurable display.
import re, dbus, time, sys
CONFIGFILE="~/.config/pypiaud.conf"
current_message = ''
def get_player_interface():
@raidzero
raidzero / localtime.py
Created March 5, 2014 23:25
Print local time in any timezone by GMT offset (hour & minute)
#!/usr/bin/python
import time, sys, re
OFFSET = sys.argv[1] # get the time offset in hours
OPERATION = OFFSET[0] # get the first character in OFFSET
if OPERATION != "+" and OPERATION != "-": # we only accept + and - as valid operations
print "usage: %s +3.5 (for UTC +3.5 hours)" % sys.argv[0]
sys.exit(1)
@raidzero
raidzero / lyrics.sh
Created March 5, 2014 23:28
pull lyrics from audacious playing track from lyrics.wikia.com
#!/bin/sh
# the regexes may need some work as song names and stuff get weirder :)
if [ -z "`ps -ef | grep audacious | grep -v grep`" ]; then
return # dont do anything if audacious isnt running
fi
clear
METADATA=`qdbus org.mpris.audacious /Player org.freedesktop.MediaPlayer.GetMetadata` # use dbus to read track data
@raidzero
raidzero / rdump.py
Created March 5, 2014 23:31
Print all strings from android resources.arsc file
#!/usr/bin/python
import sys
DEBUG = False
HEADER_ONLY = False
if len(sys.argv) >= 2:
FILENAME = sys.argv[1]
if len(sys.argv) >= 3:
@raidzero
raidzero / ctof.c
Created March 5, 2014 23:35
Celsius/Fahrenheit converter
/*
* takes a temperature (like 28.5 F or -32C) as stdin and prints
* converted value
* USAGE: echo "-205.3 F" | ./ctof
*/
#include <stdio.h>
#include <string.h>
int main(void)
{
@raidzero
raidzero / burniso.sh
Created March 5, 2014 23:44
Burn an iso to optical disc using cdrecord
#!/bin/sh
DEVICE="AUTO" # use the first detected drive. If this fails, hardcode a device, example 4,0,0
if [ ! -e "$1" ]; then
echo "File does not exist."
exit 1
fi
@raidzero
raidzero / maxmem.sh
Created March 5, 2014 23:49
Record highest amount of ram (in bytes) used at once on a system
#!/bin/bash
maxRAM=0
prevMax=0
while [ 1 == 1 ]; do
initRAM=`free | grep "Mem:" | awk '{print$3}'`
freeRAM=`free | grep "Mem:" | awk '{print$3}'`
if [ $freeRAM -ge $initRAM ]; then
prevMAX=$freeRAM
if [ $freeRAM -ge $maxRAM ]; then
@raidzero
raidzero / BFQuieter.java
Created April 12, 2014 03:36
Xposed module to stop playing sounds and music in the game Brave Frontier
package com.raidzero.xposed.bfquieter;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
/**