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 / minimold.js
Created Jul 6, 2012
mini-templating engine ( minimold ) - uses {{single_replace}} and {{iterator}}...{{/iterator}} from some ELEMENT
View minimold.js
/*
* usage:
*
* tmpl( id_of_template_source:string , [template_data:object] );
*
*/
var minimold = (function(){
"use strict";
var cache = {};
@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 ) ];
}
View _normalize.scss
/*! normalize.css v1.0.0 | MIT License | git.io/normalize */
/*
* usage:
* @import "normalize";
*
* // this will print out ALL selectors
* @include normalize();
*
* // this will print out minimal set (*) -- you can see the list of "excluded" tags below
@stryju
stryju / package.json
Created Jan 17, 2014
use nodemon for watching local changes and restarting your server with simple `npm start`
View package.json
{
"scripts": {
"start": "nodemon -w . index.js"
},
"dependencies": {
"nodemon": "~1.0.9"
}
}
View either.php
function either() {
foreach ( func_get_args() as $arg ){
if ( is_string( $arg ) ? !! trim( $arg ) : !! $arg ) {
return $arg;
}
}
return false;
}
@stryju
stryju / settings.json
Created Sep 24, 2013
sublime settings
View settings.json
{
"bold_folder_labels": true,
"color_scheme": "Packages/Dayle Rees Color Schemes/Peacock.tmTheme",
"default_line_ending": "unix",
"draw_minimap_border": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"flatland_sidebar_tree_small": true,
"flatland_square_tabs": false,
"folder_exclude_patterns":
View commenter.js
var comments = [];
function digDeeper( el, i ){
if ( el.nodeType === 8 ){
comments.push( el.nodeValue.replace( /^\s*|\s*$/g, '' ));
return;
}
if ( ! el || ! el.childNodes || ! el.childNodes.length ){
return;