Skip to content

Instantly share code, notes, and snippets.

View craigw's full-sized avatar
🦄

Craig R Webster craigw

🦄
View GitHub Profile
@craigw
craigw / aws_delete-default-vpc.sh
Last active December 15, 2021 15:19 — forked from jokeru/aws_delete-default-vpc.sh
Script to delete all AWS default VPCs from all regions using AWS CLI
#!/usr/bin/env bash
set -euo pipefail
for AWS_REGION in $(aws ec2 describe-regions --region eu-west-1 --query '[Regions[].RegionName]' --output text); do
echo -n "* Region ${AWS_REGION}: "
export AWS_REGION
# get default vpc
vpc=$(aws ec2 describe-vpcs --filter Name=isDefault,Values=true --query "Vpcs[0].VpcId" --output text)
@craigw
craigw / sha256.h
Last active August 29, 2015 14:01 — forked from ezodude/NSString+SO.m
- (uint8_t *)SHA256;
craig@zuu 0 ruby-1.9.3-p194 ~$ ruby ./example.rb 2>example.err 1>example.out
craig@zuu 0 ruby-1.9.3-p194 ~$ cat example.err
STDERR
craig@zuu 0 ruby-1.9.3-p194 ~$ cat example.out
STDOUT
@craigw
craigw / aop_logging.rb
Created May 25, 2011 10:38 — forked from timruffles/aop_logging.rb
extreme aop logging idea
before:
def process_message message
logger.debug "Started #{message.headers["message-id"]}"
event = JSON.parse message.body
logger.debug "Action: #{event['action']}"
match_id = event['matchID']
active_entries = PassingGame::Entry.count_active_for match_id
logger.info "#{active_entries} active entries for match_id = #{match_id}"
if fail_on? event
<div class="actions left">
<h3>Home</h3>
<% @home_actions.each do |player_action| %>
<%=h player_action.inspect %><br />
<% end %>
</div>
<div class="actions right">
<h3>Away</h3>
# how to test that this works?
# or would you even bother?
...
begin
require 'system_timer'
rescue LoadError
require 'timeout'
SystemTimer = Timeout
require('http')
.createServer(function(request, response){
setTimeout(function() {
response.sendHeader(200, {'Content-Type' : 'text/plain'});
response.sendBody("zoom");
response.finish();
}, 2000);
})
.listen(8000);
@craigw
craigw / models.php
Created October 14, 2009 11:13 — forked from sneeu/models.php
<?php
abstract class Model {
static abstract function getFields();
static function getFieldsForSQL() {
return implode(', ', self::getFields());
}
static function getAll() {
@craigw
craigw / models.php
Created October 14, 2009 11:13 — forked from sneeu/models.php
<?php
abstract class Model {
static abstract function getFields();
static function getFieldsForSQL() {
return implode(', ', self::getFields());
}
static function getAll() {
@craigw
craigw / gist:175901
Created August 26, 2009 22:31 — forked from james/gist:175877
# Ruby tends to pass by reference.
# http://groups.google.com/group/ruby-talk-google/msg/aa5cdea350f46314
#
# Notice all the same object ID in the output.
#
class Test
def self.test
hash = {:entry => ""}
array = []