This file contains hidden or 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 graph = new ImmutableGraph(); | |
var graph1 = graph.addVertex( 2 ) | |
var graph2 = graph1.addVertex( 1 ); | |
var graph3 = graph2.addEdge( "A", [ 1, 2 ] ); |
This file contains hidden or 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
on run argv | |
tell application "Terminal" to set current settings of selected tab of front window to first settings set whose name is (item 1 of argv) | |
end run |
This file contains hidden or 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'; | |
export default Store => ComposedComponent => React.createClass({ | |
getInitialState() { | |
return Store.getState(); | |
}, | |
componentDidMount() { | |
this.unsubscribe = Store.getState(state => this.setState(state)); |
This file contains hidden or 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
ffmpeg -i input.mov -filter:v "setpts=2.0*PTS" -s 187x333 -pix_fmt rgb8 -r 10 -f gif - | gifsicle --optimize=3 > out.gif | |
# Explanation | |
ffmpeg -i input.mov \ # Input file | |
-filter:v "setpts=2.0*PTS" \ # Scale time 2x | |
-s 187x333 \ # Set pixel size | |
-pix_fmt rgb24 \ # Pixel format | |
-r 10 \ # Set framerate | |
-f gif - | \ # Output gif format | |
gifsicle \ # Optimize the ffmpeg gif |
This file contains hidden or 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
a() { | |
local cmd | |
cmd="$(alias | sed "s/^alias \(..*\)=\'\(.*\)\'/\1#\2/" | column -t -s $'#' 2> /dev/null | fzf | sed "s/^[^ ]* *//")" | |
if [ -n "$cmd" ]; then | |
echo $cmd | |
eval $cmd | |
fi | |
} |
This file contains hidden or 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
Array.apply(null, Array(15)) | |
.map((_, i) => i + 1) | |
.map(i => | |
[i, "Fizz", "Buzz", "FizzBuzz"][!(i % 3) + 2*!(i % 5)] | |
) | |
.forEach(::console.log) |
This file contains hidden or 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 ramda from 'ramda' | |
import Immutable from 'immutable' | |
const applyWildcard = (array, val) => { | |
const wildIndex = ramda.findIndex(x => x === __, array); | |
return wildIndex > -1 ? ramda.update(wildIndex, val, array) : array.concat([val]); | |
} | |
const toThisFunction = (func) => { | |
return _.isFunction(func) ? function(...args) { |
This file contains hidden or 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 _ from 'https://npmcdn.com/[email protected]' | |
import 'https://npmcdn.com/[email protected]/firebase.js' | |
var config = { | |
apiKey: "AIzaSyCNV9EVtgHpNCHJoRe8xwkCRIpKZ3IFI_M", | |
authDomain: "example-app-ccfdb.firebaseapp.com", | |
databaseURL: "https://example-app-ccfdb.firebaseio.com", | |
storageBucket: "", |
This file contains hidden or 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 Canvas extends React.Component { | |
componentDidMount() { | |
this.props.draw(this.refs.a.getContext('2d')); | |
} | |
render() { | |
const { width, height } = this.props; | |
return <canvas ref='a' | |
width={width} | |
height={height} | |
style={{width, height}}/> |
This file contains hidden or 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
const show = (children) => | |
<svg style={{border:'1px solid #ccc', height:500}}>{children}</svg> | |
const circles = _.range(20).map(x => { | |
return <circle | |
cx={25 + x * 25} | |
cy={x % 2 == 0 ? 45 : 20} | |
fill="black" | |
r={10} /> | |
}); |