Skip to content

Instantly share code, notes, and snippets.

@teffalump
teffalump / flatten.sh
Created Jan 2, 2015
moves files and directories in target directory into current directory
View flatten.sh
#!/usr/bin/bash
find "$1" -mindepth 1 -maxdepth 1 -print0 | xargs -0 mv -t .
@teffalump
teffalump / alert_passwords.sh
Created Jul 4, 2014
Show hidden fields in alert box in dwb (put in userscripts directory)
View alert_passwords.sh
#!/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 / show_passwords.sh
Created Jul 4, 2014
Toggle hide and show password fields in dwb (put in userscripts directory)
View show_passwords.sh
#!/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 / pkg-size.sh
Last active Aug 29, 2015
Get arch pkg sizes
View pkg-size.sh
#!/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 / extract_audio.sh
Last active Sep 2, 2016
Extract audio from file
View extract_audio.sh
#!/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"
@teffalump
teffalump / README.md
Last active Mar 29, 2021
OpenWRT adblock implementation
View README.md

Others have recently developed packages for this same functionality, and done it better than anything I could do. Use the packages instead of this script:

Description

In its basic usage, this script will modify the router such that blocked addresses are null routed and unreachable. Since the address blocklist is full of advertising, malware, and tracking servers, this setup is generally a good thing. In addition, the router will update the blocklist weekly. However, the blocking is leaky, so do not expect everything to be blocked.

@teffalump
teffalump / tcplay_wrapper
Last active Dec 14, 2015
Took this from http://jasonwryan.com/blog/2013/01/10/truecrypt/. Change a little for non loopback and disk id.
View tcplay_wrapper
#!/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 / dzen.conky.ratpoison
Last active Oct 7, 2015
dzen + conky + ratpoison for toggleable status bar
View dzen.conky.ratpoison
===== .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 / split_bill.py
Created Nov 15, 2011
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
View split_bill.py
#!/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 / itunes2xml.py
Created May 13, 2011
Extract xml file from itunes subscribe page. That is, get the rss podcast feed from some bullshit iTunes crap
View itunes2xml.py
#!/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