Skip to content

Instantly share code, notes, and snippets.

@raidzero
raidzero / launchOrRaiseTerm.sh
Created March 20, 2015 17:29
Launch a new terminal or just find one and bring it to the foreground - meant for a keyboard shortcut or WM menu option
#!/bin/sh
HOSTNAME=`hostname`
# command to launch terminal
TERM_CMD="xfce4-terminal"
# what my terminal window name will always start with
NAME_PREFIX="#!"
@raidzero
raidzero / panalyze.py
Last active August 29, 2015 14:17
python script to analyze directory and print number of lines found in each type of file
#!/usr/bin/python2
import os, sys
# list comprehension to stick a dot onto each given extension
exts = ['.' + ext for ext in sys.argv[2:]]
# dictionaries that hold the count data
fileCount = dict(); lineCount = dict()
# functin to count lines in a file
@raidzero
raidzero / git_find.sh
Created March 2, 2015 22:56
Simple script to find occurrences of a git commit in all branches
#!/bin/sh
if [ -z "$1" ]; then
bname=`basename $0`
echo "Usage: $bname SHA"
exit 1
fi
PATCH_ID=`git show -p $1 | git patch-id | awk '{print$1}'`
@raidzero
raidzero / divvy.sh
Last active February 15, 2023 09:35
OS X Divvy emulation for EWMH-compliant (Unix-like) Window Managers
#!/bin/sh
DEST="$1"
if [ -z "$DEST" ]; then
echo "USAGE: $0 [location]"
echo -e "\nsupported locations: "
echo -e "\thalf-left, half-right"
echo -e "\tthird-left, third-middle, third-right"
echo -e "\tquarter-top-left, quarter-rop-right, quarter-bottom-left, quarter-bottom-right"
@raidzero
raidzero / split.c
Created October 21, 2014 19:02
Split X into N uniformly-distributed pieces (C)
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
int* split(int n, int numPieces);
int randInt(int min, int max);
int sumList(int* list, int size);
void printList(int* list, int size);
void seedrand();
@raidzero
raidzero / Split.java
Created October 21, 2014 18:34
Split X into N uniformly-distributed pieces (java)
import java.util.ArrayList;
import java.util.Random;
import java.lang.Math;
public class Split {
private static Random rand = new Random();
public static void main(String[] args) {
ArrayList<Integer> list = splitNum(Integer.valueOf(args[0]), Integer.valueOf(args[1]));
@raidzero
raidzero / split.py
Created October 21, 2014 17:09
Split N into X uniformly-distributed pieces
#!/usr/bin/python2.7
import sys
from random import randrange
def split(n, numPieces):
rtn = []
for i in range(numPieces):
# get a good starting position to deviate from
@raidzero
raidzero / passman.sh
Last active August 29, 2015 14:05
Rudimentary password manager
#!/bin/sh
FILE=~/Dropbox/creds.txt
DISPPASS="$1"
read -s -p "Please enter master passphrase: " PASSPHRASE
printf "\n"
# decrypt to /tmp
[ -f /tmp/creds.txt ] && rm /tmp/creds.txt
echo "$PASSPHRASE" | gpg --batch -q -o /tmp/creds.txt --passphrase-fd 0 --cipher-algo AES256 --decrypt "$FILE" &> /dev/null
@raidzero
raidzero / recordWindow.sh
Created April 21, 2014 02:48
Record a window ('s size) with ffmpeg
#!/bin/sh
# do we have the necessary software?
FFMPEG=`which ffmpeg`
XWININFO=`which xwininfo`
XDGOPEN=`which xdg-open`
if [ -z "$FFMPEG" ]; then
echo "ffmpeg not available"
exit 1
@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;
/**