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 *sequence(...args) { | |
const start = args.length < 2 ? 0 : args[0]; | |
const end = args[args.length < 2 ? 0 : 1] || 0; | |
const step = args.length < 3 ? 1 : args[2]; | |
for (let i = start; i < end; i += step) { | |
yield i; | |
} | |
} |
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 *parseBif(buffer) { | |
const data = new DataView(buffer); | |
// Ensure this is a BIF v0. | |
if (data.getUint32(0, true) !== 0x46494289 || data.getUint32(4, true) !== 0x0a1a0a0d || data.getUint32(8, true) !== 0) { | |
return; | |
} | |
const separation = data.getUint32(16, true) || 1000; | |
const start = 64; |
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
#!/bin/bash | |
# | |
# Version bump and publish this Git+Maven repo. | |
# | |
# Usage: ./publish.sh {major|minor|patch} | |
# | |
# For example, to bump the version from 1.5.9 to 1.6.0: | |
# | |
# ./publish.sh minor |
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>bacon.js and baconjs-router POC</title> | |
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> | |
<script src="https://unpkg.com/react@latest/dist/react.js"></script> | |
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.95/Bacon.js"></script> | |
</head> |
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>React + Bacon.js + Page.js</title> | |
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> | |
<script src="https://unpkg.com/react@latest/dist/react.js"></script> | |
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.95/Bacon.min.js"></script> | |
<script src="https://cdn.rawgit.com/visionmedia/page.js/master/page.js"></script> |
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>bacon.js and baconjs-router POC</title> | |
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> | |
<script src="https://unpkg.com/react@latest/dist/react.js"></script> | |
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/bacon.js/0.7.95/Bacon.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script> |
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
/** | |
* <p>Create a function that can generate BEM classes based on the specified block.</p> | |
* <p>Suppose you have the following code:</p> | |
* <pre> | |
* const bem = bemFor('my-block'); | |
* </pre> | |
* Then: | |
* <ul> | |
* <li><code>bem()</code> will return <code>"my-block"</code></li> | |
* <li><code>bem('my-element')</code> will return <code>"my-block__my-element"</code></li> |
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 MyComponent extends React.Component { | |
static propTypes = { | |
photoUrl: PropTypes.string, | |
initialButtonVisible: PropTypes.bool | |
}; | |
static defaultProps = { | |
photoUrl: '', | |
initialButtonVisible: true | |
}; |
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 MyComponent extends React.Component { | |
constructor(props) { | |
this.state = { | |
photoVisible: this.props.initialPhotoVisible | |
}; | |
this.togglePhotoVisible = this.togglePhotoVisible.bind(this); | |
} | |
togglePhotoVisible() { |
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
with | |
a as (select * from generate_series(0, 6) s), -- 6 is user specified number of days - 1 | |
b as (select ('2013-03-01'::date + s * interval '1 day')::date appt_date from a), -- 2013-03-01 is user specified start date | |
c as (select * from generate_series('2013-03-02 00:00'::timestamp without time zone, '2013-03-05 23:59'::timestamp without time zone, '10 minutes') appt), -- Dummy data - appointment times | |
d as (select appt::date appt_date, to_char(appt, 'HH24:MI') appt_time from c), -- Split out the date and time | |
e as (select appt_date, json_agg(appt_time order by appt_time) times from d group by appt_date), -- Aggregate times into an array per day | |
f as (select appt_date, coalesce(times, '[]'::json) times from b left join e using (appt_date)) -- Left join onto the generated date series to produce an array for all days including empty ones | |
select json_agg(times order by appt_date) from f -- Aggregate the result into a single array of arrays |