Skip to content

Instantly share code, notes, and snippets.

var reader = new FileReader(),
read = function(method) {
return function(blob) {
return new Promise(function(resolve) {
reader[method](blob);
reader.onload = function() {
resolve(reader.result);
}
});
};
var s = tt[31].A.reduce(function(res, stop, stopIndex) {
var stopTimes = Object.keys(stop).reduce(function(hrRes, hour) {
return hrRes.concat(stop[hour].map(function(i) { return hour * 60 + i; }));
}, []);
if(!res.length) {
res = stopTimes.map(function(i) { return [i]; });
}
else {
stopTimes.forEach(function(time, i) {
res[i].push(time - res[i].reduce(function(s, i) { return s+i; }, 0));
{
"0173200001414001889" : ["368", "199к"],
"0173200001415000205" : ["320"],
"0173200001415000827" : ["361", "540"],
"0173200001415000829" : ["432"],
"0173200001415000828" : ["483", "309", "346"],
"0173200001415000920" : ["112"],
"0173200001415000921" : ["206к", "63", "191"],
"0173200001415000922" : ["352", "571", "592", "215"],
"0173200001415000924" : ["617"],
(($,$$,_,__=~-~_*~_,$_=$[-~__],_$=$[-~-~__])=>$_+_$+$[_]+(''+''[$$[~-__]+$$[_]+(''+$.$)[_]+$_+$[+'']+$[_]+$[-~_]+$$[~-__]+$[+'']+$$[_]+$[_]])[-~__<<_]+_$+$[+'']+$_)(''+!''+![],{}+'',+!'')
/**
* Разбирает абсолютный URL на части
* @param {String} url
* @returns {{href, protocol, host, hostname, port, pathname, path: string[], search, query: Object}|null}
*/
function parseUrl(url) {
if (!url) {
return null;
}
@sergets
sergets / pan-pinch.js
Created September 6, 2022 12:55
Simple adding of 'pan' and 'pinch' events
(add => {
let pinchDist;
const touches = {},
trigger = (n, e, p) => e.target.dispatchEvent(Object.assign(new Event(n, e), p, { originalEvent: e })),
dist = ([a, b]) => Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)),
pan = (x, y, e) => (x || y) && trigger('pan', e, { deltaX: x, deltaY: y }),
pinch = (d, x, y, e) => d !== 1 && trigger('pinch', e, { delta: d, clientX: x, clientY: y }),
pinchDiff = e => {
const pts = Object.values(touches); if (pts.length !== 2) return pinchDist = null; const dst = dist(pts);
pinchDist && pinch(dst / pinchDist, (pts[0].x + pts[1].x) / 2, (pts[0].y + pts[1].y) / 2, e); pinchDist = dst;