Skip to content

Instantly share code, notes, and snippets.

View eiriklv's full-sized avatar

Eirik L. Vullum eiriklv

View GitHub Profile
@eiriklv
eiriklv / church.js
Created September 20, 2016 22:06 — forked from arian/church.js
Church Numerals, Booleans, Pairs and Lists in JavaScript (ES6)
// conversions
let c2i = x => x(y => y + 1, 0)
let c2star = x => x(y => y + '*', '')
let c2b = x => x('True', 'False')
let c2a = xs => xs((y, ys) => [c2i(y)].concat(ys), [])
// numbers
let zero = (s,z) => z
let one = (s,z) => s(z)
@eiriklv
eiriklv / linux_fun.md
Created July 13, 2016 18:40 — forked from marianposaceanu/linux_fun.md
How to have some fun using the terminal.

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!
@eiriklv
eiriklv / README.md
Created July 13, 2016 17:37 — forked from joshdover/README.md
Idiomatic React Testing Patterns

Idiomatic React Testing Patterns

Testing React components seems simple at first. Then you need to test something that isn't a pure interaction and things seem to break down. These 4 patterns should help you use a pattern that is repeatable and readable for the type of test you need.

Setup

I recommend doing all setup in the most functional way possible. If you can avoid it, don't set variables in a beforeEach. This will help ensure tests are isolated and make things a bit easier to reason about. I use a pattern

// from the brilliant mind of sb
var _catch = Promise.prototype.catch;
Promise.prototype.catch = function () {
return _catch.call(this, function (err) { setTimeout(function () { throw(err); }, 0); });
}
@eiriklv
eiriklv / contest.md
Created January 5, 2016 21:05 — forked from brentvatne/contest.md
React.js Conf Contest

React.js Conf tickets, everyone wants them but we only have space for 400 people, and that includes speakers, organizers and everyone’s proud parents and grandparents! If you are into speaking and have time before December 13th, you should submit a 30 minute talk or 5 minute lightning talk proposal. If you’re more into writing than speaking or coding, ReactJSNews is giving away 1 ticket for the best blog post submission. But you probably like programming, so React Native Newsletter & Exponent are giving away two tickets for the best React Native apps made with Exponent! Of course, if you like speaking, writing and programming you should do all of the above.

Details of the contest

  • You make an “app” and publish it to Exponent. You don’t have to open source it, but people
@eiriklv
eiriklv / richhickey.md
Created November 29, 2015 21:50 — forked from prakhar1989/richhickey.md
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@eiriklv
eiriklv / Component.jsx
Last active November 27, 2015 13:50
Stating intent and using conventions
const React = require('react');
const MyComponent = React.createClass({
propTypes: {
},
getDefaultProps() {
},
var webpack = require('webpack');
var isProduction = process.env.NODE_ENV == 'production';
var plugins = [];
if (isProduction) {
plugins.push(new webpack.optimize.UglifyJsPlugin())
}
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@eiriklv
eiriklv / app.js
Last active October 19, 2015 15:55
Simple express example with body parsing
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var tokenChallenge = 'XXX';
/**
* Add automatic body parsing,
* so that you have req.body
* available inside the route handler