Skip to content

Instantly share code, notes, and snippets.

View alexwright's full-sized avatar

Alex alexwright

View GitHub Profile
@alexwright
alexwright / keybase.md
Created December 25, 2016 16:00
keybase.md

Keybase proof

I hereby claim:

  • I am alexwright on github.
  • I am alexw (https://keybase.io/alexw) on keybase.
  • I have a public key whose fingerprint is E5AA 7E35 98AC 9D98 297A 6364 148A 922B BCCC 141E

To claim this, I am signing this object:

@alexwright
alexwright / serve.js
Created November 7, 2016 17:24
Serving straight from JSX to the browser
require("babel-register")({
extensions: [
".es6",
".jsx"
],
presets: [
"react",
"es2015",
],
});
@alexwright
alexwright / status2json.py
Last active September 8, 2022 20:50
Parse the Nagios status.dat and poop out some JSON
#!/usr/bin/env python
import re
import json
STATUS_FILE_PATH = "/var/cache/nagios3/status.dat"
def read_status():
hosts = {}
services = {}
@alexwright
alexwright / gist:2ace6688f232c733e1b2
Created December 17, 2015 18:18
Enumerate Intent Extras
Timber.d("Result_Ok");
Bundle extras = data.getExtras();
if (extras != null) {
for (String key : extras.keySet()) {
Timber.d("Extra %s:%s", key, extras.getString(key));
}
}

Keybase proof

I hereby claim:

  • I am alexwright on github.
  • I am alexw (https://keybase.io/alexw) on keybase.
  • I have a public key whose fingerprint is 56B0 74A6 B6EA 8A96 D951 F54D F8A8 9EB0 2E92 4159

To claim this, I am signing this object:

@alexwright
alexwright / reagent.sh
Created February 2, 2014 16:41
Find the most recently created ssh-agent socket and export it to the current session.
#!/bin/bash
export SSH_AUTH_SOCK=$(find /tmp/ssh-* -user `whoami` -name agent\* -printf '%T@ %p\n' | sort -k 1nr | sed 's/^[^ ]* //' | head -n 1);
@alexwright
alexwright / gist:5526721
Created May 6, 2013 17:43
Traverse an object based on dot notation.
a = {foo:{bar:{baz:42}}};
"foo.bar.baz".split('.').reduce(function(o, i) { return o[i]; }, a);
@alexwright
alexwright / sort.py
Created February 14, 2013 19:14
Quick and dirty script to sort pictures into a directory structure based on EXIF DateTaken date/times.
import os
import EXIF
import datetime
work_dir = '../pics'
exif_date_format = '%Y:%m:%d %H:%M:%S'
for dirname, dirnames, filenames in os.walk(work_dir):
for filename in filenames:
old_file_path = os.path.join(work_dir, filename)
<!doctype html>
<html>
<head>
</head>
<body>
<h1>Hi</h1>
<div class="widget" style="padding: 2em;">
<div class="some-menu-whatever">
<button data-color="red" class="btn-change-color">red</button>
<button data-color="blue" class="btn-change-color">blue</button>
def get_commit_activity(self, project):
from datetime import date, timedelta
from pygit2 import Repository
from pygit2 import GIT_SORT_TIME
repo = Repository(project.gitrepo)
weeks = self.get_weeks()
for commit in repo.walk(repo.head.oid, GIT_SORT_TIME):
commit_time = date.fromtimestamp(commit.commit_time)
commit_week = commit_time - timedelta(days=commit_time.weekday())