Skip to content

Instantly share code, notes, and snippets.

@cdosborn
cdosborn / arp-explained.txt
Last active April 10, 2016 00:46
A story to motivate/understand the Address Resolution Protocol (ARP).
| A story to motivate/understand the Address Resolution Protocol (ARP).
|
| Connor Osborn
| 04/09/16
So you want to send a packet to your friend on your local ethernet. They are
blah.coolsite.org and you use DNS to find out which internet address maps to
that name. It's 1.2.3.4, ho-okay. You're fillin out this packet according to
the Internet Protocol (IP). You throw in you're address, their address, blah
blah some more bits. This packet is going over ethernet so you have to wrap
@cdosborn
cdosborn / gist:a4b4dc8175c4634edbfb
Last active February 21, 2016 19:41
Make suckless st compile on OSX..
diff --git a/config.mk b/config.mk
index 81e3e47..8f2352a 100644
--- a/config.mk
+++ b/config.mk
@@ -14,7 +14,7 @@ X11LIB = /usr/X11R6/lib
INCS = -I. -I/usr/include -I${X11INC} \
`pkg-config --cflags fontconfig` \
`pkg-config --cflags freetype2`
-LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXft \
+LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lX11 -lutil -lXft \

Keybase proof

I hereby claim:

  • I am cdosborn on github.
  • I am cdosborn (https://keybase.io/cdosborn) on keybase.
  • I have a public key whose fingerprint is 984F 20A7 9F62 E06E FC94 4BB7 3894 82F7 C056 4A76

To claim this, I am signing this object:

@cdosborn
cdosborn / logtrunc
Last active May 14, 2022 19:58
Truncate log files such that the end of the file is preserved
#! /bin/bash
# Truncate to last 100 lines of each file.
# logtrunc file1 file2 file3
# Truncate to last 50 lines of each file.
# logtrunc -n 50 file1 file2 file3
# WARNING * WARNING * WARNING
# This script is not highly tested
@cdosborn
cdosborn / nano-install.sh
Created October 3, 2015 17:48
nano-install.sh
curl -L -O http://www.nano-editor.org/dist/v2.4/NT/nano-2.4.2.zip
unzip -d nano-temp *nano*.zip
mkdir ~/bin &> /dev/null
cp -r nano-temp/nano*/* ~/bin
rm -r ~/bin/nano/
@cdosborn
cdosborn / alter-your-firefox.txt
Last active August 29, 2015 14:24
Alter your firefox
| Alter your firefox
|
| Connor Osborn
| 07/05/15
Firefox supports users customizing the gui beyond what you might imagine. With
a little snooping around, you can implement a pretty unique interface. For my
interests I wanted to clean up my tab bar (see gif below). Here are the steps to begin
customizing.
@cdosborn
cdosborn / gist:92b0f373ab4364b27032
Created June 25, 2015 19:09
Solutions to jpalardy's bash one-liner challenges, a tribute to gawk
| Solutions from https://github.com/jpalardy/Command-line-one-liner-challenges
|
| Connor Osborn
| 06/25/15
Number 12 is gone, because I thought the challenge was lame (and I like
unicode.)
1) gawk '{ wow[$1] += 1;} END { for (key in wow) print key, wow[key]; }' < $1
2) gawk '{ wow[$1] += 1;} END { for (key in wow) print key, wow[key]; }' < $1
@cdosborn
cdosborn / monty_hall.txt
Last active August 29, 2015 14:23
The monty hall problem
| Musings on the Monty Hall problem
|
| Connor Osborn
| 06/20/15
The problem:
Suppose you're on a game show, and you're given the choice of three doors:
Behind one door is a car; behind the others, goats. You pick a door, say No. 1,
and the host, who knows what's behind the doors, opens another door, say No. 3,
# Big ideas
#
# - 2 types of shell tools
# - Compute (ls, rm, find, grep, vim ..)
# - Format (sort, tail, cut, uniq, sed, ..)
# - awk is the ultimate formatting tool
# - a complete prog lang for text processing
# - handle state on the cmd line
# - 2 major datatypes
@cdosborn
cdosborn / pager.awk
Last active May 13, 2022 23:06
pager.awk
#!/usr/local/bin/gawk -f
BEGIN {
for (i in ARGV) {
if (ARGV[i] == "--sep") {
sep = ARGV[i + 1];
"echo \'" sep "\'" | getline sep
}
ARGV[i] = "";
}