Navigation Menu

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
@bingeboy
bingeboy / 0_reuse_code.js
Created March 7, 2014 20:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bingeboy
bingeboy / editor.js
Created February 28, 2014 04:20 — forked from Floby/editor.js
var fs = require('fs');
var child_process = require('child_process');
var spawn = child_process.spawn;
function openEditor(file) {
var cp = spawn(process.env.EDITOR, [file], {
customFds: [
process.stdin,
process.stdout,
process.stderr
#!/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 / 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>');
});
});
// 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);
});
}