Skip to content

Instantly share code, notes, and snippets.

View maxrp's full-sized avatar

Max P maxrp

View GitHub Profile
@maxrp
maxrp / haversines.py
Last active August 29, 2015 14:12
Another python haversine implementation
#!/usr/bin/env python
import math
# from here: https://gist.github.com/rochacbruno/2883505
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371 # km
@maxrp
maxrp / xephyrize.sh
Created November 2, 2014 20:55
My preferred way of launching a test X server for WM experimentation
#!/bin/bash
# Usage: ./xephyrize 2bwm|dwm|cwm|tinywm
# Define a simple X session
function x_session() {
sleep 1;
$@ &
xterm &
}
#!/usr/bin/env bash
DESKS=( ' one ' ' two ' ' three ' ' four ' ' five ' )
battery() {
acpi --battery | \
awk -F, '{print $2}'
}
dual_date() {
@maxrp
maxrp / null_request_check.py
Last active August 29, 2015 14:03
Check to see if null-appended requests get you a 200 with content (and if it's the apache directory listing)
#!/usr/bin/env python
from contextlib import closing
from hashlib import sha1
import sys
import urllib2
def hash_page(content):
page_hash = sha1()
@maxrp
maxrp / wauditclean.py
Created April 24, 2014 18:28
Simple script to reduce bulk and flatten Windows audit log exports to a simple event series
#!/usr/bin/python
import csv
# Ad hoc names for the fields from the source CSV
WAUDITFIELDS = ( 'id',
'type',
'facility',
'date',
'empty?',
@maxrp
maxrp / gist:8679487
Last active January 4, 2016 21:09
A simple top-level view of a PHP cas client integration
<?php
/**
* PHP-CAS library.
*/
require_once "CAS/CAS.php";
/**
* d2l SSO library.
*/
require_once "d2l-login.php";
/**
@maxrp
maxrp / rc.conf
Last active February 8, 2023 03:39
FreeBSD 13.1 confs for a slightly better life on a Lenovo x220
# sysmouse will work with the trackpoint and trackpad, so enable
moused_enable="YES"
# Power saving features to keep it from getting ridiculously hot
powerd_enable="YES"
# you'll need to `pkg install drm-510-kmod`
kld_list="i915kms"
@maxrp
maxrp / scrape_cgit_repos.py
Created July 1, 2013 19:30
Check out all the git projects advertised on a cgit page.
#!/usr/bin/env python
"""
Get all git projects advertised on a cgit index as submodules for a repo.
Usage:
./scrape_cgit_repos.py http://git.example.com ./repos
"""
from bs4 import BeautifulSoup as soupy
@maxrp
maxrp / quicktbb.sh
Last active December 18, 2015 07:19
#!/usr/bin/bash
# enable job control
set -m
TOR_PKGS=(tor-browser-gnu-linux-x86_64-2.3.25-8-dev-en-US.tar.gz{,.asc})
TOR_MIRROR='https://www.torproject.org/dist/torbrowser/linux/'
# never hurts to double check this
TOR_SIGNING_KEY='416F061063FEE659'
@maxrp
maxrp / FUThread.sh
Last active December 17, 2015 20:19
Fuckin' threads. Fuck 'em.
#!/usr/bin/bash
USERNAME=''
PASSWORD=''
THRESHOLD='1000'
SLO_THREADS=$(mysqladmin -u$USERNAME -p$PASSWORD proc | egrep -v 'Sleep|Time|Id|processlist' | awk -F'|' '{print $7,$2,$9}' | sort -bnr | sed '/^[ \t\n]*$/d' | head -5 )
date
while read -r line; do