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
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
})
@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,
@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 / sym link for iterm2.sh
Created July 3, 2013 20:18
Sym link for iterm2
#!/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
// print process.argv
process.argv.forEach(function (val, index, array) {
console.log(index + ': ' + val);
});
@bingeboy
bingeboy / node manifest joyent
Created July 13, 2013 07:35
joyent hello world node xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="node-hello-world-service">
<service name="site/node-hello-world-service" type="service" version="1">
<create_default_instance enabled="true"/>
<single_instance/>
<dependency name="network" grouping="require_all" restart_on="refresh" type="service">
@bingeboy
bingeboy / jsdom.js
Created July 18, 2013 03:36
jsdom loading jquery and loading a file.
var http = require('http')
, fs = require('fs')
, util= require('util');
var jsdom = require("jsdom")
, $ = require("jquery");
jsdom.env(
@bingeboy
bingeboy / vimrc.vim
Created July 19, 2013 09:03
Quick .vimrc for webservers
set nocompatible " be iMproved
filetype off " required!
"Allow F2 key to toggle paste from outside of vim and retain indents
set pastetoggle=<F2>
"Set up the clipboard to be shared across termi windows"
set clipboard=unnamed
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
var http = require('http')
, fs = require('fs')
, request = require('request')
, jsdom = require("jsdom");
//Description: Create a file to pipe to. (this could also be added to a db if recommended.)
request('http://google.com').pipe(fs.createWriteStream('backup.html'))
//Description: use jsdom for DOM scrapping as needed dom needed. Alternatively this could be stored to DB.
jsdom.env({