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
DEBUG: url: { href: 'http://investing.businessweek.com/research/stocks/snapshot/snapshot.asp?capId=101648'
, protocol: 'http:'
, slashes: true
, host: 'investing.businessweek.com'
, hostname: 'investing.businessweek.com'
, search: '?capId=101648'
, query: 'capId=101648'
, pathname: '/research/stocks/snapshot/snapshot.asp'
}
DEBUG: url: { href: 'http://../../stocks/private/snapshot.asp?privcapId=101648'
var f = require('./test/f');
console.log('test: ' + __dirname);
- if (logged_in)
.loggedin You are logged in
- if (!(logged_in))
.loggedin You are not logged in
@ncb000gt
ncb000gt / elasticsearch-index-config.js
Created March 10, 2011 15:40
Elastic search configuration with a custom analyzer.
{
settings: {
number_of_shards: 5,
number_of_replicas: 1,
"index" : {
"analysis" : {
"analyzer" : {
"html" : {
filter: [ 'standard', 'lowercase', 'stop', 'asciifolding' ],
"tokenizer" : "standard",
@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);
function OTest() {
console.log('test');
}
module.exports = OTest;
@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);
}
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;
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,
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>,