Skip to content

Instantly share code, notes, and snippets.

Charles Blaxland ampedandwired

  • Sydney, Australia
Block or report user

Report or block ampedandwired

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
@ampedandwired
ampedandwired / gist:3385002
Last active Oct 8, 2017
Zip a directory to memory in Ruby. The rubyzip library is pretty hard to use. I tried for ages to figure out how to zip a directory to a string in memory. So here's an example that zips the given directory to a Ruby StringIO object using rubyzip.
View gist:3385002
require 'zip/zip'
def zip(dir)
Zip::ZipOutputStream::write_buffer do |zos|
Dir["#{dir}/**/**"].each do |file|
path_for_file_in_zip = file.sub(/\A#{dir}\//, '')
if !File.directory?(file)
zip_entry = zos.put_next_entry(path_for_file_in_zip)
zos << IO.read(file)
end
@ampedandwired
ampedandwired / gist:3682627
Created Sep 9, 2012
A simple command line client for JSON (Rails) APIs - basically a curl wrapper
View gist:3682627
#!/bin/bash
baseurl='http://localhost:3000'
output_file=zb.out
rm $output_file
action=`echo $1 | tr '[a-z]' '[A-Z]'`
shift
url=$1.json
shift
@ampedandwired
ampedandwired / jenkins.conf
Created Sep 25, 2013
Configuring nginx as a Jenkins proxy with SSL
View jenkins.conf
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80 default;
rewrite ^ https://$host$request_uri? permanent;
}
server {
@ampedandwired
ampedandwired / NumberSpec.js
Created Jul 11, 2014
Webpack mocha loader runs multiple times
View NumberSpec.js
expect = require('chai').expect;
describe('arithmetic', function() {
it("adds numbers", function() {
expect(1 + 1).to.eql(2);
});
});
@ampedandwired
ampedandwired / README.md
Created Aug 5, 2014
Chef Intro Workshop
View README.md

Chef Workshop

This workshop will take you through the very basics of creating and running Chef recipes with chef-solo.

This workshop assumes you're running on a Mac or Linux. If you're running Windows best to set up a Linux VM to run this workshop.

Getting Started

@ampedandwired
ampedandwired / README.md
Last active Jul 9, 2019
webpack-dev-server with html-webpack-plugin
View README.md
$ npm install
$ ./node_modules/.bin/webpack-dev-server
$ open http://localhost:8080/webpack-dev-server/

Notes:

  • Note the trailing slash on the URL is significant. Without it webpack-dev-server shows a file listing page.
  • You need 1.0.11 or later of webpack-dev-middleware for this URL to work. With earlier versions you need to specify the full URL like this: http://localhost:8080/webpack-dev-server/index.html.
  • To get a non-autoreloading version of the page use http://localhost:8080/index.html.
@ampedandwired
ampedandwired / myservice
Last active Aug 29, 2015
Generic sysv init
View myservice
#!/bin/bash
service_name=`basename $0`
# Load default variables. Provides a way to configure the service
# differently in different environments.
if [ -f /etc/default/${service_name} ]; then
source /etc/default/${service_name}
fi
@ampedandwired
ampedandwired / Vagrantfile
Created Jan 14, 2015
Configure a Vagrant VM to piggyback off CNTLM running on the host
View Vagrantfile
def get_proxy_url
# Doesn't support different proxies for different protocols at present
host_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] || ENV['https_proxy'] || ENV["HTTPS_PROXY"]
if host_proxy
uri = URI(host_proxy)
if ['localhost', '127.0.0.1'].include? uri.host
# 10.0.2.2 is the default vagrant gateway and should connect to the host OS.
# Confirm this by running 'netstat -r' in the guest.
host_proxy = host_proxy.sub(uri.host, '10.0.2.2')
end
@ampedandwired
ampedandwired / template.rb
Last active Mar 10, 2017
Splitting cfndsl templates into multiple files
View template.rb
require_relative "subtemplate.rb"
CloudFormation {
instance_type = external_parameters.fetch(:instance_type, "t2.micro")
my_instance(instance_type)
}
@ampedandwired
ampedandwired / trello-bz.js
Created Oct 27, 2016
A TamperMonkey script that turns bugzilla bug references in Trello into clickable links. Handles formats
View trello-bz.js
// ==UserScript==
// @name Trello Bugzilla Linker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Links Trello issues to Bugzilla
// @author Charles Blaxland
// @match https://trello.com/*
// @grant none
// ==/UserScript==
You can’t perform that action at this time.