Skip to content

Instantly share code, notes, and snippets.

@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
// based on
// https://raw.githubusercontent.com/bmorton/dnswatch/0eec21738a7f9b3786c43e6c13c2d6c32cc60f73/dnswatch.go
package main
import (
"flag"
"fmt"
"time"
"github.com/google/gopacket"
import unittest
import unh698
class FlaskrTestCase(unittest.TestCase):
def setUp(self):
self.app = unh698.app.test_client()
@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"
@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 / 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"
package main
import (
"flag"
"log"
"net"
"net/http"
"strings"
"time"
### 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: