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 days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; | |
var shortDays = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; | |
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"]; | |
var shortMonths = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; | |
function zeropad(n) { | |
return n > 9 ? String(n) : "0" + String(n); | |
} | |
function twelveHour(t) { |
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
class Array | |
# Pick +n+ random items from this array. | |
def pick_random(n=1) | |
sort_by { rand }.slice(0...n) | |
end | |
end |
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
// Event handling functions modified from originals by Dean Edwards. | |
// http://dean.edwards.name/my/events.js | |
var guid = 1; | |
// Adds an event handler to the given element. The handler will be called | |
// in the context of the element with the event object as its only argument. | |
function addEvent(element, type, handler) { | |
if (element.addEventListener) { | |
element.addEventListener(type, handler, false); |
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
// Returns the intersection of two sorted arrays of numbers or strings. | |
function intersectArrays(a, b) { | |
var array = [], ai = 0, alen = a.length, bi = 0, blen = b.length; | |
while (ai < alen && bi < blen) { | |
if (a[ai] < b[bi]) { | |
ai++; | |
} else if (a[ai] > b[bi]) { | |
bi++; | |
} else { |
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
def a(*args, &block) | |
puts "a got a block" if block_given? | |
end | |
def b(*args, &block) | |
puts "b got a block" if block_given? | |
end | |
# In this call, `b' is called with the block and the | |
# return value is given to `a' as an argument. |
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 JSONStream = require('jsonstream') | |
var es = require('event-stream') | |
function handleRequest(data, callback) { | |
callback(null, JSON.stringify(data) + '\n') | |
} | |
process.stdin | |
.pipe(JSONStream.parse()) | |
.pipe(es.map(handleRequest)) |
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 Firebase = require('firebase'); | |
var baseRef = new Firebase('https://my-firebase.firebaseio.com'); | |
function getSnapshotValue(snapshot) { | |
return snapshot.val(); | |
} | |
/** | |
* A mixin for components that want to bind the value of a state variable | |
* to the value at a Firebase ref. |
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
(function webpackUniversalModuleDefinition(root, factory) { | |
if(typeof exports === 'object' && typeof module === 'object') | |
module.exports = factory(); | |
else if(typeof define === 'function' && define.amd) | |
define([], factory); | |
else if(typeof exports === 'object') | |
exports["HTTPClient"] = factory(); | |
else | |
root["HTTPClient"] = factory(); | |
})(this, function() { |
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
<div className="pricing" style={{ opacity: purchasing ? 0.25 : '' }}> | |
{purchaseComplete ? ( | |
<div className="purchase-complete"> | |
<h2>Thanks!</h2> | |
<p> | |
Thank you for your purchase of {formatPrice(this.state.total)}. | |
We’ll send you a receipt shortly. | |
</p> | |
<p> | |
<button |
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
import React from 'react' | |
// So, this is awesome. And it's the approach I took in my own site. | |
// Nothing wrong with it! | |
const IconUmbrella = React.createClass({ | |
render() { | |
return ( | |
<svg className="umbrella" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" aria-labelledby="umbrella icon"> | |
<title>Umbrella</title> | |
<path d="M27 14h5c0-1.105-1.119-2-2.5-2s-2.5 0.895-2.5 2v0zM27 14c0-1.105-1.119-2-2.5-2s-2.5 0.895-2.5 2c0-1.105-1.119-2-2.5-2s-2.5 0.895-2.5 2v0 14c0 1.112-0.895 2-2 2-1.112 0-2-0.896-2-2.001v-1.494c0-0.291 0.224-0.505 0.5-0.505 0.268 0 0.5 0.226 0.5 0.505v1.505c0 0.547 0.444 0.991 1 0.991 0.552 0 1-0.451 1-0.991v-14.009c0-1.105-1.119-2-2.5-2s-2.5 0.895-2.5 2c0-1.105-1.119-2-2.5-2s-2.5 0.895-2.5 2c0-1.105-1.119-2-2.5-2s-2.5 0.895-2.5 2c0-5.415 6.671-9.825 15-9.995v-1.506c0-0.283 0.224-0.499 0.5-0.499 0.268 0 0.5 0.224 0.5 0.499v1.506c8.329 0.17 15 4.58 15 9.995h-5z"/> |