Skip to content

Instantly share code, notes, and snippets.

@brimston3
brimston3 / n8x0_recode.bash
Last active December 20, 2015 15:49
No guarantee that this still works; last modified date says 2009. I used it to resize video to less than 400x704 for display on my nokia n810. You can probably play with the parameters too.
#!/bin/bash
#Requires:
# mplayer, mencoder. mkvmerge
# libx264, liblame
HaveOpt() {
local needle=$1
shift
while [[ $1 == -* ]]; do
@brimston3
brimston3 / strbuf.c
Created September 8, 2013 01:32
Wrote this for amusement; it is not fully tested. A friend wanted a way to avoid freeing return results from a function call that he called repeatedly.
/*
* strbuf.c
* Andrew Domaszek
* CodeLibrary/dynamic_string
*
* Copyright September 6, 2013, Andrew Domaszek
* All rights reserved.
*
Redistribution and use in source and binary forms, with or without
@brimston3
brimston3 / autoscreen.bashrc
Last active December 22, 2015 14:49
.bashrc script to auto-attach screen if there is a session available on login.
#/bin/bash
#set -x
: <<'END'
autoscreen.bashrc
Andrew Domaszek
project: random bits of bash
Copyright (C) September 8, 2013, Andrew Domaszek
@brimston3
brimston3 / config.py
Created September 18, 2013 01:09
load id3 data into postgresql, intermediate through sqlite3 for tag filtering.
#!/usr/bin/python
conn_string = "host='localhost' dbname='radio' user='radio_queue' password='apassword'"
@brimston3
brimston3 / rectify_updated_soas.py
Created September 20, 2013 20:23
PowerDNS. Whenever the SOA is updated, queue the zone to have it rectified.
#!/usr/bin/python
import subprocess
import psycopg2
conn_string = "host='localhost' dbname='pdns' user='pdns' password=''"
def call_rectifyzone(zone):
proc = 0
try:
@brimston3
brimston3 / rdnslistconv.sh
Created September 21, 2013 20:47
Awk script to convert from a list of IPv4s and hostnames to a zonefile format rdns entry.
awk '{print gensub(/([0-9]*)\.([0-9]*)\.([0-9]*)\.([0-9]*) - (.*)/,"\\4.\\3.\\2.\\1.in-addr.arpa. IN PTR \\5.", $0)}' << "EOF"
192.168.1.101 - test.localdomain
192.168.1.105 - test2.example.com
EOF
@brimston3
brimston3 / genstats.py
Created March 18, 2014 11:27
some die rolling nonsense for d&d-like stats
import random;
import os;
import copy;
random.seed(os.urandom(20));
def Mode1GenFcn():
dg = []
for x in range(4):
dg.append(random.randint(1,6))
@brimston3
brimston3 / preprocessor_monstrosities_1.c
Created May 8, 2014 20:00
Selecting functions using C preprocessor symbol concatenation.
#include <stdio.h>
#include <stdarg.h>
void f1() {
printf("a\n");
}
void f2() {
printf("b\n");
}
@brimston3
brimston3 / array_contains.bash
Created July 14, 2014 18:03
A function to test if contents are in array. I probably swiped this from S.O. with minor alterations.
#!/bin/bash
function contains() {
local n=$#
local value=${!n}
for ((i=1;i < $#;i++)) {
if [ "${!i}" == "${value}" ]; then
return 0
fi
}
@brimston3
brimston3 / autosys_hold_all.bash
Created July 15, 2014 11:59
multi-environment kill-and-hold for autosys... if this script would work for you, you should know on sight. I assume no liability from using parts of this script. {} string expansions need bash. Script tested in bash 4.2. You may need to re-alias jr and se before executing.
######## DO SETUP ########
e=accD
pre=UD
jildir=$DATDIR/../jil
for file in "`ls -1 \"$jildir\"`"
do
ostr=`grep delete_box $file | gawk -v s=$pre '{if (NR>1) {exit(0)};gsub(/\\\$S/,s,$2);print $2}'`
echo $ostr
stat=`jr $ostr | egrep '^'$ostr | sed -e 's@.* \([A-Z][A-Z]\) .*@\1@'`
echo $ostr $stat