Skip to content

Instantly share code, notes, and snippets.

interface MyCustomType<T> {
prop: Promise<T>
}
interface MyBlaBlaType {
prop: string
}
interface MyObj {
[key: string]: (...args: any) => any
@imaximix
imaximix / index.js
Created January 31, 2019 10:27
wine-classifier. logistic regrestion
var fs = require('fs');
var csv = require('fast-csv');
var math = require('mathjs');
var R = require('ramda');
var colors = require('colors/safe');
var process = require('process');
var stream = fs.createReadStream("wines.csv");
var yKey = 'Class';
@imaximix
imaximix / EventViewer.js
Created November 15, 2018 08:11
Server Sent Events with WebFlux
import React, { Component } from "react";
export default class EventViewer extends Component {
constructor() {
super();
this.state = { events: [] };
}
componentDidMount() {
@imaximix
imaximix / docker-compose.yml
Last active February 28, 2019 10:41
docker compose with: postgres, pgadmin, redis and rabbitmq
version: '3'
services:
rabbitmq:
container_name: rabbitmq
image: rabbitmq:3.6.10-management-alpine
environment:
RABBITMQ_DEFAULT_USER: rmq
RABBITMQ_DEFAULT_PASS: pass
restart: on-failure
@imaximix
imaximix / insertion_sort.hs
Last active March 13, 2018 09:31
Implement Insertion Sort in Haskell to understand ST mutation
module Main where
import Control.Monad.ST
import qualified Data.STRef as STR
import qualified Data.Array.ST as STArray
import qualified Data.Array as Arr
import qualified Data.Array.MArray as MA
untilM :: (Monad m) => m Bool -> m a -> m ()
etcd2 --name node1 --initial-advertise-peer-urls 'http://207.154.233.166:2380' \
--listen-peer-urls 'http://207.154.233.166:2380' \
--listen-client-urls 'http://207.154.233.166:2379,http://127.0.0.1:2379' \
--advertise-client-urls 'http://207.154.233.166:2379' \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster 'node1=http://207.154.233.166:2380,node2=http://207.154.237.27:2380' \
--initial-cluster-state new
func cycle<A>(coll: [A]) -> AnyIterator<A> {
var cursor = 0
let infiniteItems = AnyIterator { () -> A in
let itemToReturn = coll[cursor]
cursor += 1
if (cursor > coll.count - 1) {
cursor = 0
}
return itemToReturn
}

Datomic is ACID.

Single writer.

When a generator is good solution for repetitious code, a better solution is to abstract it into a simpler API.
var queue = function () {
var tasksToExecute = [],
lastExecutedIndex = -1,
$deferred, taskFailed = false;
function reset() {
lastExecutedIndex = -1;
taskFailed = false;
}
function pop() {
lastExecutedIndex = lastExecutedIndex + 1;