Skip to content

Instantly share code, notes, and snippets.

View stryju's full-sized avatar

tomasz stryjewski stryju

  • Meta
  • Kailua, HI
  • 11:49 (UTC -10:00)
View GitHub Profile
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 / esnextbin.md
Created January 12, 2017 10:50
esnextbin sketch
@stryju
stryju / esnextbin.md
Last active September 13, 2016 14:03
esnextbin sketch
@stryju
stryju / quicksort.js
Created October 6, 2015 07:56
quicksort (haskell-inspired) in es6
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 August 29, 2015 14:23
preferred state $http resolution
const state = {
resolve : {
foo : ( $http ) => $http.get( '/foo' )
},
controller : Controller
}
class Controller {
constructor( foo ) {
this.foo = foo.data;
@stryju
stryju / Makefile
Last active August 29, 2015 14:22
material design icons SVG <defs> sprite generator
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 August 24, 2022 16:28
something something **es6**

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"

{
"tasks": {
"gulp": "gulp",
"dev": "gulp watch"
},
"devDependencies": {
"gulp": "*"
}
}
@stryju
stryju / foo-controller.es6
Created February 14, 2015 13:50
angular 1.x on es6
export default class FooController {
// @ngInject
constructor( $document ) {
console.log( $codument );
}
}
@stryju
stryju / require-config.js
Created January 30, 2015 17:02
requirejs config shared between app and optimizer
( function( requirejs ) {
'use strict';
requirejs.config({
// ... config goes here
});
})( typeof exports === 'object' ? {
config : function ( cfg ) {
'use strict';