Skip to content

Instantly share code, notes, and snippets.

View lloydroc's full-sized avatar

Lloyd Rochester lloydroc

  • Denver, Colorado
View GitHub Profile
import Cocoa
import AudioToolbox
import CoreAudio
let fileType = kAudioFileAIFFType;
let sampleRate = 44100.0;
var pcm = AudioStreamBasicDescription(mSampleRate: sampleRate,
mFormatID: kAudioFormatLinearPCM,
mFormatFlags: kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsSignedInteger,
mBytesPerPacket: 2,
@lloydroc
lloydroc / SimpleServer.java
Created July 20, 2018 13:39
Simple Java HTTP Server
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
public class SimpleServer {
@lloydroc
lloydroc / index.html
Last active March 19, 2018 04:40
D3 Line Chart Sound Pressure
<html>
<head>
<meta charset="utf-8">
</head>
<style>
.peak-line {
fill: none;
stroke-width: 1;
stroke: red;
stroke-dasharray: 2,2;
@lloydroc
lloydroc / dwdmbar.js
Last active January 17, 2018 19:27
Bar chart showing DWDM channels
<html>
<head>
</head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>
<body>
<canvas id="myChart"></canvas>
</body>
@lloydroc
lloydroc / init.vim
Last active October 1, 2018 23:15
Neovim Customization File
set number
set nohlsearch
let mapleader="/"
"Mappings
noremap <Leader>ev :e $MYVIMRC<cr>
nnoremap <Leader>sv :source $MYVIMRC<cr>
inoremap jk <esc>
noremap <Leader>n :setlocal number!<cr>
@lloydroc
lloydroc / resize
Created September 18, 2017 05:15
Resize Images in Mac OS X
# Will resize the image given in the first parameter
# to 100x100, 200x200, and 300x300 with
# respective filenames @1x, @2x, @3x
NAME=$(echo "$1" | cut -d'.' -f1)
EXTENSION=$(echo "$1" | cut -d'.' -f2)
sips -z 100 100 $1 --out ../$NAME@1x.$EXTENSION
sips -z 200 200 $1 --out ../$NAME@2x.$EXTENSION
sips -z 300 300 $1 --out ../$NAME@3x.$EXTENSION
@lloydroc
lloydroc / crontab_speed.sh
Created September 1, 2017 02:41
Crontab for Mac Speed Tests
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/15 * * * * speedtest --csv >> speedtests.csv
@lloydroc
lloydroc / testsnmptrap.sh
Created August 25, 2017 21:14
Test SNMP Trap
snmptrap -v 2c -c public localhost '' 1.3.6.1.4.1.8072.2.3.0.1 1.3.6.1.4.1.8072.2.3.2.1 i 123456
# List them all
sudo iptables -v -t nat -L -n --line-numbers
# Create one in the nat table
sudo iptables -t nat -A POSTROUTING --source 172.17.0.3 --destination 172.17.0.3 -p udp -j MASQUERADE
# Delete one in the nat table
sudo iptables -t nat -D POSTROUTING 12
sudo iptables -t nat -D DOCKER 2
@lloydroc
lloydroc / listen-snmp.sh
Created August 4, 2017 17:52
tcpdump to capture snmp packets
tcpdump -i eno1 -T snmp -n dst portrange 161-162
# output looks like this for an ios router linkup
# 11:47:50.905818 IP 10.10.201.27.56503 > 10.10.202.11.162: V2Trap(138) .1.3.6.1.2.1.1.3.0=791308 .1.3.6.1.6.3.1.1.4.1.0=.1.3.6.1.6.3.1.1.5.4 .1.3.6.1.2.1.2.2.1.1.1=1 .1.3.6.1.2.1.2.2.1.2.1="FastEthernet0/0" .1.3.6.1.2.1.2.2.1.3.1=6 .1.3.6.1.4.1.9.2.2.1.1.20.1="up"
# in ios you can see how many snmp traps, the address its sending to and the port
# router4#show snmp
# Chassis: FTX151202SZ
# 0 SNMP packets input
# 0 Bad SNMP version errors
# 0 Unknown community name