Skip to content

Instantly share code, notes, and snippets.

View joshuakfarrar's full-sized avatar
💻
EitherT[IO, Throwable, Human]

Joshua K. Farrar joshuakfarrar

💻
EitherT[IO, Throwable, Human]
View GitHub Profile
@joshuakfarrar
joshuakfarrar / animations.js
Created August 6, 2013 21:53
The start of the game I was making on my Arduino at Nodebots Day DC. I had to leave early due to camping, so I didn't get to finish :(
var five = require('johnny-five')
, board
, pot
, button, buttonStatus
, pin = 9 // starting pin
, animation
board = new five.Board();
var speed = 100
_ _ _ _
__ _____| | | __| | ___ _ __ ___ | |
\ \ /\ / / _ \ | | / _` |/ _ \| '_ \ / _ \ | |
\ V V / __/ | | | (_| | (_) | | | | __/ |_|
\_/\_/ \___|_|_| \__,_|\___/|_| |_|\___| (_)
## .
// Click the Invisible Cow hacks
// CTIC doesn't use jQuery, so selectors and triggering events are dirty funky native
// I initially tried simply $('#cow').click(); to no avail
// Instead, I wrote a function to simulate clicks and then we can click on the cow by passing its position to the function
function simulateClick(x, y) {
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initMouseEvent(
'click', true, true, window, 0,
0, 0, x, y, false, false,
false, false, 0, null
// C'mon, Axe. Get your act together. return Axe.writesBadCode(); // always returns true
// http://moffdub.files.wordpress.com/2009/01/2609_2768.jpg
var self = this;
var get = {
a: {
girlfriend: (function() { console.log('derp'); })
}
}
var opened = true // toggle
, map_width
, side_panel_width
, OPEN_SIDEBAR_WIDTH = 30
, MAX_MAP_WIDTH = 100
var self = this;
$("#toggle").on('click', function() {
zergling:rails-haiti-map zipp$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
server starting
# check my app, 'could not connect to server: Connection refused'
# is pg running? px aux | grep pg says no
zergling:rails-haiti-map zipp$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start --log=derp.txt
server starting
zergling:rails-haiti-map zipp$ cat derp.txt
FATAL: database files are incompatible with server
# stream a compressed backup file into a local database using pipes
ssh -C zipp@remote_ip 'cat ~/backupfile.sql.gz' | gunzip -dc | mysql -u root -D database
var fs = require('fs')
fs.readFile(process.argv[2], function(err, file) {
if (err) return err;
console.log(file.toString().split('\n').length - 1);
});
# enter password twice even though no prompt exists. find a better way!
mysqldump -h $HOST -u $USERNAME -p $PRODUCTION_DB_NAME | mysql -h $HOST -u $USERNAME -p $ARCHIVE_DB_NAME
var fs = require('fs')
, path = require('path')
fs.readdir(process.argv[2], function(err, list) {
for (var k = 0; k < list.length; k++) {
var name = list[k];
if (path.extname(name) == '.' + process.argv[3]) console.log(name);
}
});