Skip to content

Instantly share code, notes, and snippets.

View ncb000gt's full-sized avatar
💭
Slapping keyboard...

Nick Campbell ncb000gt

💭
Slapping keyboard...
View GitHub Profile
@ncb000gt
ncb000gt / package.json
Created August 19, 2011 14:25
NPM package.json Files
{
"name": "packagename",
"description": "A description of your project...even though you wont necessarily be putting it in NPM.",
"version": "0.0.1",
"author": "Your Name Here (http://github.com/user)",
"engines": { "node": ">= 0.4.11" },
"repository": {
"type": "git",
"url": "http://github.com/user/project.git"
},
@ncb000gt
ncb000gt / remove-all-riak.js
Created May 21, 2011 15:33
Remove all items from a bucket in riak with riak-js.
var db = require('riak-js').getClient({port: 8091});
console.log(process.argv);
db.keys(process.argv[2], function(err, keys) {
if (err) console.log(err);
keys.forEach(function(key) {
db.remove(process.argv[2], key, function(err) {
if (err) console.log(err);
console.log("Removed: " + key);
@ncb000gt
ncb000gt / gist:982282
Created May 20, 2011 03:15
riak-js error.
/usr/local/lib/node_modules/riak-js/lib/utils.js:84
target[k] = d.value;
^
RangeError: Maximum call stack size exceeded
@ncb000gt
ncb000gt / work-hard.js
Created April 25, 2011 14:00
I swear I'm working...hard.
/*
* Goto -> http://duiker101.tk/hackertyper/
* Open a console
* Copy and paste the following
* Fullscreen your window
* ?
* Profit
*/
var eventEl = document.getElementById('console');
node
> module
{ id: 'repl',
exports:
{ writer: [Function],
REPLServer: [Function: REPLServer],
start: [Function],
repl: { context: [Object], bufferedCommand: 'module\n', outputStream: [Object], inputStream: [Object], prompt: '> ', rli: [Object], commands: [Object] } },
parent: undefined,
filename: <current path>,
function serve_cgi(filename, res, get, post, method, vhost, port, pinfo, get, sname, uri, droot) {
var env = {
CONTENT_LENGTH: post.length,
CONTENT_TYPE: 'application/x-www-form-urlencoded',
DOCUMENT_ROOT: droot,
GATEWAY_INTERFACE: 'CGI/1.1',
HTTP_HOST: vhost,
QUERY_STRING: get,
REDIRECT_STATUS: '200',
REQUEST_METHOD: method,
var http = require('http'),
util = require('util');
var options = {
host: 'api.twitter.com',
port: 80,
path: '/1/statuses/public_timeline.json'
};
var chunks = [],
total = 0;
@ncb000gt
ncb000gt / drop_hbase_tables.js
Created March 17, 2011 18:53
Drop hbase tables - both will remove, the JS version is async (concurrent disables and drops).
var spawn = require('child_process').exec,
exports = module.exports;
exports.getTables = function(cb) {
var lines = [],
get = spawn('echo "list" | ./hbase shell',
function (err, stdout, stderr) {
if (err) {
console.log(err);
}
function OTest() {
console.log('test');
}
module.exports = OTest;
@ncb000gt
ncb000gt / get.js
Created March 10, 2011 18:43
Node 0.4.x get example (from docs)
var http = require('http');
var options = {
host: 'www.google.com',
port: 80,
path: '/index.html'
};
http.get(options, function(res) {
console.log("Got response: " + res.statusCode);