Skip to content

Instantly share code, notes, and snippets.

View lanceharper's full-sized avatar

Lance Harper lanceharper

View GitHub Profile
@lanceharper
lanceharper / fold.js
Last active December 3, 2015 01:06 — forked from kpuputti/fold.js
Functional acrobatics using folds in JavaScript.
/*eslint-env es6 */
// Inspired by the paper "A tutorial on the universality and
// expressiveness of fold" by Graham Hutton (available at
// http://www.cs.nott.ac.uk/~gmh/fold.pdf), implementing some generic
// list handling functions in JavaScript in terms of `fold`.
// Personally I had an enlightnening moment when I realised the
// beautiful interplay of cons lists and foldr during the FP101x
// Haskell course. JavaScript's syntax doesn't make this very apparent
@lanceharper
lanceharper / gulp-layout.js
Created November 11, 2014 06:55
layout with consolidate and gulp
var consolidate = require('consolidate');
var through = require('through2');
var gutil = require('gulp-util');
var PluginError = gutil.PluginError;
const PLUGIN_NAME = 'gulp-layout';
function gulpLayout(opts) {
opts = opts || {};
@lanceharper
lanceharper / pipe-bluebird.js
Last active August 29, 2015 14:05
pipe with bluebird
var Promise = require("bluebird");
exports.pipe = function (source, sink) {
var resolve, reject;
return new Promise(function(resolve_, reject_) {
resolve = resolve_;
reject = reject_;
source
.on("end", resolve)
.on("error", reject)
indexClass: function () {
return 'panel-' + (this.get('contentIndex') + 1);
}.property()
@lanceharper
lanceharper / package.json
Created February 25, 2013 19:55
package.json with grunt and express
var express = require('express');
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 8080);
app.use(express.logger('dev'));
});
@lanceharper
lanceharper / app.js
Created February 15, 2013 21:08
dabble with socket.io
var app = require('express')();
app.set('port', process.env.PORT || 80);
var server = require('http').createServer(app)
, io = require('socket.io').listen(server);
server.listen(app.get('port'));
app.get('/', function (req, res) {
public class BlogPostCountByAuthorTask : MapReduceTask<BlogPost, BlogPostCountByAuthorTask.PostCountResult>
{
public class PostCountResult
{
public string AuthorName { get; set; }
public int PostCount { get; set; }
}
public BlogPostCountByAuthorTask()
{
@lanceharper
lanceharper / Widget.cs
Created October 19, 2012 23:16
Test the widget
namespace Widget
{
public interface IDeduceable
{
bool Deduce();
}
public class FooA
{
public FooA(FooB fb) { }
@lanceharper
lanceharper / ChildWithCondition.cs
Created May 13, 2012 19:22
Demo of a RavenDB index used to find entities with the existence of children objects where at least one child is active.
namespace ChildConditionDemo
{
public class ChildWithCondition
{
public string Id { get; set; }
public string Name { get; set; }
public bool Active { get; set; }
}
}
@lanceharper
lanceharper / BabySittingTransaction.cs
Created March 5, 2012 20:07
Using AbstractMultiMapIndexCreationTask to replace left joins in SQL
public class BabySittingTransaction : DomainBase
{
public virtual int ChildrenWatched { get; set; }
public virtual int Hours { get; set; }
public virtual string SittingProvider { get; set; }
public virtual string SittingReceiver { get; set; }