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 / watch_woot.pl
Created Apr 26, 2012
A handy Twitter streaming API script to watch woot's deals (especially when there is a wootoff)
View watch_woot.pl
#!/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
OpenBSD CVS Port to openbsd-wip
View import-cvs-to-git
#!/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 Dec 14, 2012
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…
View tcpbench_client.pl
#!/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 Dec 16, 2012
Some utility methods for converting lat/long to google/bing maps coordinates. EPSG:4326 and EPSG:3856
View lat_lon_to_from_google.pl
# 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 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
You can’t perform that action at this time.