Skip to content

Instantly share code, notes, and snippets.

View afresh1's full-sized avatar

Andrew Hewus Fresh afresh1

View GitHub Profile
@afresh1
afresh1 / watch_woot.pl
Created April 26, 2012 04:29
A handy Twitter streaming API script to watch woot's deals (especially when there is a wootoff)
#!/usr/bin/perl
# Copyright (c) 2012 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
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@afresh1
afresh1 / import-cvs-to-git
Created May 9, 2012 02:35
OpenBSD CVS Port to openbsd-wip
#!/bin/sh
# https://gist.github.com/gists/2641363
# https://github.com/jasperla/openbsd-wip
# $ cd ~/openbsd-wip && CVSROOT=:local:/cvsroot import-cvs-to-git misc/anyport
#GITROOT=~/openbsd-wip
#GITROOT=/usr/ports/mystuff
GITROOT=`pwd`
CVSROOT=${CVSROOT:-/cvs}
# SUBDIR can be any valid dirname without trailing /
@afresh1
afresh1 / tcpbench_client.pl
Created December 14, 2012 04:23
This is a [Mojolicious](http://mojolicio.us) streaming http server that opens a [tcpbench](http://www.openbsd.org/cgi-bin/man.cgi?query=tcpbench) connection to back to you. For me this lets me put the page on my server on the net and connect back to my home system and see the results on anything with a web browser. Mostly based on the [EventSour…
#!/usr/bin/perl
# Start this on a server someplace with tcpbench
# Start tcpbench -s on a machine that is the remote IP you are connecting the the web from
# Browse to the page.
use Mojolicious::Lite;
use Mojo::IOLoop;
use Mojo::IOLoop::Stream;
# Template with browser-side code
get '/' => sub {
@afresh1
afresh1 / lat_lon_to_from_google.pl
Created December 16, 2012 18:04
Some utility methods for converting lat/long to google/bing maps coordinates. EPSG:4326 and EPSG:3856
# Converted from http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
# http://trac.osgeo.org/proj/wiki/man_cs2cs
# similar to
# cs2cs -f "%.10f" +init=epsg:3857 +to +init=epsg:4326
# and
# cs2cs -f ".10f" +init=epsg:4326 +to +init=epsg:3857
# http://trac.osgeo.org/proj/wiki/man_cs2cs
use Math::Trig;
@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 / git_prompt.sh
Last active October 13, 2021 11:03
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.
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 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 / tmup.sh
Created May 15, 2013 22:11
I use this in my .bashrc to update my shell environment from tmux
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;
@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