Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am mathyourlife on github.
* I am mathyourlife (https://keybase.io/mathyourlife) on keybase.
* I have a public key ASD9_w22c6-SmbGeJpZDew5hQlBy-HuFO-Wdzr7CYKwRqQo
To claim this, I am signing this object:
package main
import (
"flag"
"log"
"net"
"net/http"
"strings"
"time"
@mathyourlife
mathyourlife / asn-block.go
Created April 4, 2019 02:40
ASN iptables Block
// Add iptable blocks for CIDR blocks associated with the ASN
// Each run, the custom chain is flushed and repopulated by the new set of CIDR blocks
//
// Usage:
// asn-block --asn 32934 --asn-name facebook
//
package main
import (
"bytes"
@mathyourlife
mathyourlife / tarball.go
Created June 6, 2018 03:55
create a tarball from a source directory including empty folders
// Sample script for generating a tarball from a source directory
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"io"
"os"
"path/filepath"
@mathyourlife
mathyourlife / catenary-garland.go
Created November 20, 2017 01:38
playing around with finding the length of garland needed for different sags
package main
import (
"fmt"
"image/color"
"math"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
import unittest
import unh698
class FlaskrTestCase(unittest.TestCase):
def setUp(self):
self.app = unh698.app.test_client()
// based on
// https://raw.githubusercontent.com/bmorton/dnswatch/0eec21738a7f9b3786c43e6c13c2d6c32cc60f73/dnswatch.go
package main
import (
"flag"
"fmt"
"time"
"github.com/google/gopacket"
@mathyourlife
mathyourlife / rotate-background.sh
Last active November 18, 2016 04:00
script to dump in a user's crontab to rotate the background image based off a random image in the ~/Pictures/ directory
#!/bin/bash
CACHE_FILE=~/tmp/pic-list
PID=$(pgrep xfce4-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
USE_CACHE=false
if [ -e $CACHE_FILE ]; then
if [ $(date -r $CACHE_FILE +%Y/%m/%d) == $(date +%Y/%m/%d) ]; then
USE_CACHE=true
@mathyourlife
mathyourlife / LexPerm.go
Created May 5, 2015 22:02
Lexicographic Permutations - implementation of a method without recursion or state memory
/*
Lexicographic Permutations
source: http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order
The following algorithm generates the next permutation lexicographically
after a given permutation. It changes the given permutation in-place.
1) Find the largest index k such that a[k] < a[k + 1].
If no such index exists, the permutation is the last permutation.
@mathyourlife
mathyourlife / csv_chunk generator.py
Created September 29, 2014 15:24
generate chunks of csv files
import csv
# cat First500000.lst
# 0,a
# 1,a
# 2,a
# 3,a
# 4,a
# 5,a
# 6,a