Skip to content

Instantly share code, notes, and snippets.


Andy Hawkes azhawkes

View GitHub Profile
View code-step-example.js
// 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
View random-led-chart.js
var columns = 200;
var ticker = document.getElementById("ticker");
for (var i = 0; i < columns; i++) {
function addTickerColumn() {
var value = Math.floor(Math.random() * 5);
var column = document.createElement("div");
azhawkes /
Created Oct 15, 2015
Spring Boot: convert inbound parameters from snake_case to camelCase
public class SnakeCaseApplicationConfiguration {
public OncePerRequestFilter snakeCaseConverterFilter() {
return new OncePerRequestFilter() {
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
final Map<String, String[]> parameters = new ConcurrentHashMap<>();
for (String param : request.getParameterMap().keySet()) {
azhawkes / WebConfig.groovy
Created Aug 19, 2015
Spring Boot (RestController) - support for application/octet-stream using InputStream
View WebConfig.groovy
* Adds support for application/octet-stream through a RestController using streams.
class WebConfig extends WebMvcConfigurationSupport {
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new AbstractHttpMessageConverter<InputStream>(MediaType.APPLICATION_OCTET_STREAM) {
protected boolean supports(Class<?> clazz) {
return InputStream.isAssignableFrom(clazz)
azhawkes / express-facebook-connector.js
Last active Aug 29, 2015
Crude Express microservice for a Facebook connector
View express-facebook-connector.js
var Express = require('express');
var BodyParser = require('body-parser');
var CredentialsService = require('infusionsoft-credentials');
var app = Express();
app.get('/activities', function(req, res) {
var accessToken = CredentialsService.resolveCredentials(req.params.credentialsId).accessToken;
azhawkes /
Last active Nov 27, 2015
Deploys a 3-node Storm cluster with Docker
# Set these to the Docker hosts you want each container to run on
# Run ZooKeeper
$ export DOCKER_HOST=tcp://$ZOOKEEPER_HOST:5000
$ docker run -h zookeeper --name=zookeeper -d jplock/zookeeper
azhawkes /
Created Oct 1, 2014
Keybase verification

Keybase proof

I hereby claim:

  • I am azhawkes on github.
  • I am 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 / BootStrap.groovy
Created May 22, 2014
Add a dynamic "commify" to Groovy's ArrayList
View BootStrap.groovy
class BootStrap {
def init = { servletContext ->
ArrayList.metaClass.commify = {
StringBuilder output = new StringBuilder()
for (int i = 0; i < delegate.size(); i++) {
if (i == 0) {
} else if (i == delegate.size() - 1) {
output.append(" and ${delegate[i]}")
azhawkes / .htaccess
Created Jan 22, 2014
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.
View .htaccess
RewriteEngine on
# Automatically rewrite /something -> something.html
RewriteRule /(.*)$ /$1.html [L]
# Strip off .html extensions from the request and redirect
RewriteCond %{REQUEST_URI} ^(.+)\.html$
RewriteRule /(.*)\.html$ /$1 [R=301,L]
azhawkes / .editorconfig
Created Jan 15, 2014
Vim configs for the JsBeautify plugin in ~/.vim/.editorconfig
View .editorconfig
; .editorconfig
root = true
indent_style = space
indent_size = 4
indent_style = space