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 HelpText = (props) => | |
| <div {...props} style={css` | |
| font-family: Helvetica; | |
| padding: 10px; | |
| background-color: white; | |
| border: 1px inset #ccc; | |
| `} />; | |
| const state = observable({ value: 0 }); |
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
| // texgen.js - http://github.com/mrdoob/texgen.js | |
| let TG={OP:{SET:function(a,b){return b},ADD:function(a,b){return a+b},SUB:function(a,b){return a-b},MUL:function(a,b){return a*b},DIV:function(a,b){return a/b},AND:function(a,b){return a&b},XOR:function(a,b){return a^b},MIN:function(a,b){return Math.min(a,b)},MAX:function(a,b){return Math.max(a,b)}},Texture:function(a,b){this.color=new Float32Array(4);this.buffer=new TG.Buffer(a,b);this.bufferCopy=new TG.Buffer(a,b)}}; | |
| TG.Texture.prototype={constructor:TG.Texture,set:function(a,b){void 0===b&&(b=TG.OP.SET);this.bufferCopy.copy(this.buffer);var c=["var x = 0, y = 0;\nvar array = dst.array;\nvar width = dst.width, height = dst.height;\nfor ( var i = 0, il = array.length; i < il; i += 4 ) {","\t"+a.getSource(),"\tarray[ i ] = op( array[ i ], color[ 0 ] * tint[ 0 ] );\n\tarray[ i + 1 ] = op( array[ i + 1 ], color[ 1 ] * tint[ 1 ] );\n\tarray[ i + 2 ] = op( array[ i + 2 ], color[ 2 ] * tint[ 2 ] );\n\tif ( ++x === width ) { x = 0; y ++; }\n}"].join("\n"); | |
| ( |
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} /> | |
| }); |
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
| 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
| 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
| 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
| 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
| 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
| import React from 'react'; | |
| export default Store => ComposedComponent => React.createClass({ | |
| getInitialState() { | |
| return Store.getState(); | |
| }, | |
| componentDidMount() { | |
| this.unsubscribe = Store.getState(state => this.setState(state)); |