Skip to content

Instantly share code, notes, and snippets.

View bxjx's full-sized avatar

Bridger Rossiter bxjx

  • Newcastle, Australia
View GitHub Profile
@bxjx
bxjx / gist:7001437
Created October 16, 2013 01:49
Example of using gramophone ngrams as input into Natural's TF-IDF function. It's adapted from the example in the Natural docs. NOTE that all arguments to the tfidf methods must be arrays. If they are strings, the tfidf object will run the default tokenizer over the argument. I might submit a pull request to natural so that `natural.TfIdf` could …
var natural = require('natural'),
TfIdf = natural.TfIdf,
tfidf = new TfIdf();
var gramophone = require('gramophone');
var docs = [
'this document is about node programming language.',
'this document is about ruby programming language.',
'this document is about the ruby programming language and node programming language.',
@bxjx
bxjx / gist:968173
Created May 12, 2011 08:33
render js templates in rails
# in controller:
# @item = JsTemplate.new('item', :renderer => :mustache)
# in view:
# %[email protected]
# rendered:
# {{item.user.name}}
class JsTemplate
def initialize(id, options = {})
parents = options[:parents] || {}
var express = require('express'),
request = require('request'),
BufferList = require('bufferlist').BufferList,
sys = require('sys');
var app = express.createServer(
express.logger(),
express.bodyDecoder()
);
var http = require('http');
function getXml(cb){
var host = 'node.geht-ab.net';
var url = '/original.php'
var server = http.createClient(80, host);
var request = server.request('GET', url, { Host: host });
request.end();
request.on('response', function (response) {
response.setEncoding("binary");
var body = "";