Skip to content

Instantly share code, notes, and snippets.

@shapeshed
shapeshed / aws-cf-logs
Last active September 12, 2022 09:10
Fetch AWS Cloudfront Logs, decompress, combine into a single file and remove comments
#!/usr/bin/env bash
BUCKET=$1
CWD=$(pwd)
if [[ -n $1 ]]; then
aws s3 sync s3://$BUCKET/cf-logs .
cat *.gz > combined.log.gz
find $CWD ! -name 'combined.log.gz' -name '*.gz' -type f -exec rm -f {} +
gzip -d combined.log.gz
@shapeshed
shapeshed / gist:0bff69546ae312899d51
Created November 11, 2015 09:34
S3 Hosted Site custom domain proxy
server {
listen 80;
server_name some.domain.com;
location / {
access_log off;
resolver 8.8.8.8;
set $backend "somebucket.s3-website-eu-west-1.amazonaws.com";
proxy_pass http://$backend;
proxy_redirect off;
proxy_set_header Host $backend;
7a29b835e5914fb4aeb2859c2c77b1d0
37d87edd33e7c75372590ba9cc2db797
@shapeshed
shapeshed / course.json
Created December 4, 2014 09:16
course structure
{
"course": {
"name": "iOSH Health and Safety",
"arborId": "123",
"modules": [
{
"title": "Introducing Managing Safely",
"sections": [
{
"title": "Introduction",
@shapeshed
shapeshed / app.js
Last active August 29, 2015 14:07
Box.com Events Long Polling
var boxSdk = require('box-sdk');
var winston = require('winston');
var logger = new (winston.Logger)({
transports: [
new (winston.transports.File)({
filename: './events.log',
json: true
})
]
@shapeshed
shapeshed / coverage.sh
Created July 4, 2014 12:15
Post Coverage from TC to Github Pull Requests
#!/usr/bin/env sh
ISSUE=`echo %teamcity.build.branch% | cut -d '/' -f 1`
COVERAGE=`cat coverage/PhantomJS\ 1.9.7\ \(Linux\)/index.html | grep "Lines: <span class=\"metric\">" | awk -F ">" '{print $2}' | cut -d "<" -f1`
curl -X POST -H "Content-Type: application/json" -d "{\"body\": \"I am coveragebot! LOC code coverage is now $COVERAGE\"}" -u [mykey]:x-oauth-basic https://api.github.com/repos/BedeGaming/BingoV3/issues/$ISSUE/comments
@shapeshed
shapeshed / ndch.md
Last active August 29, 2015 14:01
Guardian Article

National Day of Civic Hacking aims to empower citizens to improve communities through collaborative action.

This weekend the [National Day of Civic Hacking][2] will encourage citizens at 100 events in 120 cities to improve their communities and governments that serve them. It will promote civic hacking and open data as an opportunity to foster innovation in the civic space and make governments more transparent and accountable. Around the globe hackers, designers, entrepreneurs and citizens will work together to innovate and bring change to their communities and cities.

In Tacloban, the Philippines city that was [hit by the eye of Typhoon Haiyan][3], community development organisers are hosting an event to focus on local post-disaster redevelopment. The White House is hosting [an event][11] focusing on new ways for citizens to sign petitions and to make their voices heard. In Columbus, Ohio, city residents will be invited to collaborate on local challenges around homelessness, poverty and failing school

get_iplayer --stream --type=tv --modes=flashhigh2 "http://www.bbc.co.uk/iplayer/playlive/bbc_two" | mplayer -cache 2048 -
@shapeshed
shapeshed / index.html
Created November 27, 2013 14:45
Forced synchronous layout is a possible performance bottleneck.
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
@shapeshed
shapeshed / authlogin.txt
Last active December 28, 2015 02:29
Seige Test on Auth Service
# Test completed with seige http://www.joedog.org/siege-home/
# Test runs for 2 minutes, repeated 5 times
# siege --log=loadtest.log -H 'Content-Type:application/json' "https://qa01-sgp.bedegaming.net:18203/Auth/Login POST < ./postdata.json" -c 50 -t 2m
# postdata: {"Email": "gornbo@gmail.com", "SiteCode": "bingostars.com", "Password": "xxxxx", "IpAddress": "127.0.0.1"}
# 50 concurrents
Date & Time Trans Elap Time Data Trans Resp Time Trans Rate Throughput Concurrent OKAY Failed
2013-11-12 10:06:18 3966 119.87 3 1.00 33.09 0.03 33.13 3966 0
2013-11-12 10:08:32 3806 119.44 3 1.04 31.87 0.03 33.15 3806 0