Skip to content

Instantly share code, notes, and snippets.

View tlhunter's full-sized avatar
📷
Taking Photos

Thomas Hunter II tlhunter

📷
Taking Photos
View GitHub Profile
@tlhunter
tlhunter / health.js
Created October 24, 2012 18:32
/HEALTH
app.get('/health', function(req, res){
res.send({
pid: process.pid,
memory: process.memoryUsage(),
uptime: process.uptime(),
connections: server.connections
});
});
@tlhunter
tlhunter / example.php
Created September 5, 2013 17:47
How does one use DocBlocks to specify a require array key?
<?php
class MyCoolClass {
/**
* @var $data array How does one specify this array needs a 'subelement' key?
*/
public function performAction($data) {
echo $data['requiredkey'];
}
}
@tlhunter
tlhunter / blackjack.js
Created March 9, 2014 05:50
Node.js Blackjack using the Prototype and Constructor Approach
var readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
// CARD CLASS
var Card = function(face, suite) {
if (this.faces.indexOf(face) == -1) {
throw new Error("Invalid Face: " + face);

Keybase proof

I hereby claim:

  • I am tlhunter on github.
  • I am tlhunter (https://keybase.io/tlhunter) on keybase.
  • I have a public key whose fingerprint is 34FA 158E 563B CEF7 816E DB79 3B71 1C30 7DA2 4AA1

To claim this, I am signing this object:

@tlhunter
tlhunter / rmq-pub.js
Created June 4, 2014 22:01
Node.js ampqlib pubsub example, works with RabbitMQ, run several instances of each script
#!/usr/bin/env node
var amqp = require('amqplib');
var exchange_name = 'pubsub';
amqp.connect('amqp://localhost').then(function(conn) {
process.once('SIGINT', function() { conn.close(); });
return conn.createChannel().then(function(channel) {
@tlhunter
tlhunter / gist:31830e88fb27bd3277fd
Created June 19, 2014 03:19
Attempting to upgrade Nginx on Debian
# http://wiki.nginx.org/Install#Official_Debian.2FUbuntu_packages
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
nginx
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 477 kB of archives.
#EXTM3U
#EXTINF:-1,Groove Salad: a nicely chilled plate of ambient beats and grooves. [SomaFM]
http://uwstream1.somafm.com:80
#EXTINF:-1,Dub Step Beyond: Dubstep, Dub and Deep Bass. May damage speakers at high volume. [SomaFM]
http://somafm.com/dubstep.pls
#EXTINF:-1,Def Con Radio: SomaFM's special mix for Def Con [SomaFM]
http://somafm.com/defcon.pls
#EXTINF:-1,The Trip: Progressive house / trance. Tip top tunes. (Formerly Tag's Trance Trip) [SomaFM]
http://somafm.com/thetrip.pls
#EXTINF:-1,Suburbs of Goa [SomaFM]
var level_result = createLevel(12, {data: true});
console.log(level_result);
function createLevel(user_id, level_data) {
var user = getUser(user_id);
var can_create = canCreate(user);
if (!can_create) {
return null;
}
var print = typeof print === 'function' ? print : console.log.bind(console);
function X() {
}
X.prototype.dispatch = function (obj) {
this[obj.type](obj);
};
var DEGREE = 20;
@tlhunter
tlhunter / flip.js
Created November 2, 2015 00:06
Flips every item in a PNG spritesheet horizontally, maintaining position
#!/usr/bin/env node
/**
* Flips each item in a spritesheet horizontally, maintaining position
* @author Thomas Hunter II <me@thomashunter.name>
*
* 1) Execute `npm install lwip async`
* 2) Delete the following conditional in the lwip node_module:
* https://github.com/EyalAr/lwip/blob/1138482318e79ee6c69706b544ed5d6ffe11391c/lib/ImagePrototypeInit.js#L467
*/