Skip to content

Instantly share code, notes, and snippets.

View callumj's full-sized avatar
🙌
writing code

Callum Jones callumj

🙌
writing code
View GitHub Profile
@callumj
callumj / ec2_hostname.rb
Created July 12, 2012 01:33
Set hostname from EC2 Tags (Name, Domain)
#!/usr/bin/env ruby
require 'net/http'
require 'open-uri'
require 'uri'
require 'base64'
require 'openssl'
require 'cgi'
def query_aws(host, path, action, params = {}, method = "GET")
@callumj
callumj / 1prep.yml
Created July 14, 2014 13:04
Ansible examples
---
# Configures the system for deploying My School Day
- name: Ensure backend directory exists
file: path=/apps/backend state=directory owner=app group=apps mode=0770
- name: Ensure shared directory exists
file: path=/apps/shared state=directory owner=app group=apps mode=0770
- name: Ensure shared sub directories exist

Keybase proof

I hereby claim:

  • I am callumj on github.
  • I am callumj (https://keybase.io/callumj) on keybase.
  • I have a public key whose fingerprint is 27C2 6E66 2C8B 759D C7C8 98AC 9CDF BAFF 07E0 F16D

To claim this, I am signing this object:

@callumj
callumj / README.md
Created November 18, 2012 10:30
Use rtmpdump and ffmpeg to download BBC Radio 1 shows

This script will use the tools rtmpdump and ffmpeg to download and convert a BBC Radio 1 show into a m4a file.

It is capable of either downloading a show direct, or finding the latest show from a webpage.

Requirements

  • nokogiri (Ruby gem)
  • rtmpdump (binary)
  • ffmpeg (binary)
@callumj
callumj / index.html
Last active July 14, 2017 22:58
window_test
<html>
<head>
<style type="text/css">
td, th {
text-align: center;
}
.view {
cursor: pointer;
}
@callumj
callumj / collate_excel.rb
Created January 4, 2017 18:15
Collate multiple CSV into sheets in one Excel workbook using RubyXL
files = Dir.glob("#{ENV["FOLDER"]}/**.csv").sort
files.each do |file|
worksheet = workbook.add_worksheet(file.gsub("#{ENV["FOLDER"]}/", "").gsub(".csv", "").gsub("*", ""))
row_indx = 0
CSV.foreach(file) do |row|
row.each_with_index do |cell, cell_indx|
worksheet.add_cell(row_indx, cell_indx, cell)
end
row_indx += 1
end
@callumj
callumj / mysql-dump.sh
Last active December 25, 2015 08:19
tcpdump for MySQL - recording table modifications.
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(INSERT|UPDATE)/) {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$time = "$hour:$min";
if (defined $q) {
if ($q =~ /INSERT\s+INTO\s+`(\w+)`/) {
print "$time,insert,$1\n";
}
if ($q =~ /UPDATE\s+`(\w+)`/) {
--1be8c94f995d47bb81e298f853aba9c0
Content-Disposition: form-data; name="avatar"; filename="FSQ-Scr1.png"
Content-Type: image/png
âPNG

IHDRÄ¿í<8…tEXtSoftwareAdobe ImageReadyq…e<#iTXtXML:com.adobe.xmp<?xpacket begin="Ôªø" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.5-c014 79.151481, 2013/03/13-12:09:15 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmp:CreatorTool="Adobe Photoshop CC (Macintosh)" xmpMM:InstanceID="xmp.iid:CF015EF9F0FA11E297C097A1C70D0091" xmpMM:DocumentID="xmp.did:CF015EFAF0FA11E297C097A1C70D0091"> <xmpMM:DerivedFrom stRef:instanceID="xmp.iid:CF015EF7F0FA11E297C097A1C70D0091" stRef:documentID="xmp.did:CF015EF8F0FA11E297C097A1C70D0091"/> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="r"?>f˙‘S PLTEfi
@callumj
callumj / csv_to_yml.rb
Created June 20, 2013 03:27
Generates YAML files from a directory of CSVs using libraries that know what they are doing.
require 'csv'
require 'yaml'
dir ||= ENV["CSV_DIR"]
Dir["#{dir}/*.csv"].each do |file|
set = []
fields = []
index = 0
http://placeme.azurewebsites.net/suburb/recommendation?responses%5BhousePrice%5D%5B%5D=1000000&responses%5BhousePrice%5D%5B%5D=1500000&responses%5Bage%5D%5B%5D=36&responses%5Bage%5D%5B%5D=45&responses%5BcloseToCity%5D=true&responses%5Bstate%5D=WA