Skip to content

Instantly share code, notes, and snippets.

View tolland's full-sized avatar

Tom Hodder tolland

View GitHub Profile
@halberom
halberom / 0_play.yml
Last active November 5, 2021 18:13
ansible - example of calling a handler when a fact is set
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- debug: msg="call handler"
changed_when: True
notify: do something
handlers:
@trestletech
trestletech / instance-types.sh
Created June 15, 2016 16:41
Get all EC2 Instance Types in All Availability Zones
#!/bin/bash
echo "Getting list of Availability Zones"
all_regions=$(aws ec2 describe-regions --output text --query 'Regions[*].[RegionName]' | sort)
all_az=()
while read -r region; do
az_per_region=$(aws ec2 describe-availability-zones --region $region --query 'AvailabilityZones[*].[ZoneName]' --output text | sort)
while read -r az; do

Basic

import code; code.interact(local=locals())

Advanced

IPython with embed()

@BenConstable
BenConstable / elasticsearch.conf
Last active November 15, 2018 11:41
Elasticsearch Upstart config
#
# Elasticsearch Service
#
# Tested with ES v1.5.2
#
# Doesn't currently support a configurable JVM.
#
# Adapted from the SysVInit script ES provides, which
# can be found here:
#
@mannieschumpert
mannieschumpert / gist:8886289
Last active August 2, 2020 13:15
Code Examples from Andrew Nacin's "Current User Can Watch This Talk"
<?php
// If you can edit pages, you can edit widgets
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps['edit_pages'] ) )
$caps['edit_theme_options'] = true;
return $caps;
} );
@digulla
digulla / FastXtextResourceSetProvider.java
Created September 20, 2012 07:11
Faster implementation of XtextResourceSetProvider.
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
import org.eclipse.xtext.ui.resource.XtextResourceSetProvider;
import org.eclipse.xtext.ui.util.JdtClasspathUriResolver;
anonymous
anonymous / gist:2980348
Created June 23, 2012 22:36
lsusb -v for 5MP/220x adafruit microscope: https://www.adafruit.com/products/636
Bus 001 Device 006: ID 0ac8:3420 Z-Star Microelectronics Corp. Venus USB2.0 Camera
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x0ac8 Z-Star Microelectronics Corp.
@tolland
tolland / Makefile
Created June 4, 2012 06:34 — forked from atdt/Makefile
Build and upload Chrome extensions to GitHub using APIv3
EXTNAME := extension
KEYFILE := $(EXTNAME).pem
CRXFILE := $(EXTNAME).crx
EXTDIR := $(EXTNAME)
SHELL := /usr/bin/env bash
CHROME := open /Applications/Google\ Chrome.app -n --args
CWD := $(shell pwd)
SIZE := $(shell wc -c <$(CRXFILE) | tr -d ' ')
VERSION := $(shell python -c "import json,sys;print json.loads(sys.stdin.read()).get('version','')" < $(EXTDIR)/manifest.json)
ZIPFILE := $(EXTNAME)-$(VERSION).crx
@nazgob
nazgob / gist:2367583
Created April 12, 2012 14:13
vagrant cheatsheet
# setup vagrant
gem install vagrant
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
mkdir my_vagrant_test
cd my_vagrant_test
vagrant init lucid32
vim Vagrantfile
vagrant up
vagrant ssh
@fujin
fujin / foo.rb
Created January 31, 2012 21:49
template override between cookbooks
template "/tmp/foo.rb"
source "foo.rb.erb"
cookbook "banana"
end