Skip to content

Instantly share code, notes, and snippets.

@noah
noah / dovecot-maildir-compress.sh
Last active November 30, 2022 09:34 — forked from cs278/dovecot-maildir-compress.sh
Compresses email in maildir format with check for already-compressed files
#!/bin/bash
# Enable zlib in Dovecot alongside automatic writing of new emails in gzipped format
## Convert Existing Emails using process described with the pseudocode here: https://wiki.dovecot.org/Plugins/Zlib
##
##
store=.
compress=bzip2
@noah
noah / mmw
Last active September 8, 2018 03:30
mmw: _inimalistic _arkdown _iki
#!/bin/sh
#
# mmw: _inimalistic _arkdown _iki
#
# dependencies:
# - grip (or another markdown compiler)
# - tree(1)
#
# installation:
# - cat mmw> ./git/hooks/post-commit
@noah
noah / clean-rtorrent.sh
Created June 13, 2017 03:50
Cron task to delete torrents from rtorrent after 48 hours of seeding.
#!/bin/sh
# Close torrents in rtorrent after x hours of seeding
# dependencies: libxmlrpc-core-c3-dev, bc, nginx
# https://github.com/mdevaev/emonoda/wiki/rTorrent-XMLRPC-Reference
# http://elektito.com/2016/02/10/rtorrent-xmlrpc/
x=48
SERVER=localhost:8000
now=$(date +%s)
@noah
noah / vcr.sh
Last active January 25, 2020 06:52
VCR transcoding - usbtv007
# ツ sudo lsusb|grep -i easy
# Bus 001 Device 007: ID 1b71:3002 Fushicai USBTV007 Video Grabber [EasyCAP]
# usbtv module on archlinux
# fushicai usbtv007
# ultimately, mencoder works. also tried mplayer and ffmpeg but on-the-fly transcoding doesn't work. mplayer can't save tv "streams", so mencoder is necessary.
# audio transcode o-t-f is fast enough but just copy video and transcode it later
# tradeoff: 1GB/1minute of video, roughly
@noah
noah / count-exif-tags.py
Created January 4, 2017 16:26
Count unique EXIF tags
def grouper(iterable, n, fillvalue=None):
args = [iter(iterable)] * n
return izip_longest(*args, fillvalue=fillvalue)
# read exif data and build a list of unique keys
media_files = []
for root, sub_folders, files in walk(app.config['MEDIA_ROOT']):
for f in files:
media_files.append(path.join(root, f))
@noah
noah / common-exif-tags.csv
Created January 4, 2017 16:18
Common EXIF tags
ExifTool:ExifToolVersion 123469
File:Directory 123469
File:FileAccessDate 123469
File:FileInodeChangeDate 123469
File:FileModifyDate 123469
File:FileName 123469
File:FilePermissions 123469
File:FileSize 123469
SourceFile 123469
File:FileType 80230
@noah
noah / convert.rb
Created January 4, 2017 15:02
Convert HTML to markdown using pandoc
#!/usr/bin/env ruby
#
%w[nokogiri open-uri chronic].each{|lib| require lib}
base = "https://blog.tilton.co"
doc = Nokogiri::HTML open "#{base}/archive.html"
doc.search('section.archives a').each do |post|
post_link = post[:href]
@noah
noah / ssh-github-deploy.sh
Created November 11, 2016 10:32
Programmatically create deploy keys, on server and GitHub, for an existing git repository
#!/bin/sh
KEYDIR=~/.ssh/keys.d/github-deploy
CONFDIR=~/.ssh/config.d/github-deploy
github_username=noah
github_access_token=$(cat ~/.secret/github_access_token)
rp=$(git rev-parse --is-inside-work-tree 2>/dev/null)
@noah
noah / BlockSpammer.py
Last active July 7, 2016 14:15
Programmatically add entries to postfix sender_access file.
#!/usr/bin/env python2
import sys
import smtplib
from subprocess import call
from email.parser import Parser
from email.utils import parseaddr, make_msgid
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
@noah
noah / 2pod.sh
Created May 2, 2016 17:00
# recursively convert all flac to mp3 and add to ipod
#!/bin/sh
# recursively convert all flac to mp3
#
for dir in "$@"; do
echo "+ $dir"
find "$dir" -type f -name "*.flac"\
| parallel -u\
ffmpeg -v warning -n -i {} -qscale:a 0 {.}.mp3
done