Skip to content

Instantly share code, notes, and snippets.

View sulrich's full-sized avatar
🙀
furble plotz

steve ulrich sulrich

🙀
furble plotz
View GitHub Profile
@sulrich
sulrich / vonage.sh
Created May 8, 2012 19:32
an old shell script to enable one to do vonage dialing from the command line. particularly nice when you have the phone number in your clipboard and you want to use quicksilver or something along those lines to make the call.
#!/bin/sh
#
RCFILE=$HOME/.vonage
PREFIX='1'
#if [ a$1 = a ]
#then
# printf '\n\nUsage: dial \n\n'
# exit
#fi
@sulrich
sulrich / mail_ofocus.rb
Created June 22, 2012 16:14
script to push mail message into omnifocus from mutt
#!/usr/local/bin/ruby
require 'rubygems'
require 'mail'
require 'appscript'; include Appscript
require 'iconv'
message = STDIN.read
mail = Mail.new(message)
require 'formula'
class Fetchmail < Formula
# note that the following url is actually a javascript redirection.
# download the associated file and place it into /Library/Caches/Homebrew
homepage 'http://www.fetchmail.info/'
url 'http://prdownload.berlios.de/fetchmail/fetchmail-6.3.21.tar.bz2'
# md5 '548f152df27d32b632afa4f1a8a6cd1a'
md5 '0ad8eac47e85bd0ae63870daa09992af'
@sulrich
sulrich / gist:3744698
Created September 18, 2012 18:03 — forked from al3xandru/gist:1169583
OmniFocus Generalized Bookmarklet
javascript:(function(){
var w=window,d=document,selectedTxt=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),pageUri=w.location.href,isGMail=w.location.host.match(/mail\.google\.com/),subject=d.title,source;
if(isGMail){
var msgFrm=d.getElementById("canvas_frame"),subjectSpans;
if(msgFrm){
subjectSpans=msgFrm.contentDocument.getElementsByClassName("hP");
if(subjectSpans)subject=subjectSpans[0].innerText;
};
if(!subjectSpans){
subject=d.title.substring(d.title.indexOf("-")+1,d.title.lastIndexOf("-")).replace(/^%20+/,"").replace(/%20+$/,"")
(setq edit-server-url-major-mode-alist
'(
("github\\.com" . markdown-mode)
("wikicentral\\.*" . confluence-mode)
))
@sulrich
sulrich / spirent-convert.pl
Created January 11, 2013 16:17
some spirent test center releases have a bug where they encode traffic stream addresses in an, ahem, counterintuitive manner. this unpacks the elements appropriately and generates a merged field with the IP addresses packaged appropriately.
#!/usr/bin/perl
# -*- mode: cperl; c-basic-offset: 2; indent-tabs-mode: nil -*-
open (INFILE, "<$ARGV[0]") || die "ERROR: opening $ARGV[0]\n";
while (<INFILE>) {
my @traffic = split(',', $_);
next if $#traffic <= 1; # skip the cruft lines in the input file.
my $lt1 = int2addr($traffic[2]);
my $rt1 = int2addr($traffic[3]);
@sulrich
sulrich / stream-parse.pl
Created January 11, 2013 16:17
parse stream information from spirent (dealing with the foible associated with their horked address encoding) and generate some useful stats around a particular traffic stream. particularly useful for instrumentation of large MPLS-TE tunnel blocks and doing failure analysis.
#!/usr/bin/perl
# -*- mode: cperl; c-basic-offset: 2; indent-tabs-mode: nil -*-
use Statistics::Descriptive;
#fields within the output file
# 00 - Rx Port Name
# 01 - Comp32
# 02 - Comp16_1 (src_addr lt) - the following four fields need to be merged into
# 03 - Comp16_2 (src_addr rt) a valid IP addrss
@sulrich
sulrich / json-disp.pl
Created February 25, 2013 01:29
script to parse nested json in database dumps for kathy
#!/opt/local/bin/perl
use JSON;
use Data::Dumper;
my $debug = 0;
my @json_dump = ();
open(JSON, "$ARGV[0]") || die "error opening: $ARGV[0]\n";
@sulrich
sulrich / ipphone-dial.sh
Created August 27, 2013 16:36
old script to enable dialing via quicksilver on cisco ip phones. so much has changed since then ...
#!/bin/sh
#
RCFILE=$HOME/.ipphone
PREFIX='91'
#if [ a$1 = a ]
#then
# printf '\n\nUsage: dial <dial string>\n\n'
# exit
#fi
@sulrich
sulrich / vpn-live.sh
Last active August 29, 2015 13:56
check the liveness of the VPN for other stuff
#!/bin/zsh
CHK_URL="http://test-destination-host"
# note you need to redireect STDERR -> STDOUT since wget outputs the headers on STDERR
HEADERS=`wget --server-response --spider --quiet -T 1 -t 1 ${CHK_URL} 2>&1`
HEADERS_RET=$?
if [[ ${HEADERS_RET} == 4 ]] {
echo "some sort of network error occurred"