Skip to content

Instantly share code, notes, and snippets.

View homelinen's full-sized avatar

Calum Gilchrist homelinen

View GitHub Profile

Keybase proof

I hereby claim:

  • I am homelinen on github.
  • I am homelinen (https://keybase.io/homelinen) on keybase.
  • I have a public key whose fingerprint is 9891 216E 9A5D C7A8 8F17 EF80 EE14 8ECE 6128 57BC

To claim this, I am signing this object:

# This is a slightly modified .slate file.
# If no ~/.slate file exists this is the file that will be used.
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Resize Bindings
bind right:alt resize +10% +0
bind left:alt resize -10% +0
:hierarchy:
- cfstack/%{cloudformation_stack}/outputs
- cfstack/%{cloudformation_stack}/resources/%{cloudformation_resource_id}
- '%{environment}/hieradata/%{clientcert}'
- '%{environment}/hieradata/autoscaling/%{autoscaling_group_name}'
- '%{environment}/hieradata/autoscaling/%{autoscaling_basename}'
- '%{environment}/hieradata/availability-zones/%{environment}/%{ec2_placement_availability_zone}'
- '%{environment}/hieradata/os/%{::osfamily}/%{::operatingsystem}/%{::operatingsystemrelease}/%{environment}'
- '%{environment}/hieradata/os/%{::osfamily}/%{::operatingsystem}/%{::operatingsystemrelease}/%{ec2_tag_environment}'
- '%{environment}/hieradata/os/%{::osfamily}/%{::operatingsystem}/%{::operatingsystemrelease}'
$ sudo facter | grep environment
ec2_tag_environment => testing
puppet_environment => production
> + for child in config.children:
> + if child.key == "TypesDB":
> + paths = child.value
I think there's probably a more Pythonic way to do this.
List comprehensions is one
paths = [ child.value for child in config.children if child.key == "TypeDB" ]
Using filter to filter out the children and then doing a list comprehension is more readable than above but requries two O(n) loops.
@homelinen
homelinen / parse-ripe-json.py
Created January 28, 2016 12:27
Horrible quick script to scrape RIPE Json files
import netaddr
import json
# Parse IPs to CIDR ranges from https://apps.db.ripe.net/search/query.html#resultsAnchor
def iprange_to_cidr(ip_value):
r = ip_value.split(' - ')
print(r)
return netaddr.iprange_to_cidrs(r[0], r[1])
# Have a default hash that can be merged into an array
# One other requirement is the default should be overridden by the array
default_values = {
username => 'user',
password => 'password'
}
nginx_stats = [
{
@homelinen
homelinen / mesos-userdata-script-do.sh
Last active April 24, 2016 09:43
Setup Mesos in DigitalOcean Userdata (Ubuntu 16.04)
#!/bin/bash
set -e
# Update the packages.
apt-get update
# Install a few utility tools.
apt-get install -y tar wget git

Old Way

func checkBlockedSubdivisions(subdivisions []struct {
       GeoNameID uint              `maxminddb:"geoname_id"`
       IsoCode   string            `maxminddb:"iso_code"`
       Names     map[string]string `maxminddb:"names"`
}) bool {
       for _, sub := range subdivisions {
               if checkRegionInList(sub.Names["en"]) {
 return true
#!/usr/bin/env python
#
# Requirements:
# Flask==0.11.1
import ipaddress
from flask import Flask, request
app = Flask(__name__)