Skip to content

Instantly share code, notes, and snippets.

@dalelane
dalelane / nodejs_simple_webserver.js
Last active August 29, 2015 14:02
node.js simple web server (from http://nodejs.org/)
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
@dalelane
dalelane / nodejs_simple_file_db.js
Created June 15, 2014 20:55
Node.js with a SQLite database (based on sample from https://github.com/mapbox/node-sqlite3)
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('data/demodb01');
db.serialize(function() {
db.run("CREATE TABLE IF NOT EXISTS demo (runtime REAL)");
db.run("INSERT INTO demo (runtime) VALUES (?)", new Date().getTime());
db.each("SELECT runtime FROM demo", function(err, row) {
console.log("This app was run at " + row.runtime);
@dalelane
dalelane / nodejs_simple_express_api.js
Created June 15, 2014 21:02
Node.js and Express to make a few REST API endpoints (based on sample in http://expressjs.com/4x/api.html )
var express = require('express');
var app = express();
console.log("Registering endpoint: /");
app.get('/', function(req, res){
res.send('hello ROOT world');
});
console.log("Registering endpoint: /stubbed");
app.get('/stubbed', function(req, res){
@dalelane
dalelane / JaxbProblem.java
Last active August 29, 2015 14:03
JAXB problem... a simple re-create of a problem I'm having with unmarshalling using JAXB. Fixed working version is at https://gist.github.com/dalelane/983f278d2485d29a6ef4
package sandbox;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@dalelane
dalelane / keybase.md
Created July 10, 2014 22:14
keybase.io - proving my identity

Keybase proof

I hereby claim:

  • I am dalelane on github.
  • I am dalelane (https://keybase.io/dalelane) on keybase.
  • I have a public key whose fingerprint is 0950 6D8F 8321 BEC7 CD01 8CF5 4872 0994 FE4A ECD8

To claim this, I am signing this object:

@dalelane
dalelane / graceparse.py
Last active August 29, 2015 14:08
A roman numeral converter - http://dalelane.co.uk/blog/?p=3244
# Converting roman numerals into numbers
#
# A homework helper by Dale and Grace Lane
# 1-Nov-2014
#
# http://dalelane.co.uk/blog/?p=3244
#
# some simple helper functions to make
@dalelane
dalelane / sample.js
Created January 25, 2015 18:46
Sample output from extract-relationships
{ entities:
[ { type: 'PERSON',
class: 'SPC',
level: 'NAM',
mentions:
[ { mtype: 'NAM',
role: 'PERSON',
class: 'SPC',
text: 'Dale Lane',
location: { begin: 0, end: 8, 'head-begin': 0, 'head-end': 8 } },
/**
* Downloads the contents of a news story, then use the
* Watson Relationship Extraction service to identify
* the names of all the people mentioned in the story.
*
* @author Dale Lane
*/
var async = require('async');
var unfluff = require('unfluff');
@dalelane
dalelane / demo-machine-translation.sh
Last active August 29, 2015 14:14
Running Watson Machine Translation service from curl
# Get these from Bluemix and set as environment variables
# $BLUEMIX_WATSON_MACHTRANS_USER
# $BLUEMIX_WATSON_MACHTRANS_PASS
# $BLUEMIX_WATSON_MACHTRANS_URL
export FORMAT="rt=text" # or json or xml
export LANG_FROM="enus"
export LANG_TO="frfr"
@dalelane
dalelane / rnn_dalelane.md
Created July 26, 2015 11:40
Tweets generated by a Recurrent Neural Network trained on tweets by @dalelane

@rnn_dalelane

Inspired by https://medium.com/@samim/obama-rnn-machine-generated-political-speeches-c8abd18a2ea0 I tried training a recurrent neural network (RNN) for myself.

I exported every tweet I've ever posted as @dalelane, and used that as the training text. The idea was to see whether it would generate new tweets that looked like they could be things that I had written.

This is just a first quick attempt, with no attempts to tweak or tune the generation of the training model, or modify any other settings.

This is the kind of thing it's currently outputting: