Skip to content

Instantly share code, notes, and snippets.

@onyxfish
onyxfish / example1.py
Created March 5, 2010 16:51
Basic example of using NLTK for name entity extraction.
import nltk
with open('sample.txt', 'r') as f:
sample = f.read()
sentences = nltk.sent_tokenize(sample)
tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences]
tagged_sentences = [nltk.pos_tag(sentence) for sentence in tokenized_sentences]
chunked_sentences = nltk.batch_ne_chunk(tagged_sentences, binary=True)
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active July 21, 2024 01:20
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@bivas
bivas / NotNullCacheEventListener.java
Created September 6, 2011 07:09
EhCache event listener for preventing caching of null values in data store
package com.example.cache;
import net.sf.ehcache.CacheException;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import net.sf.ehcache.event.CacheEventListener;
final class NotNullCacheEventListener implements CacheEventListener {
public static final CacheEventListener INSTANCE = new NotNullCacheEventListener();
@mklabs
mklabs / pre-commit
Created September 28, 2011 01:25
npm test as git/hg hooks
#!/usr/bin/env node
var npm = nrequire('npm');
if (npm) return npm.load(function(e, n) {
this.commands.test(function(e) {
process.exit(e ? 1 : 0);
});
});
@max747
max747 / gist:1280444
Created October 12, 2011 06:30
java-diff-utils usage example
public class DiffTest {
@Test
public void parseDiffToSideBySideView() throws IOException {
List<String> lines = IOUtils.readLines(FileUtils.openInputStream(new File("httpd.conf.diff")));
Patch diff = DiffUtils.parseUnifiedDiff(lines);
DiffRowGenerator.Builder builder = new DiffRowGenerator.Builder();
builder.showInlineDiffs(false);
DiffRowGenerator generator = builder.build();
@entaroadun
entaroadun / gist:1653794
Created January 21, 2012 20:10
Recommendation and Ratings Public Data Sets For Machine Learning

Movies Recommendation:

Music Recommendation:

@paolorossi
paolorossi / html5-video-streamer.js
Created March 7, 2012 13:21
Node.js HTML5 video streamer
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@BinaryMuse
BinaryMuse / phantom.coffee
Created April 13, 2012 18:33
Take screenshots with Phantom.js from Node.js
#!/usr/bin/env coffee
# Call the program with: coffee phantom.coffee http://url.to/screengrab
phantom = require 'phantom' # npm install phantom
child_process = require 'child_process'
url = process.argv[2]
createScreenshot = (page, filename) ->
@hectorcorrea
hectorcorrea / webserver.js
Last active June 29, 2024 12:51
web server in node.js
// A very basic web server in node.js
// Stolen from: Node.js for Front-End Developers by Garann Means (p. 9-10)
var port = 8000;
var serverUrl = "127.0.0.1";
var http = require("http");
var path = require("path");
var fs = require("fs");
var checkMimeType = true;