Skip to content

Instantly share code, notes, and snippets.

Lance Harper lanceharper

Block or report user

Report or block lanceharper

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
@lanceharper
lanceharper / fold.js
Last active Dec 3, 2015 — forked from kpuputti/fold.js
Functional acrobatics using folds in JavaScript.
View fold.js
/*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 Nov 11, 2014
layout with consolidate and gulp
View gulp-layout.js
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 Aug 29, 2015
pipe with bluebird
View pipe-bluebird.js
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)
View indexClass.js
indexClass: function () {
return 'panel-' + (this.get('contentIndex') + 1);
}.property()
@lanceharper
lanceharper / package.json
Created Feb 25, 2013
package.json with grunt and express
View package.json
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 Feb 15, 2013
dabble with socket.io
View app.js
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) {
View BlogPostCountByAuthorTask
public class BlogPostCountByAuthorTask : MapReduceTask<BlogPost, BlogPostCountByAuthorTask.PostCountResult>
{
public class PostCountResult
{
public string AuthorName { get; set; }
public int PostCount { get; set; }
}
public BlogPostCountByAuthorTask()
{
View Widget.cs
namespace Widget
{
public interface IDeduceable
{
bool Deduce();
}
public class FooA
{
public FooA(FooB fb) { }
@lanceharper
lanceharper / ChildWithCondition.cs
Created May 13, 2012
Demo of a RavenDB index used to find entities with the existence of children objects where at least one child is active.
View ChildWithCondition.cs
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 Mar 5, 2012
Using AbstractMultiMapIndexCreationTask to replace left joins in SQL
View BabySittingTransaction.cs
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; }
You can’t perform that action at this time.