This file contains 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"; | |
import {ImageBackground} from "react-native"; | |
export function Sprite(props) { | |
const [w, h] = [props.geometry.width, props.geometry.height]; | |
const r = Math.min(w / (props.width / props.cols), h / (props.height / props.rows)); | |
return ( | |
<ImageBackground | |
source={props.source} |
This file contains 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
function dtree_decide(tree, ...argv) { | |
var i, len, r; | |
for(i = 0, len = tree.length; i < len; i++) | |
if((r = tree[i](...argv))) | |
return r; | |
return false; | |
} | |
function dtree_make(tree) { |
This file contains 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
/* E.g. verscmp("1.2.3", "1.2.2") */ | |
function verscmp(a, b) { | |
var spa = a.split('.').map(x => Number(x)); | |
var spb = b.split('.').map(x => Number(x)); | |
var part = [], r = 0; | |
while(!r && spa.length && spb.length) { | |
part = [spa.shift(), spb.shift()]; | |
if(part[0] == part[1]) | |
continue; |
This file contains 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
/* Do not use code you have not read first. | |
* Original file: https://gist.github.com/clamiax/ee6eea3010021bc62d188739b42c86cd */ | |
let T9N_DEFLANG = null; | |
function _() { | |
if(!T9N_DEFLANG) | |
return ""; | |
return t9n_format(T9N_DEFLANG, ...Array.from(arguments)); | |
} |
This file contains 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
function xmltojson(xml, attkey = "$") { | |
var obj = {}, t, len, i; | |
switch(xml.nodeType) { | |
case Node.ELEMENT_NODE: | |
len = xml.attributes.length; | |
if(len) { | |
obj[attkey] = {}; | |
for(i = 0; i < len; ++i) { | |
t = xml.attributes[i]; |
This file contains 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
(() => { | |
/* | |
* Build mazes of arbitrary size using a randomized version of the Deep-first | |
* search algorhitm. Cells are accessed using the row/column-major order | |
* method. Mazes are printed in console. | |
* | |
* To understand everything else, start reading main(). | |
*/ | |
"use strict"; |
This file contains 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
function isleap(year) { | |
return !(year % 4) && ((year % 100) || !(year % 400)); | |
} |
This file contains 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
/* Superseded by domapply: | |
* https://gist.github.com/clamiax/e053d486c28e5101ddf6a1739a5151c7 */ | |
/* This may eventually be included in utils.js[0] at some point, if everything | |
* will works as expected. | |
* [0] https://gist.github.com/clamiax/e1db98deaf94bb1ccf8556d993245afb */ | |
function applytodom(dst, src) { | |
var par, len, atts, i, has; | |
if(!(dst && src)) |
This file contains 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
function getheight(el) { | |
var props = ["height", "marginTop", "marginBottom", "borderTop"]; | |
var s = getComputedStyle(el), ret = 0; | |
if(!s) return 0; | |
props.forEach((p) => ret += parseFloat(s[p])); | |
return ret; | |
} |
This file contains 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
/* clear all timers */ | |
[...Array(100000).keys()].forEach(function(i) { | |
++i; /* timer IDs starts from 1 */ | |
clearTimeout(i); | |
clearInterval(i); | |
}); |