Skip to content

Instantly share code, notes, and snippets.

View teropa's full-sized avatar

Tero Parviainen teropa

View GitHub Profile

On Lisp

Instead of just writing your program in Lisp, you can write your own language on Lisp, and write your program in that.

It is possible to write programs bottom-up in any language, but Lisp is the most natural vehicle for this style of programming. In Lisp, bottom-up design is not a special technique reserved for unusually large or difficult programs. Any substantial program will be written partly in this style. Lisp was meant from the start to be an extensible language. [...]

@teropa
teropa / angular_toc.md
Created November 11, 2013 18:39
A preliminary table of contents for "Build Your Own AngularJS"

0. Project Setup

Part 1: Scopes

1. Scopes and Digest

2. Scope Inheritance

3. Watching Collections

Part 2: Expressions And Filters

4. Lexing Expressions

5. Parsing Expressions

6. Expressions On The Scope

7. Creating Filters

@teropa
teropa / res.clj
Created May 25, 2012 12:06
Reservation puzzle, one possible solution
(def seats (-> (repeat 5000 nil) vec ref))
(def clerks (repeatedly 10 #(agent 0)))
(defn available-indexes
"Given a sequence of seats, returns a (lazy)
sequence of the indexes of the available seats.
This is purely functional and doesn't know anything
about refs or agents"
[seats]
(keep-indexed
@teropa
teropa / minicompiler.js
Created May 9, 2015 18:02
Code for "Inside The AngularJS Directive Compiler"
'use strict';
function $CompileProvider($provide) {
var directives = {};
this.directive = function(name, factory) {
if (!directives.hasOwnProperty(name)) {
directives[name] = [factory];
$provide.factory(
@teropa
teropa / frontend_ops.md
Created November 11, 2014 10:19
Why Frontend Needs Ops - Resources
@teropa
teropa / no_migration_path.md
Last active August 29, 2015 14:08
Angular 2.0's "No Migration Path": A Story in Three Acts

Act 1

Igor Minar at ng-europe, October 23:

Once 2.0 is ready, then we’ll figure out what’s the best way to migrate. At this point we’re really trying to create the best 2.0 ever, and once we know what that is, we’ll go back and see what is the best migration path. Because if we run it the other way around, that would constrain what we can do with 2.0.

Act 2

David Iffland, InfoQ, October 27:

@teropa
teropa / q_now.js
Created May 20, 2014 14:01
$q.now() - an immediately resolved promise oneliner for Angular.js
module.config(['$provide', function($provide) {
// Add a method to $q that returns a promise resolved to
// the given value. Use as: $q.now(42)
$provide.decorator('$q', ['$delegate', function($delegate) {
$delegate.now = function(value) {
var d = $delegate.defer();
d.resolve(value);
return d.promise;
};
@teropa
teropa / d-fens.js
Created May 7, 2014 09:36
Angular.js DI example
// Framework
function createInjector() {
var instanceCache = {};
var providerCache = {};
function constant(key, value) {
instanceCache[key] = value;
}
{ "names": [ "Anne", "Bette", "Cate", "Dawn",
"Elise", "Faye", "Ginger", "Harriot",
"Izzy", "Jane", "Kaye", "Liz",
"Maria", "Nell", "Olive", "Pat",
"Queenie", "Rae", "Sal", "Tam",
"Uma", "Violet", "Wilma", "Xana",
"Yvonne", "Zelda",
"Abe", "Billy", "Caleb", "Davie",
"Eb", "Frank", "Gabe", "House",
"Icarus", "Jack", "Kurt", "Larry",