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
{
function suite(fiboMax, repeats, fiboLoop) {
function getMedian(args) {
if (!args.length) {return 0};
var numbers = args.slice(0).sort((a,b) => a - b);
var middle = Math.floor(numbers.length / 2);
var isEven = numbers.length % 2 === 0;
return isEven ? (numbers[middle] + numbers[middle - 1]) / 2 : numbers[middle];
type attr = ..;
type attr +=
| Str(string);
type attr +=
| Int(int)
| Float(float);
module Bool: {
type attr +=
pri
module type DEVICE = {
let draw: string => unit;
};
let devices: Hashtbl.t(string, module DEVICE) = Hashtbl.create(17);
module SVG = {
let draw = string => Js.log2("svg module", string);
};
Hashtbl.add(devices, "SVG", (module SVG): (module DEVICE));
module PDF = {
let draw = string => Js.log2("pdf module", string);
module F = (X: {type c = pri {.. x: int};}) => {
let get_x = (o: X.c) => o#x;
};
module G =
(
X: {
type c =
pri {
..
x: int,
p{padding-left:60px;}
#foo{
border-radius:50px;
width:50px;
height:50px;
background:#c00;
position:absolute;
top:0;
left:0;
transition: transform 1s;
@zerobias
zerobias / animated css gears.js
Created September 30, 2018 15:34
animated css gears
//@flow
import * as React from 'react'
import {render} from 'react-dom'
import styled, {keyframes, css} from 'styled-components'
export function run() {
let devpage = document.querySelector('#devpage')
if (!devpage) {
devpage = document.createElement('div')
const {body} = document
@zerobias
zerobias / transmutation.js
Last active September 12, 2018 04:20
Transmutation with effector (aka histomorphism)
//@flow
import {createStore, type Store} from 'effector'
const capacity: '@@capacity' = (Symbol('buffer capacity'): any)
declare export function readCapacity<T>(store: Store<[T, T, T, T, T, T, T]>): 7
declare export function readCapacity<T>(store: Store<[T, T, T, T, T, T]>): 6
declare export function readCapacity<T>(store: Store<[T, T, T, T, T]>): 5
declare export function readCapacity<T>(store: Store<[T, T, T, T]>): 4
@zerobias
zerobias / a_worker.js
Created September 10, 2018 07:22
Async worker
import * as promises from './b_promises.js';
const allowedWorkTime = 4;
const maximumTaskFrame = 100;
export default class Worker {
constructor(fn) {
this.fn_ = fn;
this.queue_ = [];
this.waiting_ = null;
const resolved = Promise.resolve();
/**
* Returns a Promise that resolves on `requestIdleCallback`.
*
* @return {!Promise<!IdleDeadline>}
*/
export function idle() {
return new Promise((resolve) => window.requestIdleCallback(resolve));
}