Skip to content

Instantly share code, notes, and snippets.

Avatar

tomasz stryjewski stryju

View GitHub Profile
View useFPS.js
function useFPS() {
const [fps, setFPS] = useState(0);
useEffect(() => {
let then = performance.now();
let frames = 0;
let req;
(function loop(now) {
req = window.requestAnimationFrame(loop);
@stryju
stryju / quicksort.js
Created Oct 6, 2015
quicksort (haskell-inspired) in es6
View quicksort.js
function quicksort([ x, ...xs ]) {
if (!arguments[0].length) return [];
return [ ...xs.filter( y => y <= x ), x, ...xs.filter( y => y > x ) ];
}
@stryju
stryju / 01.es6
Last active Aug 29, 2015
preferred state $http resolution
View 01.es6
const state = {
resolve : {
foo : ( $http ) => $http.get( '/foo' )
},
controller : Controller
}
class Controller {
constructor( foo ) {
this.foo = foo.data;
@stryju
stryju / Makefile
Last active Aug 29, 2015
material design icons SVG <defs> sprite generator
View Makefile
OUTPUT = sprites/svg-defs-sprite
reverse = $(2) $(1)
id = $(shell basename $(1) | sed 's/^ic_//;s/_24px\.svg$$//;s/_/-/g' )
extract = $$(cat $(1) | egrep -o $(2) | tr '\n' ' ' | sed "s/id=\"/id=\"$(call id,$(1))-/g")
src := $(wildcard */svg/production)
dest := $(patsubst %/svg/production,$(OUTPUT)/%.svg,$(src))
svg_start := '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs>'
@stryju
stryju / _intro.md
Last active Aug 29, 2015
something something **es6**
View _intro.md

something something es6

a bit cleaned up version of my "slides"

disclaimer: this "talk" was done to show some "real life use cases" to simplify the knowledge I mainly got from Axel Rauschmayer's articles

why "destructring is a good way to go"

View package.json
{
"tasks": {
"gulp": "gulp",
"dev": "gulp watch"
},
"devDependencies": {
"gulp": "*"
}
}
View foo-controller.es6
export default class FooController {
// @ngInject
constructor( $document ) {
console.log( $codument );
}
}
@stryju
stryju / require-config.js
Created Jan 30, 2015
requirejs config shared between app and optimizer
View require-config.js
( function( requirejs ) {
'use strict';
requirejs.config({
// ... config goes here
});
})( typeof exports === 'object' ? {
config : function ( cfg ) {
'use strict';
You can’t perform that action at this time.