Skip to content

Instantly share code, notes, and snippets.

View dearing's full-sized avatar

Jacob Dearing dearing

View GitHub Profile
@dearing
dearing / websockets-echo-test.cs
Created February 10, 2012 07:33
RFC6455: simple echo test with websocket after handshake
/* http://tools.ietf.org/html/rfc6455#section-5.2
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-------+-+-------------+-------------------------------+
|F|R|R|R| opcode|M| Payload len | Extended payload length |
|I|S|S|S| (4) |A| (7) | (16/64) |
|N|V|V|V| |S| | (if payload len==126/127) |
| |1|2|3| |K| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
| Extended payload length continued, if payload len == 127 |
@dearing
dearing / fizzbuzz.go
Created March 22, 2012 03:55
GO, FizzBuzz as a webserver...
/*
FizzBuzz in GO, as a webserver...
*/
package main
import (
"flag"
"fmt"
"net/http"
c "strconv"
@dearing
dearing / trivialweb.go
Created April 18, 2012 02:13
Trivial HTTP/HTTPS server in Go
// trivial HTTP server
package main
import (
"flag"
"fmt"
"log"
"net/http"
)
@dearing
dearing / WXR-attachment-scraper-jpeg.rb
Created April 27, 2012 02:48
WXR export attachment scraper (hard-coded for type/jpeg); checks existing CDN objects and publishes them if needed
#!/usr/bin/ruby
require 'net/http'
require 'cloudfiles'
require 'colorize'
require 'uri'
i = 0
skipto = ARGV[0].to_i
snooze = ARGV[1].to_f
@dearing
dearing / nftables.conf
Created October 13, 2014 01:56
standard netfilter tables script for bootup on Arch : /etc/nftables.conf
table inet firewall {
chain incoming {
type filter hook input priority 0;
# bad tcp -> avoid network scanning:
tcp flags & (fin|syn) == (fin|syn) drop
tcp flags & (syn|rst) == (syn|rst) drop
tcp flags & (fin|syn|rst|psh|ack|urg) < (fin) drop # == 0 would be better, not supported yet.
tcp flags & (fin|syn|rst|psh|ack|urg) == (fin|psh|urg) drop
@dearing
dearing / modules-nftables.conf
Created October 13, 2014 01:58
/etc/modules-load.d/nftables.conf
nf_conntrack
nf_conntrack_ipv4
nf_conntrack_ipv6
nf_defrag_ipv4
nf_defrag_ipv6
nf_nat
nf_nat_ipv4
nf_tables
nf_tables_inet
nf_tables_ipv4
@dearing
dearing / keyring-inject.py
Last active August 29, 2015 14:10
inject keys into rings
#!/usr/bin/python2
# req : pip install keyring
import sys
import keyring
# ERROR if not enough arguments supplied
if len(sys.argv) < 4:
print '''
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("Hello World!")
fmt.Println("Testing the editor...")
@dearing
dearing / setup.rb
Created May 5, 2015 21:30
quickly strap a student workstation
%w(git nano vim vi wget curl).each do |p|
package p
end
remote_file '/tmp/atom.rpm' do
owner 'student'
group 'student'
mode '0644'
source 'https://atom.io/download/rpm'
@dearing
dearing / firewall.json
Created May 12, 2015 06:17
$ nft export > firewall.json
{
"nftables": [
{
"table": {
"name": "nat",
"family": "ip",
"flags": 0,
"use": 2
}
},