Skip to content

Instantly share code, notes, and snippets.

@teffalump
teffalump / pkg-size.sh
Last active August 29, 2015 14:03
Get arch pkg sizes
#!/usr/bin/zsh
#DEPRECATED
#get size of package(s) in arch (specify none for all)
pacman -Si "$@" | awk -F ": " '/^Name/ {name=$2} /^Installed Size/ {printf "%s %d KiB\n", name, $2}'
@teffalump
teffalump / show_passwords.sh
Created July 4, 2014 19:46
Toggle hide and show password fields in dwb (put in userscripts directory)
#!/usr/bin/zsh
# dwb: sP
echo -En "js var F,j,f,i;F=document.forms;for(j=0;j<F.length;++j){f=F[j];for(i=0;i<f.length;++i){if(f.elements[i].type.toLowerCase()=='password'){f.elements[i].type='text';f.elements[i].pwmarker='true'}else if(f.elements[i].pwmarker=='true'){f.elements[i].type='password'}else{}}};" > ${DWB_FIFO}
@teffalump
teffalump / alert_passwords.sh
Created July 4, 2014 19:47
Show hidden fields in alert box in dwb (put in userscripts directory)
#!/usr/bin/zsh
# dwb: sp
echo -En "js var F,j,f,i;var s=new Array();F=document.forms;for(j=0;j<F.length;++j){f=F[j];for(i=0;i<f.length;++i){if(f.elements[i].type.toLowerCase()=='password'){s.push(f.elements[i].value)}}}if(s.length>0){alert('Passwords in forms on this page:\n\n'+s.join('\n'))}else{alert('There are no passwords in forms on this page.')};" > ${DWB_FIFO}
@teffalump
teffalump / flatten.sh
Created January 2, 2015 20:42
moves files and directories in target directory into current directory
#!/usr/bin/bash
find "$1" -mindepth 1 -maxdepth 1 -print0 | xargs -0 mv -t .
#!/usr/bin/env python
#A little script to convert ID3 tags, in flac files, to flac tags in the current dir.
'''
Required:
mutagen
python-magic
'''
from mutagen.easyid3 import EasyID3
from mutagen.flac import FLAC
@teffalump
teffalump / itunes2xml.py
Created May 13, 2011 21:58
Extract xml file from itunes subscribe page. That is, get the rss podcast feed from some bullshit iTunes crap
#!/usr/bin/python3
#Extract xml file from iTunes subscribe bullshit
'''
That is, take a subscribe page
(e.g., http://itunes.apple.com/us/podcast/a-state-trance-official-podcast/id260190086)
and find the original xml playlist, so you don't have to have iShit or w/e.
'''
import sys,urllib.parse,urllib.request
import xml.parsers.expat
@teffalump
teffalump / split_bill.py
Created November 15, 2011 23:53
basically, you have a series of bills that people have paid -- the question is, who owes whom? this script calculates this, just needs all the receipts and the weights. the weights are, for example, if person x should only pay .5 equal split, weight = .5
#!/usr/bin/python3
#Split bills according to payment weights
#how much each person paid and weight of person
amts={}
while True:
label=input("\nperson: ")
if label == "":
break
else:
amt=0
@teffalump
teffalump / dzen.conky.ratpoison
Last active October 7, 2015 11:58
dzen + conky + ratpoison for toggleable status bar
===== .CONKYRC ======
out_to_x no
background no
cpu_avg_samples 2
net_avg_samples 2
no_buffers yes
out_to_console yes
out_to_stderr no
extra_newline no
update_interval 1.0
@teffalump
teffalump / tcplay_wrapper
Last active December 14, 2015 10:49
Took this from http://jasonwryan.com/blog/2013/01/10/truecrypt/. Change a little for non loopback and disk id.
#!/bin/bash
# manage truecrypt containers using tcplay
cryptdev="/dev/disk/by-id/usb-Ut165_USB2FlashStorage_19211326100935920031-0:0"
cryptmap=truecrypt
mountpt=/mnt/"$cryptmap"
# must be run as root
if [[ $EUID != 0 ]]; then
printf "%s\n" "You must be root to run this."
@teffalump
teffalump / extract_audio.sh
Last active September 2, 2016 17:21
Extract audio from file
#!/usr/bin/zsh
#Simple script to extract audio from a file.
FILE="$1"
FILENAME="${FILE%.*}"
EXTENSION=`ffmpeg -i "$1" 2>&1 | gawk '/Audio/ {print $4}' | tr -d '[:punct:]'`
ffmpeg -vn -i "$1" -acodec copy "$FILENAME"."$EXTENSION"