Skip to content

Instantly share code, notes, and snippets.

View whatupdave's full-sized avatar

Dave Newman whatupdave

  • Twitter
  • Seattle, WA
View GitHub Profile
@whatupdave
whatupdave / uke
Created July 18, 2013 20:12
Lisztomania Uke Part
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-4-6-6-6-6-6-6-6-6-7-7-7-7-7-7-7-7-9--9--9--9--9--9--9--9--6-6-6-6-6-6-6-6-
-2-2-2-2-2-2-2-2-4-4-4-4-4-4-4-4-6-6-6-6-6-6-6-6-7-7-7-7-7-7-7-7-11-11-11-11-11-11-11-11-6-6-6-6-6-6-6-6-
@whatupdave
whatupdave / month.rb
Created June 5, 2013 19:50
Stripe month to date report
require "stripe"
require "time"
Stripe.api_key = ENV['STRIPE_KEY']
start_of_month = Time.parse(Time.now.strftime('1-%b-%Y 00:00:00 UTC'))
def created_after(object, time)
offset = 0
objects = object.all(count:100, offset: offset, created: { gte: time.to_i }).to_a
@whatupdave
whatupdave / drop_collections.js
Created April 29, 2013 21:09
Drop mongo collections with name match
var collectionNames = db.getCollectionNames();
for(var i = 0, len = collectionNames.length; i < len ; i++){
var collectionName = collectionNames[i];
if(collectionName.indexOf('logs_') == 0){
print(i + '/' + len + ':' + collectionName);
db[collectionName].drop();
}
}
@whatupdave
whatupdave / check.sh
Created March 4, 2013 20:53
Text me when Mojang updates the Minecraft server
#!/bin/bash
old_etag=$(curl --silent http://api.openkeyval.org/minecraft-etag)
new_etag=$(curl --silent --head https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar | grep ETag | awk -F\" '{print $2}')
if [ $old_etag != $new_etag ]; then
echo "event=updated old=$old_etag new=$new_etag"
curl --silent -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_USER/SMS/Messages.json \
-u $TWILIO_USER:$TWILIO_PASS \
-d "From=$SMS_FROM" \
@whatupdave
whatupdave / jquery.machine.js
Created March 2, 2013 23:53
An old javascript state machine implementation
/*
Possible names: Reaktor, Fat Controller
ideas:
bind/unbind between states?
allow machines to be shared, overriding states on instance
$('#target').machine({
stopped : {
enter : ['a.pause:hide', 'a.play:show'],
exit : ...,
@whatupdave
whatupdave / gist:3219431
Created July 31, 2012 18:50
Minecraft 1.3.1 Help
2012-07-31 11:44:59 [INFO] /ban <name> [reason ...]
2012-07-31 11:44:59 [INFO] /ban-ip <address|name> [reason ...]
2012-07-31 11:44:59 [INFO] /banlist [ips|players]
2012-07-31 11:44:59 [INFO] /debug
2012-07-31 11:44:59 [INFO] /defaultgamemode <mode>
2012-07-31 11:44:59 [INFO] /deop <player>
2012-07-31 11:44:59 [INFO] /gamemode <mode> [player]
2012-07-31 11:45:05 [INFO] /give <player> <item> [amount] [data]
2012-07-31 11:45:05 [INFO] /help [page|command name]
2012-07-31 11:45:05 [INFO] /kick <player> [reason ...]
2012-05-27 11:59:06 Welcome to Minecraft Overviewer!
2012-05-27 11:59:06 Checking all tiles for updates manually.
*******************************************************************************
2012-05-27 11:59:06 E An error has occurred. This may be a bug. Please let us know!
See http://docs.overviewer.org/en/latest/index.html#help
This is the error that occurred:
Traceback (most recent call last):
File "overviewer/overviewer.py", line 493, in <module>
ret = main()
2012-05-27 11:34:09 Welcome to Minecraft Overviewer!
2012-05-27 11:34:09 Checking all tiles for updates manually.
2012-05-27 11:34:31 Rendered 0 of 22369621. 0% complete
*******************************************************************************
2012-05-27 11:34:35 E An error has occurred. This may be a bug. Please let us know!
See http://docs.overviewer.org/en/latest/index.html#help
This is the error that occurred:
Traceback (most recent call last):
File "overviewer/overviewer.py", line 493, in <module>
multi = EventMachine::Multi.new
multi.add :query1, query1
multi.add :query2, query2
multi.callback do |results|
puts results
end
@whatupdave
whatupdave / emhiredis.rb
Created August 23, 2011 22:20
emhiredis example
require 'em-hiredis'
module EMServer
def post_init
puts "-- someone connected to the echo server!"
end
def receive_data data
redis = EM::Hiredis.connect
redis.callback do