Skip to content

Instantly share code, notes, and snippets.

Andrew Fresh afresh1

Block or report user

Report or block afresh1

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@afresh1
afresh1 / screen_sizes
Last active Dec 14, 2015
uses xrandr to setup my displays the way I want them on my x220 running OpenBSD. Including a statusbar using dzen2
View screen_sizes
#!/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 / git_prompt.sh
Last active Dec 15, 2015
My git branch prompt, colorizes the branch based on status. Might need some work on the colors as yet. Apart from the definition, works in bash or ksh.
View git_prompt.sh
function _git_prompt() {
local _branch=`git branch --no-color 2> /dev/null | sed -ne 's/^* //p'`
[[ -z $_branch ]] && return
local _bgcolor
local _color
for s in `git status --porcelain | tr ' ' '.' | cut -c 1-2`; do
if [ -z "$_color" ]; then
case "$s" in
@afresh1
afresh1 / cleanup_maildirs.pl
Created Apr 24, 2013
This runs though my Maildir and puts old mail into a .archive mailbox to make the main mailbox access faster.
View cleanup_maildirs.pl
#!/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 Dec 17, 2015
This sets up and starts a couple OpenBSD carped virtual machines using qemu and flashrd.
View qemu_carp_on_vlans.sh
#!/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 / tmup.sh
Created May 15, 2013
I use this in my .bashrc to update my shell environment from tmux
View tmup.sh
tmup () {
echo -n "Updating to latest tmux environment...";
local IFS=",";
for line in $(tmux showenv -t $(tmux display -p "#S") | tr "\n" ",");
do
if [[ $line == -* ]]; then
unset $(echo $line | cut -c2-);
else
export $line;
View palm_keyring2pwsafe.pl
#!/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
View soekris_net4511_pin2gpio.txt
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 Dec 24, 2015
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/
View calagatorEvents.js
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 Dec 28, 2015
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.
View make_updated_ports.pl
#!/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 Jan 20, 2016
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.
View wtf.cgi
#!/usr/bin/perl
use strict;
use warnings;
$| = 1;
print "foo: bar\r\n" for 1 .. 15;
print "\r\n";
print "quux\r\n";
You can’t perform that action at this time.