Skip to content

Instantly share code, notes, and snippets.

View jdan's full-sized avatar
🐫
- : int -> int -> int = <fun>

Jordan Scales jdan

🐫
- : int -> int -> int = <fun>
View GitHub Profile
const K = x => ls => [x].concat(ls)
const add = ([fst, snd, ...rest]) => [fst + snd].concat(rest)
const mult = ([fst, snd, ...rest]) => [fst * snd].concat(rest)
const dup = ([fst, ...rest]) => [fst].concat([fst, ...rest])
const swp = ([fst, snd, ...rest]) => [snd, fst, ...rest]
const print = ([fst, ...rest]) => {
console.log(fst)
#lang racket
; Coin Flips!
; http://fivethirtyeight.com/features/can-you-survive-this-deadly-board-game/
;
; You place 100 coins heads up in a row and number them by position, with the coin all the way on the left No. 1 and the one on the rightmost edge No. 100. Next, for every number N, from 1 to 100, you flip over every coin whose position is a multiple of N. For example, first you’ll flip over all the coins, because every number is a multiple of 1. Then you’ll flip over all the even-numbered coins, because they’re multiples of 2. Then you’ll flip coins No. over all the coins, because every number is a multiple of 1. Then you’ll flip over all the even-numbered coins, because they’re multiples of 2. Then you’ll flip coins No. 3, 6, 9, 12 ... And so on.
;
; What do the coins look like when you’re done? Specifically, which coins are heads down?
; Heads is true, tails is false
@jdan
jdan / redux.rb
Created November 30, 2015 01:24
An implementation of Redux.createStore (https://github.com/rackt/redux) in Ruby
# redux.rb
#
# An implementation of Redux.createStore (github.com/rackt/redux) in Ruby
# Jordan Scales - http://thatjdanisso.cool
def assert(expr, message)
raise message unless expr
end
# Counter reducer
@jdan
jdan / README.md
Created October 28, 2015 15:25
React server-side example
$ node index.js
<p data-reactid=".1n79yas6h34" data-react-checksum="-427214699"><span data-reactid=".1n79yas6h34.0">Hello </span><span data-reactid=".1n79yas6h34.1">Jordan</span><span data-reactid=".1n79yas6h34.2">!</span></p>
/**
* $ node test.js
* 1
* 3
*/
var window;
window = {
blah: 1,
let assert = require("assert");
let mockDom = require("./mock-dom");
describe("Landmarks plugin", function() {
let dom = null;
let plugin = null;
before(function(done) {
mockDom.createDom(function(domObj) {
// Assign `dom` to the new created jsdom
@jdan
jdan / focus-styles.js
Created June 25, 2015 14:34
Some tests to determine if an element has a visual cue when focused
const VISUAL_INDICATOR_TESTS = [
function outline(style, focusStyle) {
// Fail if there are no differences in the element's outline
if (style.outline !== focusStyle.outline) {
return false;
}
// A focus outline that is not "none" is only valid if the outline
// also has a width
return focusStyle.outlineStyle !== "none" &&
@jdan
jdan / README.md
Created July 26, 2014 19:57
Isomer using @TooTallNate's ansi-canvas

output

@jdan
jdan / README.md
Last active August 29, 2015 14:01

domino

quick-n-dirty HTML markup generator

examples

var dom = require('./domino');
dom.ul.li.span.class('note')
set -g prefix C-a
unbind C-b
set-option -g default-shell /bin/zsh
set -sg escape-time 1
set -g base-index 1
set -g pane-base-index 1
bind r source-file ~/.tmux.conf \; display "Reloaded .tmux.conf!"