Skip to content

Instantly share code, notes, and snippets.

@jackprice
jackprice / sendData.js
Created July 5, 2013 07:35
Use a hidden iframe to send data. Useful for bypassing cross-origin request restrictions where you don't need to know the response, just to send the data.
/**
* Send data to a URL using a hidden iframe
* @param {String} URL The URL to send to
* @param {Object} data An object describing the data to send (optional)
* @param {String} method The method (GET / POST) (optional)
*/
function sendData(URL, data, method){
/* Check we have a URL to send to */
if (typeof URL != "string"){
return;
@jackprice
jackprice / download-4chan
Created July 10, 2013 14:13
Download all images from a 4chan thread. Simples.
#!/bin/bash
if [ $# -ne 1]; then
echo Usage:
echo $0 [URL]
fi
wget -O - $1 | egrep -e "//images.4chan.org/s/src/[0-9]*.jpg" -o | while read u; do wget "http:"$u; done
@jackprice
jackprice / dp.js
Created December 28, 2013 16:20
Borrowing from Android, allows you to use the device-independant pixel unit (dp) in CSS stylesheets.
(function(){
var dpi;
function get_dpi(){
var div = document.createElement("div");
div.style.visibility = "hidden";
div.style.width = "1in";
div = document.body.appendChild(div);
var dpi = div.clientWidth;
div.parentElement.removeChild(div);
@jackprice
jackprice / .motd
Created February 10, 2015 19:28
Bash motd
#
# Shell script to print a motd with various bits of information about the system
# Included from .bashrc
#
# Get hostname
HOSTNAME=$(hostname)
# Get kernel version
KERNEL="$(uname -r) ($(uname -s))"
CHAR_FULL_TRIANGLE='\356\202\260'
COLOR_WHITE='\e[37m'
COLOR_RESET='\e[0m'
COLOR_GREY='\e[90m'
COLOR_BLUE='\e[34m'
COLOR_GREEN='\e[32m'
BG_GREY='\e[100m'
BG_BLUE='\e[44m'
BG_GREEN='\e[42m'
@jackprice
jackprice / keybase.md
Created August 23, 2016 08:37
Keybase Github ownership proof

Keybase proof

I hereby claim:

  • I am jackprice on github.
  • I am jackprice (https://keybase.io/jackprice) on keybase.
  • I have a public key ASDjxgv6e-lnsewvgQepPR9fPP5SPZWY9pqL23esdbFWsQo

To claim this, I am signing this object:

@jackprice
jackprice / crash.log
Created March 13, 2017 01:56
Terraform debug log
2017/03/13 01:53:20 [INFO] Terraform version: 0.8.8 403a86dc557fae52f8e39676b11e1e4356b7d1a2
2017/03/13 01:53:20 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2017/03/13 01:53:20 [DEBUG] Detected home directory from env var: /Users/jack
2017/03/13 01:53:20 [DEBUG] Detected home directory from env var: /Users/jack
2017/03/13 01:53:20 [DEBUG] Attempting to open CLI config file: /Users/jack/.terraformrc
2017/03/13 01:53:20 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/03/13 01:53:20 [DEBUG] Detected home directory from env var: /Users/jack
2017/03/13 01:53:20 [TRACE] Preserving existing state lineage "63085651-34fe-42e7-a7b5-17c38c61c513"
2017/03/13 01:53:20 [TRACE] Preserving existing state lineage "63085651-34fe-42e7-a7b5-17c38c61c513"
2017/03/13 01:53:20 [TRACE] Graph after step *terraform.ConfigTransformerOld:
@jackprice
jackprice / kickstart.cfg.j2
Last active May 18, 2019 22:41
Ansible+Kickstart+Push
install
cdrom
keyboard --vckeymap=gb --xlayouts='gb'
lang en_GB.UTF-8
timezone Europe/London --isUtc
network --hostname={{ inventory_hostname }}
%packages
@jackprice
jackprice / Makefile
Last active April 11, 2017 05:46
Ansible+Kickstarter Makefile
build/%.iso: build/%.cfg
./build-configuration-iso.sh build/$*.cfg build/$*.iso
build/%.cfg: kickstart.cfg.j2
ansible-playbook --limit $* template-kickstart.yml
.PHONY: clean
clean:
rm -rf build/*
@jackprice
jackprice / vms.yml
Created April 11, 2017 06:20
Ansible+vSphere+Kickstart Playbook
- hosts: all
connection: local
become: no
vars:
vsphere_hostname: "{{ lookup('env', 'VSPHERE_HOSTNAME') }}"
vsphere_username: "{{ lookup('env', 'VSPHERE_USERNAME') }}"
vsphere_password: "{{ lookup('env', 'VSPHERE_PASSWORD') }}"
vsphere_datacenter: changeme