Skip to content

Instantly share code, notes, and snippets.

View eiriklv's full-sized avatar

Eirik L. Vullum eiriklv

View GitHub Profile
@eiriklv
eiriklv / view.jsx
Created June 7, 2014 11:18 — forked from insin/view.jsx
/**
* JSX version of https://github.com/jpmonette/todomvc-mithril/blob/1d627f1d5dc0890d0a99cdcb16d09387f68f6df0/js/views/todo-view.js
* Assumes the use of the vanilla JSX Transformer and an "mshim" object to translate tag calls to the format m() expects.
* @jsx mshim
*/
'use strict';
var m = require('mithril')

Leader presumes follower. Follower presumes choice. One who is coerced to the purposes, objectives, or preferences of another is not a follower in any true sense of the word, but an object of manipulation. Nor is the relationship materially altered if both parties voluntarily accept the dominance of one by the other. A true leader cannot be bound to lead. A true follower cannot be bound to follow. The moment they are bound they are no longer leader or follower. If the behavior of either is compelled, whether by force, economic necessity, or contractual arrangement, the relationship is altered to one of superior/subordinate, manager/employee, master/servant, or owner/slave. All such relationships are materially different from leader/follower…

A vital question is how to insure that those who lead are constructive, ethical, open, and honest. The answer is to follow those who behave in that manner. It comes down to both individual and collective sense of where and how people choose to be led. In a very real sens

#!/usr/bin/python
# This script is a replacement for the OS X "say" command.
# Built on a Raspberry Pi :)
# to install:
# sudo apt-get install curl mpg123
# sudo curl https://gist.github.com/raw/4412815 > say; chmod a+x say; sudo mv say /usr/bin/
# say hello world
import subprocess
@eiriklv
eiriklv / mp3.js
Created June 19, 2014 16:15 — forked from dtrce/mp3.js
var http = require('http'),
fileSystem = require('fs'),
path = require('path')
util = require('util');
http.createServer(function(request, response) {
var filePath = 'path_to_file.mp3';
var stat = fileSystem.statSync(filePath);
response.writeHead(200, {

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

// Just paste this into the console on http://www.jshint.com/docs/options/
(function() {
var i, row, link, span, extraCol, checkbox, value;
var rows = document.querySelectorAll('table.options tr');
var links = document.querySelectorAll('table.options a');
// add checkboxes
for (var i = 0; i < rows.length; i++) {
row = rows[i];
// Example usage:
// deepPopulate(blogPost, "comments comments._creator comments._creator.blogposts", {sort:{title:-1}}, callback);
// Note that the options get passed at *every* level!
// Also note that you must populate the shallower documents before the deeper ones.
function deepPopulate(doc, pathListString, options, callback) {
var listOfPathsToPopulate = pathListString.split(" ");
function doNext() {
if (listOfPathsToPopulate.length == 0) {
// Now all the things underneath the original doc should be populated. Thanks mongoose!
callback(null,doc);
@eiriklv
eiriklv / main.js
Created August 25, 2014 14:34 — forked from donnut/main.js
var mongoose = require('mongoose'),
assert = require('assert')
mongoose.connect('localhost/mydb');
var Schema = mongoose.Schema;
var ContainerSchema = new Schema({
name: String,
})
// mongoose v3.6.18
//
var mongoose = require('mongoose');
mongoose.connect('localhost/mydb');
var Schema = mongoose.Schema;
var MasterSchema = new Schema({
name: String,
});