Skip to content

Instantly share code, notes, and snippets.

@teffalump
teffalump / README.md
Last active January 4, 2023 21:17
OpenWRT adblock implementation

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 / 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"
@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 / 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 / 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 / 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
#!/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 / 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 .
@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}