Skip to content

Instantly share code, notes, and snippets.

var graph = new ImmutableGraph();
var graph1 = graph.addVertex( 2 )
var graph2 = graph1.addVertex( 1 );
var graph3 = graph2.addEdge( "A", [ 1, 2 ] );
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
@JakeCoxon
JakeCoxon / store-component.js
Last active August 29, 2015 14:19
Higher-order Hoverboard Store Component
import React from 'react';
export default Store => ComposedComponent => React.createClass({
getInitialState() {
return Store.getState();
},
componentDidMount() {
this.unsubscribe = Store.getState(state => this.setState(state));
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
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
}
Array.apply(null, Array(15))
.map((_, i) => i + 1)
.map(i =>
[i, "Fizz", "Buzz", "FizzBuzz"][!(i % 3) + 2*!(i % 5)]
)
.forEach(::console.log)
@JakeCoxon
JakeCoxon / ramda-bind.js
Last active August 5, 2016 14:56
Wrap ramda to work nice with the bind operator
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) {
@JakeCoxon
JakeCoxon / index.js
Last active March 26, 2022 20:51
Firebase Mobx
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: "",
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}}/>
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} />
});