Skip to content

Instantly share code, notes, and snippets.

View maxrp's full-sized avatar

Max P maxrp

View GitHub Profile
@maxrp
maxrp / caslogin.py
Created August 22, 2012 22:34
Example of automated log in to CAS (Central Authentication Service)
#!/usr/bin/env python
from bs4 import BeautifulSoup as soupy
import requests
def login_elements(tag):
"""A filter to find cas login form elements"""
return tag.has_key('name') and tag.has_key('value')
def login(username, password, url):
@maxrp
maxrp / README.mkd
Created October 5, 2012 20:50
CSV to SQLlite tutorial
  1. Start up the sqlite3 commandline on a new datafile: sqlite3 myFooData.db

  2. You should see a prompt something like this:

SQLite version 3.7.11 2012-03-20 11:35:50
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> 
@maxrp
maxrp / CheckArch.java
Created October 9, 2012 19:11
The simplest possible way to determine the JVM architecture, AFAIK
class CheckArch {
public static void main(String[] args) {
String arch = System.getProperty("os.arch");
System.out.println("Architecture: " + arch);
}
}
@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
@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 / 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 / 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 / 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 / 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 / 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()