Skip to content

Instantly share code, notes, and snippets.

View afresh1's full-sized avatar

Andrew Hewus Fresh afresh1

View GitHub Profile
@afresh1
afresh1 / screen_sizes
Last active December 14, 2015 13:48
uses xrandr to setup my displays the way I want them on my x220 running OpenBSD. Including a statusbar using dzen2
#!/bin/sh
_screen=1
xrandr | sed -ne 's/(.*$//' -e 's/.* connected *//p'|
while read _line; do
_size=${_line#* }
echo SCREEN_${_screen}_HEIGHT=`echo $_size | sed -e 's/.*x//' -e 's/\+.*//'`
echo SCREEN_${_screen}_WIDTH=`echo $_size | sed -e 's/x.*//'`
echo SCREEN_${_screen}_X=`echo $_size | sed -e 's/[^+]*+\([0-9]*\).*/\1/'`
echo SCREEN_${_screen}_Y=`echo $_size | sed -e 's/.*+.*+//'`
@afresh1
afresh1 / cleanup_maildirs.pl
Created April 24, 2013 22:38
This runs though my Maildir and puts old mail into a .archive mailbox to make the main mailbox access faster.
#!/usr/bin/perl
# $Id: cleanup_maildirs,v 1.27 2011/02/22 00:36:24 andrew Exp $
# Copyright (c) 2013 Andrew Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@afresh1
afresh1 / qemu_carp_on_vlans.sh
Last active December 17, 2015 00:39
This sets up and starts a couple OpenBSD carped virtual machines using qemu and flashrd.
#!/bin/sh
# This uses qemu, so pkg_add qemu
# Download and extract flashrd, either from github or here:
# http://www.nmedia.net/flashrd/
# Grab a flashrd image from here:
# http://www.nmedia.net/flashrd/images/
# and set the name:
flashimg=flashimg.amd64.pccons-20130318
@afresh1
afresh1 / palm_keyring2pwsafe.pl
Created July 11, 2013 06:27
A script to turn a Palm Keyring file into a PasswordSafe v3 file. http://gnukeyring.sourceforge.net/ http://passwordsafe.sourceforge.net/
#!/usr/bin/perl
########################################################################
# Copyright (c) 2013 Andrew Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@afresh1
afresh1 / soekris_net4511_pin2gpio.txt
Created July 14, 2013 04:00
A map of the Soekris net4511 physical pin to GPIO. http://soekris.com/products/net4511.html
http://soekris.com/products/net4511.html
jp3 on the Soekris net4511
pin -> gpio
3 -> 5
4 -> 6
5 -> 7
6 -> 8
7 -> 21
8 -> 22
@afresh1
afresh1 / calagatorEvents.js
Last active December 24, 2015 11:19
A Google Script to copy Calagator Events I'm interested in to my calendar so I can get alarms. http://calagator.org https://script.google.com https://developers.google.com/apps-script/reference/calendar/
function calagatorFactory() {
var calagator = CalendarApp.getCalendarsByName('calagator')[0];
var start = new Date();
var end = new Date( start.getTime() + 7 * 24 * 60 * 60 * 1000 );
var findCopiedEvent = function(cal, event) {
var copy;
var events = cal.getEventsForDay( event.getStartTime() );
for (i in events) {
@afresh1
afresh1 / make_updated_ports.pl
Last active December 28, 2015 14:49
A script that will create updated "starter" Makefiles for OpenBSD perl ports available on the CPAN. Should only require things in the base system, but does like an up-to-date /usr/ports path.
#!/usr/bin/perl
use strict;
use warnings;
# Copyright (c) 2013 Andrew Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
@afresh1
afresh1 / wtf.cgi
Created January 20, 2016 17:09
This simple program displays an issue with either slowcgi or httpd. It appears that the headers end after the first read instead of after the first blank line.
#!/usr/bin/perl
use strict;
use warnings;
$| = 1;
print "foo: bar\r\n" for 1 .. 15;
print "\r\n";
print "quux\r\n";
@afresh1
afresh1 / firefox
Last active May 12, 2016 18:40
~/bin/firefox for OpenBSD. Raises the ulimits needed to keep Firefox from crashing regularly. (~/bin is in my path before /usr/local/bin)
#!/bin/sh
ulimit -n $(ulimit -Hn)
ulimit -d $(ulimit -Hd)
exec /usr/local/bin/firefox "$@"
@afresh1
afresh1 / lock_screen
Created May 15, 2016 19:16
Lock screen and dpms off monitor. I have `command lock "lock_screen"` in ~/.cwmrc and `*/5 * * * * $HOME/bin/monitors_off` in my crontab.
#!/bin/sh
if ! pgrep xlock >/dev/null 2>&1; then
xlock -lockdelay 0 &
sleep 1
fi
sudo -k
ssh-add -D