This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2008 Apple Inc. All Rights Reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions | |
* are met: | |
* 1. Redistributions of source code must retain the above copyright | |
* notice, this list of conditions and the following disclaimer. | |
* 2. Redistributions in binary form must reproduce the above copyright | |
* notice, this list of conditions and the following disclaimer in the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Person = function(name, age) { | |
if (!(this instanceof Person)) return new Person(name, age); | |
return { name, age }; | |
} | |
var data = [ | |
Person('John', 29), | |
Person('Helen', 18), | |
Person('Tom', 59) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
linear extrapolate(interpolate) property based on viewport units | |
@example: | |
// extrapolating | |
.example { | |
.linear(height, 320px, 100px, 480px, 128px); | |
} | |
result: | |
.example { | |
height: calc(17.5vw + 44px); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn coin-exchange [amount, coins] | |
(cond (= amount 0) 1 | |
(< amount 0) 0 | |
(empty? coins) 0 | |
(= (count coins) 1) (if (= (rem amount (first coins)) 0) 1 0) | |
:else (let [[coin & remaining-coins] coins] | |
(+ (coin-exchange (- amount coin) coins) | |
(coin-exchange amount remaining-coins))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn calc-spiral-coord [index] | |
(defn iterate [cell direction-index index steps increase-steps] | |
(defn add-vectors [a b] | |
[(+ (first a) (first b)) (+ (second a) (second b))]) | |
(defn get-direction [i] (nth [[1 0] [0 1] [-1 0] [0 -1]] (mod i 4))) | |
(defn walk [cell direction steps] | |
(if (= steps 0) | |
cell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This is the main Apache server configuration file. It contains the | |
# configuration directives that give the server its instructions. | |
# See <URL:http://httpd.apache.org/docs/2.2/> for detailed information. | |
# In particular, see | |
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html> | |
# for a discussion of each configuration directive. | |
# | |
# | |
# Do NOT simply read the instructions in here without understanding |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var no = require('nommon'); | |
var promise = new no.Promise(); | |
promise | |
.then(function() { | |
console.log(10); | |
}) | |
.then(function() { | |
console.log(10); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fsm = (function() { | |
function transition(name, from, to) { | |
this.transitions[name] = {name: name, from: from, to: to}; | |
return this; | |
} | |
function init(state) { | |
this.initState = state; | |
return this; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create d3 chart generator | |
* | |
* @param {Function} render function with parameters vis(d3 selection), width, height, and config context | |
* | |
* @returns {Function} chart | |
*/ | |
var createChartGenerator = function(render) { | |
var chart; | |
var config = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
#canvas { | |
width: 500x; | |
height: 300px; | |
} |