Skip to content

Instantly share code, notes, and snippets.

Richard Marr richmarr

Block or report user

Report or block richmarr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
richmarr / greenhouse.ino
Last active Feb 17, 2017
Arduino code my Dad wrote to automate his greenhouse lamps
View greenhouse.ino
int lightPin0 = 0;
int lightPin1 = 1;
int relayPin = 2;
int night = 1000;
int sunny = 8000;
float filter = 0.0;
void setup() {
View gist:286ba9b0367e667765a0
$.fn.parsley.defaults = {
// basic data-api overridable properties here..
inputs: 'input, textarea, select' // Default supported inputs.
, excluded: 'input[type=hidden], :disabled' // Do not validate input[type=hidden] & :disabled.
, trigger: false // $.Event() that will trigger validation. eg: keyup, change..
, animate: true // fade in / fade out error messages
, animateDuration: 300 // fadein/fadout ms time
, focus: 'first' // 'fist'|'last'|'none' which error field would have focus first on form validation
, validationMinlength: 3 // If trigger validation specified, only if value.length > validationMinlength
, successClass: 'has-success' // Class name on each valid input
richmarr / gist:7747115
Created Dec 2, 2013
Example test that reads every Express route and verifies that every value pulled from `req.query`, `req.param` or `req.body` has been cleaned using `express-validator` and that each mother at least calls to `req.validationErrors()` to inspect what's wrong. This example assumes that all routes are exposed as a single package, e.g. `routes.user.ha…
View gist:7747115
var routes = require('../routes'),
assert = require('assert');
describe('routes', function(){
it("should exist", function(done){
richmarr / algo.js
Created Nov 5, 2013
Quick Node.js speed test for different crypto algorithms exposed through OpenSSL. Don't forget, speed == good but speed !== good
View algo.js
var crypto = require('crypto'),
algos = crypto.getCiphers(),
testString = 'something to match, something to match, something to match, something to match, something to match '+algos.join("#"),
password = '12345asdfgh',
ciphertextEncoding = 'binary',
cleartextEncoding = 'utf8',
iterations = 1000;
algos.forEach(function( algorithm ){
richmarr / gist:3944934
Created Oct 24, 2012 — forked from mattb/gist:3888345
Some pointers for Natural Language Processing / Machine Learning
View gist:3944934

Here are the areas I've been researching, some things I've read and some open source packages...

Nearly all text processing starts by transforming text into vectors:

Often it uses transforms such as TFIDF to normalise the data and control for outliers (words that are too frequent or too rare confuse the algorithms):

Collocations is a technique to detect when two or more words occur more commonly together than separately (e.g. "wishy-washy" in English) - I use this to group words into n-gram tokens because many NLP techniques consider each word as if it's independent of all the others in a document, ignoring order:

richmarr / threadpool.groovy
Created Apr 30, 2012
Convenience defer technique for passing execution to a thread pool in Groovy
View threadpool.groovy
import java.util.concurrent.Callable
import java.util.concurrent.Executors
def THREADS = 2
def pool = Executors.newFixedThreadPool(THREADS)
def done = 0
def defer = { closure ->
pool.submit( closure as Callable )
richmarr /
Created Mar 28, 2012 — forked from kohlmeier/
Bayes net example in Python with Khan Academy data
#!/usr/bin/env python
from numpy import asmatrix, asarray, ones, zeros, mean, sum, arange, prod, dot, loadtxt
from numpy.random import random, randint
import pickle
MISSING_VALUE = -1 # a constant I will use to denote missing integer values
def impute_hidden_node(E, I, theta, sample_hidden):
richmarr / streaming-xml-standardiser.groovy
Created Feb 21, 2012
Streaming XML standardiser implementation in Groovy using NUX. Allows feeds to be processed via DB configuration rather than XSL
View streaming-xml-standardiser.groovy
package richmarr.xml.example
import org.xml.sax.InputSource
import nu.xom.*
import nux.xom.xquery.*
// this would normally be pulled from a database
def config = [
item : "/xpath/to/item/elements",
fields : [
richmarr / index.js
Created Aug 3, 2011
Export all JS modules in a directory as submodules
View index.js
I found it handy to reduce the amount of manual require() lines in a big
project by grouping small modules together like below.
If you put this code into "index.js" then it'll pick up any other
JS modules in that directory and expose them as sub-modules.
- Any exports in *this* module would be myPackage.exportName
- Any exports in other modules would be myPackage.moduleName.exportName
You can’t perform that action at this time.