Skip to content

Instantly share code, notes, and snippets.

View kindziora's full-sized avatar
:electron:
coding

alexander kindziora kindziora

:electron:
coding
View GitHub Profile
@kindziora
kindziora / load.md
Last active October 18, 2021 13:38
specs for a mongodb query -> process balancer invoking workers

balancer code

  • load a config
{
  "collection" : "products",
  "match" : { "language" : "de" },
  "queueProperty" : "__mdbqb",
 "cleanUpQueueProperty" : false,
@kindziora
kindziora / chunk-fuzzy.js
Last active October 12, 2021 14:01
chunk a string into max length segments but keep words healthy
/**
* chunk and dont be strict with length
* @param {*} text
* @param {*} chunkSize
* @returns
*/
function chunk(text, chunkSize) {
let result = [];
let words = text.split(" ");
@kindziora
kindziora / Ländercodes.json
Created March 18, 2021 09:15
Ländercodes
[
{
"text": "Deutschland",
"value": "DE"
},
{
"text": "Österreich",
"value": "AT"
},
{
@kindziora
kindziora / index.ts
Created January 13, 2020 08:10 — forked from Curtis017/index.ts
Simple middleware implementation using typescript and ES6
import pipeline, { Middleware } from './pipeline';
const step1: Middleware<any, any> = (req, res, next) => {
if (req.body) {
console.log(`STEP 1: \n req: ${JSON.stringify(req)}\n res: ${JSON.stringify(res)}`);
next();
}
}
const step2: Middleware<any, any> = async (req, res, next) => {
@kindziora
kindziora / gist:6b9fdd511d4adda492906cd98929f14e
Last active November 30, 2017 11:21
Markdown cheat sheet

Header 1

Header 2

Header 3 ### (Hashes on right are optional)

Header 4

Header 5

Markdown plus h2 with a custom ID ## {#id-goes-here}

Link back to H2

This is a paragraph, which is text surrounded by whitespace. Paragraphs can be on one

@kindziora
kindziora / colors.js
Created January 23, 2017 22:22
colors.js
var cc = ['#804080',
'#800000',
'#808080',
'#0000C0',
'#808000',
'#400080',
'#C0C000',
'#40C000',
'#4080C0',
'#C0C080',
@kindziora
kindziora / fnc-8s.prototxt
Created January 21, 2017 12:26
fnc-8s.prototxt
# data layers
layer {
name: "data"
type: "Data"
top: "data"
include {
phase: TRAIN
}
data_param {
batch_size: 1
@kindziora
kindziora / download.js
Last active January 19, 2017 18:16
download music from yandex music
function down(uri, name) {console.log(uri,name);
var link = document.createElement("a");
link.download = name;
link.href = uri;
link.click();
}
function links() {
var $tr = $('.page-album__tracks .track_selectable'), l = $tr.length;
var queue = {}, i = 1;
@kindziora
kindziora / simplerXHR.js
Last active June 28, 2020 07:32 — forked from sindresorhus/simplexhr.js
Simpler XMLHttpRequest wrapper
var simplerXHR = function( method, url) {
var _xhr = new XMLHttpRequest();
_xhr.open( method, url );
_xhr.setup = function(cb){ // hacky? maybe
cb(_xhr);
return _xhr;
};
_xhr.done = function(cb){ // hacky? maybe
_xhr.onreadystatechange = function() {
if ( _xhr.readyState === 4 ) {
var wrapworker = function (_function, data) {
var wrapr = this;var wrapworker = function (_function, data) {
var wrapr = this;
var mtd = "self.onmessage = function() {postMessage(" + _function.toString().replace('(','du(') + "(" + JSON.stringify(data) + "));};";
blob = new Blob([mtd], { type: 'application/javascript' });
var work = new Worker(URL.createObjectURL(blob));
wrapr.ready = function (cb) { work.onmessage = cb; };
wrapr.error = function (cb) { work.onerror = cb; };
work.postMessage(true);
return wrapr;