Skip to content

Instantly share code, notes, and snippets.

View modernserf's full-sized avatar

Justin Falcone modernserf

View GitHub Profile
@modernserf
modernserf / DietActiveRecord.php
Created July 6, 2013 05:02
very lightweight implementation of something that resembles Rails' implementation of ActiveRecord.
class DietActiveRecord {
public static function all( $select = null ){
$self = get_called_class();
$query = 'SELECT '. $self::select_string($select) .
' FROM '. $self::$table_name;
return $self::query($query, null, true);
}
@modernserf
modernserf / sass-linter.coffee
Created October 15, 2013 12:58
Basic SASS linter
fs = require 'fs'
file_path = __INSERT_FILE_PATH_HERE__
fs.readFile file_path, {encoding: 'utf-8'}, (err, data)->
# global document object
doc = {
tab_size: 2
lines: data.split("\n")
}

Keybase proof

I hereby claim:

  • I am modernserf on github.
  • I am modernserf (https://keybase.io/modernserf) on keybase.
  • I have a public key whose fingerprint is 5D74 D20E 86E2 2415 4BDB F497 CBD8 98BF E95C B0A5

To claim this, I am signing this object:

@modernserf
modernserf / ex1.js
Last active August 29, 2015 14:00 — forked from getify/ex1.js
// using asynquence+iterable sequences
var domready;
ASQ()
// wait for `domready` before we proceed
.seq( domready = ASQ.iterable() )
.gate(
requestJSON( "foo.json" ),
requestJSON( "bar.json" )
@modernserf
modernserf / gist:e09ba3aa9e5788803f97
Created January 30, 2015 22:00
Debounce Promise
function debouncePromise (func, wait){
var later, boundFn, promise, min = 10;
var bind = function (fn, ctx, args){
boundFn = function (done){
done(fn.apply(ctx, args));
};
};
var reset = function (){ promise = null; };
"use strict";
import React from "react";
import rebound from "rebound";
const springSystem = new rebound.SpringSystem();
const SpringGroup = React.createClass({
getDefaultProps (){
return {
; TODO: infix syntax?
; Not everything is a set, but assignment is implicitly to a set.
(def foo 1)
; equivalent to
(def foo (Set 1))
(def foo 1 2)
; equivalent to
(def foo (Set 1 2))
@modernserf
modernserf / hashtags-for-humans.md
Last active August 29, 2015 14:21
Hashtags for Humans

Guess Who?

  • maybe don't even play the game? have two computer players against each other go very quickly
  • what faces do i use? emoji?

Hashtags

Web 2.0

  • tags vs categories in blogs
    • tag clouds
  • folksonomy
@modernserf
modernserf / protocols.js.md
Last active March 18, 2024 12:29
Protocols/Interfaces in JavaScript with Symbols and bind syntax

Interfaces and protocols

ES2015, The newest iteration of JavaScript, introduces a ton of new features, types, and syntactic sugar. Those have all been explored pretty thoroughly, but the one that has the greatest implications for JavaScript are iterators; not the construct in itself but the use of the Iterator protocol.

Iterators are made possible by two new features: symbols and generators. Iterators are not necessarily a feature on their own, but rather a set of conventions around symbols and generators:

Given that JavaScript does not have interfaces, Iterable is more of a convention:

Source: A value is considered iterable if it has a method whose key is the symbol Symbol.iterator that returns a so-called iterator. The iterator is an object that returns values via its method next(). We say: it enumerates items, one per method call.

@modernserf
modernserf / stack.js
Last active August 29, 2015 14:26
Forth-like stack operations with ES6 iterators
// stackify - take function with (a... -> [b]) signature
// return unused stack with results on top
function S (fn) {
return function* (...args) {
let iter = this;
let ln = fn.length - args.length;
yield* fn.apply(null,args.concat(takeMutable(iter,ln)))
yield* iter
}
}