Skip to content

Instantly share code, notes, and snippets.

Ross Duggan duggan

Block or report user

Report or block duggan

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
@duggan
duggan / hacker.py
Created May 23, 2019
Hacker Sangiovese 2018
View hacker.py
#!/usr/bin/env python3
import binascii
content = ''
with open('hacker.txt') as f:
content = f.read().splitlines()
line = ''.join(content)
n = 8
lines = [line[i:i+n] for i in range(0, len(line), n)]
@duggan
duggan / glow.ino
Created Oct 20, 2017
Arduino. Fading an LED in and out to produce a glow effect via the PWM pins.
View glow.ino
/* Fading an LED in and out to produce a glow effect
via the PWM pins.
*/
int timer = 10;
int pin = 3;
int val = 0;
void setup(){
pinMode(pin, OUTPUT);
@duggan
duggan / configure.sh
Created Feb 3, 2017
A shell script for configuring Mesos/Storm via environment variables in Docker
View configure.sh
#!/usr/bin/env bash
#
# Write a Storm configuration from environment variables.
#
# Environment variables namespaced with `MESOS_STORM_`
set -o errexit
set -o nounset
@duggan
duggan / pre-commit
Last active Dec 19, 2016 — forked from hartfordfive/pre-commit
Git pre-commit hook to validate JSON files
View pre-commit
#!/bin/bash
# Comments:
# 1. You must add execution rights to this file (chmod u+x pre-commit)
# 2. You need to have the 'jq' package installed to parse the json
if [ "$(command -v jq )" == "" ] ; then
echo "jq required for pre-commit hook $0"
exit 1
fi
View barricade.config
files:
"/tmp/barricade.sh" :
mode: "000700"
owner: root
group: root
source: <Your Barricade install.sh URL>
"/opt/elasticbeanstalk/tasks/taillogs.d/barricade.conf" :
mode: "000755"
owner: root
@duggan
duggan / Podcache.md
Last active Dec 22, 2015
Back up podcasts with metadata from a feed URL. Progress indicator and resuming.
View Podcache.md

Podcache

Back up podcasts with metadata from a feed URL. Progress indicator and resuming. Hacky, only really tested against FeedBurner/libsyn feeds.

When you run it, you get a directory named after the podcast with a list of mp3 files and metadata.json files.

tree /mnt/backups/podcast/
/mnt/backups/podcast/
@duggan
duggan / inventory.py
Created Oct 12, 2015
Present Terraform tfstate data as an Ansible inventory
View inventory.py
#!/usr/bin/env python
import sys
import os
import json
import argparse
import collections
__description__ = """Ansible Dynamic Inventory for Terraform."""
__epilog__ = """
@duggan
duggan / purge.py
Last active Aug 29, 2015
Delete bucket objects and remove them from CloudFlare's cache, parallellised on prefixes.
View purge.py
#!/usr/bin/env python
"""
Depends on boto and pyflare (install with `pip install boto pyflare`).
usage: purge.py [-h] -b BUCKET [-p PREFIX] -z ZONE [-d]
Parallellized S3 object and CloudFlare cache purger.
optional arguments:
-h, --help show this help message and exit
@duggan
duggan / s3-metadata.py
Last active Aug 29, 2015
Modify metadata headers for bucket objects parallellised on key prefixes. Based on Boto.
View s3-metadata.py
#!/usr/bin/env python
"""
Depends on boto (install with `pip install boto`).
usage: s3-metadata.py [-h] -a HEADER -b BUCKET [-p PREFIX] [-d]
Parallellized S3 metadata modifier.
optional arguments:
-h, --help show this help message and exit
@duggan
duggan / mandelbrot.ps
Created Jul 21, 2015
PostScript for generating a Mandelbrot set.
View mandelbrot.ps
%!PS-Adobe-2.0
51 .5 551 { /x exch def 111 .5 721 { /y exch def y 521 sub 201 div x 301 sub 201 div 1 index 1 index 31 -1 1 { /n exch def 1 index dup mul 1 index dup mul 1 index 1 index add /d exch def sub 4 index add 3 1 roll 2 mul mul 2 index add d 4 gt {exit} if } for pop pop pop pop n 31 div setgray x y moveto .5 0 rlineto 0 .5 rlineto -.5 0 rlineto fill } for } for showpage
You can’t perform that action at this time.