Skip to content

Instantly share code, notes, and snippets.

View azhawkes's full-sized avatar

Andy Hawkes azhawkes

View GitHub Profile
@azhawkes
azhawkes / BootStrap.groovy
Created May 22, 2014 22:36
Add a dynamic "commify" to Groovy's ArrayList
class BootStrap {
def init = { servletContext ->
ArrayList.metaClass.commify = {
StringBuilder output = new StringBuilder()
for (int i = 0; i < delegate.size(); i++) {
if (i == 0) {
output.append(delegate[i])
} else if (i == delegate.size() - 1) {
output.append(" and ${delegate[i]}")
@azhawkes
azhawkes / keybase.md
Created October 1, 2014 01:21
Keybase verification

Keybase proof

I hereby claim:

  • I am azhawkes on github.
  • I am azhawkes (https://keybase.io/azhawkes) on keybase.
  • I have a public key whose fingerprint is AF0C 077D AF5C 2F90 5BB9 70AE 8A64 011E 0695 1A98

To claim this, I am signing this object:

@azhawkes
azhawkes / express-facebook-connector.js
Last active August 29, 2015 14:14
Crude Express microservice for a Facebook connector
var Express = require('express');
var BodyParser = require('body-parser');
var CredentialsService = require('infusionsoft-credentials');
var app = Express();
app.use(BodyParser.json());
app.get('/activities', function(req, res) {
var accessToken = CredentialsService.resolveCredentials(req.params.credentialsId).accessToken;
@azhawkes
azhawkes / docker-deploy-storm-cluster.sh
Last active November 27, 2015 09:00
Deploys a 3-node Storm cluster with Docker
#!/bin/bash
# Set these to the Docker hosts you want each container to run on
ZOOKEEPER_HOST=10.0.1.249
NIMBUS_HOST=10.0.1.250
SUPERVISOR_HOST=10.0.1.251
# Run ZooKeeper
$ export DOCKER_HOST=tcp://$ZOOKEEPER_HOST:5000
$ docker run -h zookeeper --name=zookeeper -d jplock/zookeeper
@azhawkes
azhawkes / gist:5009567
Last active December 14, 2015 01:49
Workaround to disable SWT full-screen mode on the Mac, to get around this nasty bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=389486
public static void disableFullScreen(Shell shell) {
try {
Field windowField = Shell.class.getDeclaredField("window");
windowField.setAccessible(true);
Object window = windowField.get(shell);
invoke(window.getClass(), window, "setCollectionBehavior", new Long[] { 0L });
} catch (Exception e) {
log.error("couldn't disable full screen mode", e);
}
@azhawkes
azhawkes / .vimrc
Created January 15, 2014 00:44
Finally decided to fix my .vimrc and other configs
" Vundle package manager
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Vundle packages
Bundle 'gmarik/vundle'
Bundle 'maksimr/vim-jsbeautify'
Bundle 'einars/js-beautify'
@azhawkes
azhawkes / .editorconfig
Created January 15, 2014 00:45
Vim configs for the JsBeautify plugin in ~/.vim/.editorconfig
; .editorconfig
root = true
[**.js]
indent_style = space
indent_size = 4
[**.css]
indent_style = space
@azhawkes
azhawkes / .htaccess
Created January 22, 2014 14:15
Apache mod_rewrite config to treat requests for /something as /something.html behind the scenes. Using this for a static Jekyll site because I don't want the .html extensions visible to end users.
RewriteEngine on
# Automatically rewrite /something -> something.html
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.html -f
RewriteRule /(.*)$ /$1.html [L]
# Strip off .html extensions from the request and redirect
RewriteCond %{REQUEST_URI} ^(.+)\.html$
RewriteRule /(.*)\.html$ /$1 [R=301,L]
@azhawkes
azhawkes / random-led-chart.js
Created December 7, 2017 20:39
Fun random LED chart
var columns = 200;
var ticker = document.getElementById("ticker");
for (var i = 0; i < columns; i++) {
addTickerColumn();
}
function addTickerColumn() {
var value = Math.floor(Math.random() * 5);
var column = document.createElement("div");
// This is a contrived example of some of the things you can do in a Loadster code step.
// HTTP and Wait methods are synchronous by design, no callbacks required.
// More documentation is coming soon!
console.log("We're in a code step.");
// Wait between 0 and 2 seconds
user.wait(Math.random() * 2000);
// Make a GET request with page resources