Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View scoates's full-sized avatar

Sean Coates scoates

View GitHub Profile
@scoates
scoates / Stack.php
Created December 12, 2010 21:24 — forked from stenehall/New stack
<?php
/*
* README
* mkdir one && mkdir two && mkdir three && touch one/blueprint-1.3.css && touch one/foobar.css && touch two/jquery.js && touch three/jquery-1.4.js
*
*/
include('stack.php');
<?php
/**
* Sends statistics to the stats daemon over UDP
*
**/
class StatsD {
/**
@scoates
scoates / _modules:boto_fk.py
Last active September 30, 2015 02:58
VPC peering
# …
def _get_not_deleted_peering_connections(name, vpc_conn):
unfiltered_peers = vpc_conn.get_all_vpc_peering_connections(filters={'tag:Name': name})
peers = []
for this_peer in unfiltered_peers:
if this_peer.status_code != u'deleted':
peers.append(this_peer)
return peers
@scoates
scoates / gist:1711131
Created January 31, 2012 15:40 — forked from chartjes/gist:1711104
Hands On Node File System Exercise #3
var fs = require('fs');
function readBytes(filename, position) {
fs.open(filename, 'r', function(err, fd) {
if (err) {
console.log(err.message);
return;
}
var readBuffer = new Buffer(5);
@scoates
scoates / gist:3355357
Created August 15, 2012 03:11
MongoDB: findandmodify seems to use the wrong query on the update command
> db.runCommand({ findAndModify: 'assets', query: {$or: [ { "_id" : "4ff70c97c87a97bc7f000002" }, { "_id" : ObjectId("4ff70c97c87a97bc7f000002") } ]}, update: {$set: {private: true}}, new: true, upsert: false })
{
"lastErrorObject" : {
"updatedExisting" : true,
"n" : 1,
"connectionId" : 1317,
"err" : null,
"ok" : 1
},
"value" : {
@scoates
scoates / _modules:boto_fk.py
Last active October 9, 2015 03:33
Salt: Auto-assign public IPs in VPC subnets
# -*- coding: utf-8 -*-
'''
TODO
'''
# keep lint from choking on _get_conn and _cache_id
#pylint: disable=E0602
# Import Python libs
from __future__ import absolute_import
@scoates
scoates / hangout.scpt
Created October 2, 2015 19:31
Start a Google Hangout in Textual with `/hangout`
on textualcmd(inputString, destinationChannel)
tell application id "com.google.Chrome"
activate
delay 0.5
if (count of (every window where visible is true)) is greater than 0 then
if URL of active tab of front window is not "chrome://newtab/" then
tell front window
make new tab
end tell
@scoates
scoates / timeline
Last active December 10, 2015 09:29
Times each line of stdin
#!/usr/bin/env python
import time
from sys import stdin, stdout, argv, exit
try:
if argv[1] == 'help' or argv[1] == '--help' or argv[1] == '-h':
print "%s: times each line of stdin.\n Optional parameter is a float of a threshold. (defaults to 2.0)" % argv[0]
exit(255);
else:
alert('ownenated?')
alert('ownerened?')