Skip to content

Instantly share code, notes, and snippets.

View homelinen's full-sized avatar

Calum Gilchrist homelinen

View GitHub Profile
git diff
diff --git a/tmux-osx.conf b/tmux-osx.conf
index 8093298..a7f6295 100644
--- a/tmux-osx.conf
+++ b/tmux-osx.conf
@@ -1,8 +1,8 @@
set -g default-command "reattach-to-user-namespace -l ${SHELL}"
-bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
+bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
$ cat /etc/apt/sources.list.d/graylog.list
# This file is managed by Puppet. DO NOT EDIT.
# The official Graylog package repository
deb https://downloads.graylog.org/repo/debian/ stable 2.1
$ apt-get update
Ign https://downloads.graylog.org stable Release.gpg
Ign https://downloads.graylog.org stable Release
Err https://downloads.graylog.org stable/2.1 amd64 Packages
server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
#!/usr/bin/env python
#
# Requirements:
# Flask==0.11.1
import ipaddress
from flask import Flask, request
app = Flask(__name__)

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
@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
# 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 / 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])
> + 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.
$ sudo facter | grep environment
ec2_tag_environment => testing
puppet_environment => production