Skip to content

Instantly share code, notes, and snippets.

View zerobias's full-sized avatar
💭
Set your status

Dmitry zerobias

💭
Set your status
View GitHub Profile
//puredom.js
//@flow
//@jsx domsx
//@jsxFrag 'fragment'

const handlers = (global.handlers = [])
initDOM()

const ClickMe = (props, childs) => (
'use strict';
'use exports {Semaphore, ExclusiveSemaphore, SharedSemaphor}';
const ERR_LOCKED = `Semaphore is already fully locked`;
class Semaphore {
constructor() {}
/**
* Creates a controller to manually control locking & unlocking
* the Semaphore.
*
class Tree {
constructor(root) {
this.root = null
this.root = root
}
buildFromLinks(links) {
const nodes = new Array(26)
const forest = new Array(26)
@zerobias
zerobias / ASM.js
Created November 13, 2018 04:25
Don't try this at home
//@flow
export const EMIT: "emit" = "emit";
export const MAP: "map" = "map";
export const WATCH: "watch" = "watch";
export const SCOPE: "scope" = "scope";
export const STOP: "stop" = "stop";
export const MOV: "mov" = "mov";
export const COPY: "copy" = "copy";
export const THREAD: "thread" = "thread";
// @flow
/**
* Simple function for formatting strings.
* Replaces placeholders with values passed as extra arguments
*/
export default function sprintf(format: string, ...args: mixed[]) {
let index = 0;
return format.replace(/%s/g, match => String(args[index++]));
}
@zerobias
zerobias / ABC.json
Last active November 2, 2018 12:30
BTT switch to specific keyboard language, A then Caps - "ABC" (aka english), S then Caps - "Russian - PC"
{
"BTTGestureNotes" : "switch to english",
"BTTTriggerType" : 624,
"BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
"BTTPredefinedActionType" : -1,
"BTTPredefinedActionName" : "No Action",
"BTTAdditionalConfiguration" : "131074",
"BTTEnabled2" : 1,
"BTTUUID" : "4C75140A-7C83-4D71-9317-9E986458F307",
"BTTTriggerOnDown" : 1,
@zerobias
zerobias / BTT_macro_skip_space.json
Created November 2, 2018 11:12
BTT macro skip double space
{
"BTTTriggerType" : 624,
"BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
"BTTPredefinedActionType" : -1,
"BTTPredefinedActionName" : "No Action",
"BTTEnabled2" : 1,
"BTTUUID" : "D7CCEBE4-EDE1-4DAB-A67B-8634AA87F28C",
"BTTTriggerOnDown" : 0,
"BTTEnabled" : 1,
"BTTShortcutKeyCode" : -1,
const generatePermutations = (items, process) => {
const mutableItems = items.slice();
const isEven = n => (n & 1) === 0;
const permute = (itemArray, x, last) => {
if (isEven(last)) { x = 0; }
const temp = itemArray[x];
itemArray[x] = itemArray[last];
itemArray[last] = temp;
@zerobias
zerobias / better colors.js
Created October 23, 2018 01:08
Better web colors
var colors = {
aqua: '#7fdbff',
blue: '#0074d9',
lime: '#01ff70',
navy: '#001f3f',
teal: '#39cccc',
olive: '#3d9970',
green: '#2ecc40',
red: '#ff4136',
maroon: '#85144b',
@zerobias
zerobias / mutex.js
Last active December 1, 2018 16:17
Mutex
/* @flow */
class Lock {
release: () => void
sustain = new Promise<void>(resolve => {
this.release = resolve
})
}
export type Releaser<Key> = Promise<() => void>