Skip to content

Instantly share code, notes, and snippets.

View ChillyBwoy's full-sized avatar
🕶️
(ノ ˘_˘)ノ ζ|||ζ ζ|||ζ ζ|||ζ

Eugene Cheltsov ChillyBwoy

🕶️
(ノ ˘_˘)ノ ζ|||ζ ζ|||ζ ζ|||ζ
  • 東京都
View GitHub Profile
@ChillyBwoy
ChillyBwoy / index.js
Created August 4, 2023 07:57
Promises queue
/**
- you have a list of 1000 items
- you have an async function `process(item)`
- you need to process all items
- it needs to be done concurrently, but not more than 25 at a time
- collect items with errors
what's the cleanest way to do this?
libraries allowed
*/
@ChillyBwoy
ChillyBwoy / index.js
Created November 2, 2019 20:24
Multimethod
function multiMethod() {
const methodMap = new Map();
const fn = function (name, ...args) {
const fn = methodMap.get(name);
if (typeof fn === 'undefined') {
throw new TypeError(`Invalid method name "${name}"`);
}
return fn(...args);
};
@ChillyBwoy
ChillyBwoy / HashTable.js
Created September 16, 2019 19:36 — forked from alexhawkins/HashTable.js
Correct Implementation of a Hash Table in JavaScript
var HashTable = function() {
this._storage = [];
this._count = 0;
this._limit = 8;
}
HashTable.prototype.insert = function(key, value) {
//create an index for our storage location by passing it through our hashing function
var index = this.hashFunc(key, this._limit);
@ChillyBwoy
ChillyBwoy / ExampleViewController.swift
Created March 14, 2019 21:39
UIViewController with static table
//
// AddHabitViewController.swift
// every-habit
//
// Created by Eugene Cheltsov on 13/02/2019.
// Copyright © 2019 Eugene Cheltsov. All rights reserved.
//
import UIKit
@ChillyBwoy
ChillyBwoy / tutorial.md
Created August 15, 2018 10:53 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@ChillyBwoy
ChillyBwoy / Person.css
Last active February 13, 2018 15:41
TypeScript React Sample
.root {
position: relative;
}
.isActive {
background: green;
}
.gender_male {
border: 1px solid #00f;
function factory() {
var count = 0;
return function() {
function fx() {
count += 1;
return fx;
}
fx.valueOf = function() {
@ChillyBwoy
ChillyBwoy / example.ts
Created December 6, 2017 13:17
Thunk-like middleware for redux and TypeScript 2.6 (without extra argument)
import * as Redux from "redux";
import { MiddlewareAction } from "./redux-middleware";
export interface StateType {
foo: string;
bar: number;
}
export type ActionType
= {
@ChillyBwoy
ChillyBwoy / index.ts
Created November 24, 2017 23:36
Invert RGB color
const invertColor = (hex: string) => [
(x: string) => parseInt(x.substring(1), 16),
(x: number) => 0xFFFFFF ^ x,
(x: number) => `000000${x.toString(16)}`.slice(-6),
(x: string) => `#${x}`,
].reduce((acc, f: (...args: any[]) => any) => f(acc), hex);
const Y = h => (f => f(f))(f => h(n => f(f)(n)));
/* by steps */
// helpers
const recur = (f) => f(f);
const wrap = h => recur(f => h(n => f(f)(n)));
const fact0 = (n) => n < 2
? 1