Skip to content

Instantly share code, notes, and snippets.

View bingeboy's full-sized avatar
🏠
Working from home

JP McGarrity bingeboy

🏠
Working from home
View GitHub Profile
#!/bin/bash
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
read one five fifteen rest < /proc/loadavg
@bingeboy
bingeboy / sym link for iterm2.sh
Created July 3, 2013 20:18
Sym link for iterm2
@bingeboy
bingeboy / client.js
Last active December 19, 2015 06:59 — forked from TJkrusinski/client.js
twit npm
$(function(){
var socket = io.connect('http://localhost:8080');
socket.on('tweet', function(tweet) {
$('body').append('<div class="tweet">' + tweet.text + '</div>');
});
});
@bingeboy
bingeboy / get-loop.js
Created July 1, 2013 02:38
Loop for GET requests.
var http = require('http');
var pool = require('generic-pool').Pool({
name : 'http_request',
create : function(callback) {
var c = http.createClient(80, '127.0.0.1');
callback(null, c);
},
destroy : function(client) { },
max : 10,
var request = require('request')
, JSONStream = require('JSONStream')
, es = require('event-stream')
var parser = JSONStream.parse(['rows', true, 'value') //emit parts that match this path (any element of the rows array) ---- Try added true after value
, req = request({url: 'http://isaacs.couchone.com/registry/_all_docs'})
, logger = es.mapSync(function (data) { //create a stream that logs to stderr,
console.error(data)
return data
})
// Ever needed to escape '\n' as '\\n'? This function does that for any character,
// using hex and/or Unicode escape sequences (whichever are shortest).
// Demo: http://mothereff.in/js-escapes
function unicodeEscape(str) {
return str.replace(/[\s\S]/g, function(character) {
var escape = character.charCodeAt().toString(16),
longhand = escape.length > 2;
return '\\' + (longhand ? 'u' : 'x') + ('0000' + escape).slice(longhand ? -4 : -2);
});
}
@bingeboy
bingeboy / list of 58,110 words
Created June 30, 2013 21:22
Words, Dictionary.
aardvark
aardwolf
aaron
aback
abacus
abaft
abalone
abandon
abandoned
abandonment
@bingeboy
bingeboy / app.js
Created June 29, 2013 22:07
BP for expressjs v3.x
var app = require('express')()
, server = require('http').createServer(app)
, express = require('express')
, http = require('http')
, port = 3000;
/*
* Express : Configure
@bingeboy
bingeboy / request-with-pipe.js
Created June 28, 2013 05:52
pipe with get call from request... quick and dirty!
//get image with request and pipe it to client.
var http = require('http');
var request = require('/usr/local/share/npm/lib/node_modules/request');
var server = http.createServer(function (req, res) {
request.get('http://www.1up.com/images/Elements/carouselNav.png').pipe(res);
});
server.listen(8000);
@bingeboy
bingeboy / app.js
Last active December 18, 2015 19:49
2012 Hackathon Olymipcs Entry
var fs = require('fs')
, http = require('http')
, util = require('util')
, path = require('path')
, Combinatorics = require('./combinatorics.js').Combinatorics
, request = require('request')
, ipContainer = [], url2Test, ipContainer2 = []
, cmb = Combinatorics.permutation(['0','1','8','16','46','74','96','106','109','126','127','186','192','255'], 4);
cmb = cmb.toArray();