Skip to content

Instantly share code, notes, and snippets.

@jlongman
jlongman / ipfw_lite.sh
Created May 11, 2015 21:41
ipfw show highlighting
#!/bin/sh
# requires line_lite.sh: https://brianin3d.wordpress.com/2008/05/14/scripting-with-ansi-color-codes/
ipfw show | ./line_lite.sh '\*\*\*' green:underline | ./line_lite.sh 'tag.*123' bright
# WIDE - 2 columns - must add pr from a freebsd host
ipfw show | ./line_lite.sh '\*\*\*' green:underline | ./pr -2 -t -w 300 -
ipfw show | ./line_lite.sh '\*\*\*' green:underline | ./line_lite.sh "stat:" bright | ./pr -2 -t -w 300 -
# live update
while 1
ipfw show | ./line_lite.sh '\*\*\*' green:underline | ./line_lite.sh "stat:" bright | ./pr -2 -t -l 86 -w 272 - > /tmp/foo
clear
@jlongman
jlongman / http11get.sh
Last active August 29, 2015 14:20
http/1.1 client one liner
export USER_AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:27.0) Gecko/20100101 Firefox/27.0"
http10get() {
python -c "import urllib; urllib.urlretrieve(\"$1\")"
}
http11get () { python2.7 -c "from urlparse import urlparse
import os
import urllib2
path = \"$XIPIX_DIR\" + urlparse(\"$1\").path;
try:
@jlongman
jlongman / netgraph_tee_splice.sh
Created May 11, 2015 21:45
Netgraph node splicing - add a Tee node
#!/bin/sh
# builds an ng_tee with an ng_iface tied in where the LEFT and LEFT_HOOK were so tcpdump can observe
LEFT=$1
LEFT_HOOK=$2
### ngctl show $LEFT:$LEFT_HOOK
# take RIGHT, RIGHT_HOOK from above line
RIGHT=`ngctl show $LEFT:$LEFT_HOOK | grep -Eo 'ID: [0-9a-e]+' | grep -Eo '[0-9a-e]+'`
RIGHT_HOOK=`ngctl show $LEFT:$LEFT_HOOK | grep $LEFT_HOOK | awk '{print $1}'`
ngctl rmhook $LEFT: $LEFT_HOOK
ngctl mkpeer $LEFT: tee $LEFT_HOOK left
@jlongman
jlongman / rshark.sh
Last active August 29, 2015 14:20
Remote ssh or netcat to wireshark
HOST=$1
ssh root@$HOST tcpdump -U -s0 -w - 'not port 22' | wireshark -k -i -
# or nc -l 12345 # and
# tcpdump -l -ni em0 -s0 -w - | nc $ORIGINAL_HOST 12345
@jlongman
jlongman / pssh.sh
Created May 25, 2015 14:30
ping test a host
function pssh() {
host=$1
shift
ping -o $host && growl "$host connected" && ssh $host $@
}
@jlongman
jlongman / ssh_publish.sh
Created May 25, 2015 14:31
publish ssh key to host
# there's a tool on Linux that does similar to this, not on FreeBSD
ssh_publish(){
host=$1
shift
ssh-keygen -R $host
cat ~/.ssh/id_dsa.pub | ssh -oStrictHostKeyChecking=no $host $@ "mkdir -p .ssh && cat >> .ssh/authorized_keys"
}
@jlongman
jlongman / bikeshare.js
Last active June 1, 2016 18:24
Create a static google map with nearby bixi - from atlasboard code
/**
* Job: staticmap
* Code fragment from bixi atlastboard
* Example Config:
* "mystaticmap": {
* "lat": 40.76727,
* "lon":-73.99392888,
* "city": "nyc"
* }
*
@jlongman
jlongman / wayback-files.py
Created February 9, 2017 03:40
Mv similarly named files to a backup directory,
# usage: pipe an ls command with relevant files.
# e.g. 'ls indexea4f*.html| python wayback-files.py'
#
# assumption: your source pages are static and you don't care about the differences from different dates.
# my blog didn't tend to have blog entry edits
import sys
import os
lastname = ""
@jlongman
jlongman / oldblog.sh
Created February 12, 2017 18:18
My old blog xmlstarlet extraction method
xmlstarlet sel -N my=http://www.w3.org/1999/xhtml -t -c "my:html/my:body/my:div[@class='single-post']" -c "my:html/my:body/my:div/my:div/my:ol[@id='comments']" indexfbc5-4.html
begin remote
name seiki
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 9046 4428
one 596 1606