Skip to content

Instantly share code, notes, and snippets.

Chris Agerton cagerton

Block or report user

Report or block cagerton

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cagerton
cagerton / colorfade.py
Created May 15, 2019
Simple example for using udmx to control a monoprice rgbaw-uv dmx light
View colorfade.py
"""
Simple rgb color fade tested with the monoprice rgbawuv
Requires python3.7 for the async coroutine syntax; should be trivial to backport though
Requires:
libusb==1.0.22b4
numpy==1.16.3
pyusb==1.0.2
scikit-image==0.15.0
@cagerton
cagerton / no_push_f_master.rb
Last active Mar 9, 2019
pre receive hook
View no_push_f_master.rb
#!/usr/bin/env ruby
# pre-receive hook to block 'push -f' on master
# For Phabricator, save this as:
# $REPO/hooks/pre-receive-phabricator.d/no_push_f_master.rb
# Remember to chmod +x
# Ref: http://git-scm.com/book/en/Customizing-Git-An-Example-Git-Enforced-Policy
args = STDIN.readline.chomp.split(" ")
$oldrev, $newrev, $refspec = args
@cagerton
cagerton / mail.py
Created Aug 6, 2014
this saves 3 months of vpn setup
View mail.py
from flask import Flask, redirect, render_template, url_for, request
from flask_bootstrap import Bootstrap
import redis
import json
app = Flask(__name__)
Bootstrap(app)
r = redis.Redis()
@cagerton
cagerton / fetch_hostkey.py
Last active Aug 29, 2015
Simple script to fetch an ssh host key.
View fetch_hostkey.py
#!/usr/bin/env python2.7
"""Usage: fetch_hostkey.py <host> [<port>]"""
import paramiko, docopt
opt = docopt.docopt(__doc__)
host = opt['<host>']
port = int(opt['<port>'] or 22)
t = paramiko.Transport((host, port))
t.connect()
@cagerton
cagerton / hijack_touch.js
Created Dec 13, 2013
Generate click events on touchstart; kill the mouse events that the browser cooks 200+ms afterwards.
View hijack_touch.js
(function touchJack(){
var lastTouch = 0;
document.addEventListener("touchstart", function(e){
lastTouch = Date.now();
var touch = e.touches[0],
synth_event = document.createEvent("MouseEvents");
synth_event.fab=true;
synth_event.initMouseEvent("click", true, true, window,
0, touch.screenX, touch.screenY, touch.clientX, touch.clientY,
View packages.sls
#!yaml
#
# Postgres 9.3 packages salt state
#
# Created 9/9/13
#
# author: Micah Hausler, micah.hausler@akimbo.io
postgres-pkgs:
pkg:
@cagerton
cagerton / 0.check_keys.py_example.md
Last active Dec 25, 2015
Little python3.3 script to show information about ssh public keys from key files or known_hosts files.
View 0.check_keys.py_example.md

SSH key info for pubkeys, known_hosts, and github users

Usage:
  check_keys.py hosts [<FILE>]
  check_keys.py key [<FILE>...]
  check_keys.py github <user>


$ check_hosts.py github cagerton
[
@cagerton
cagerton / 0upgrade.md
Last active Dec 16, 2015
On storing password hashes
View 0upgrade.md

Upgrade sha1 => scrypt without user logging in/pw reset:

μBackground:

We hash passwords with one-way hash functions to reduce the impact of password database compromise. Passwords hashed with salted SHA or MD5 can ofen be brute forced. Newer password hashhing techniques like Scrypt/Bcrypt/PBKDF2 add computational work to make brute forcing prohibitively expensive.

Problem:

Your service already has users with salted sha1 password hashes. Since you don't have their original passwords you can't upgrade to a modern password hash without getting each user to log in and enter their password.

You have (salt,sha(salt+password)), you want (salt, scrypt(salt,password))

@cagerton
cagerton / fade_test.py
Created Nov 12, 2012
Color fade test for PixelPusher
View fade_test.py
import socket
import time
from math import pi, sin
UDP_IP = '192.168.2.2'
UDP_PORT = 9897
def Push(messages):
"""Stolen from: https://github.com/robot-head/PixelPusher-python"""
assert type(messages) == list
@cagerton
cagerton / gist:1995257
Created Mar 7, 2012
Check your ssh public key fingerprint
View gist:1995257
# Run this command to check your ssh fingerprint.
ssh-keygen -l -f ~/.ssh/*.pub
You can’t perform that action at this time.