Skip to content

Instantly share code, notes, and snippets.

View shimondoodkin's full-sized avatar

Shimon Doodkin shimondoodkin

View GitHub Profile
@shimondoodkin
shimondoodkin / expirering-blocklist-waiting-queue.js
Last active February 5, 2024 15:58
this queue lets run not related tasks in parallel,
type Task = () => Promise<void> | void;
export class TTLCache {
cache: Map<string, number> = new Map();
set(key: string, ttl: number): void {
const expiresAt = Date.now() + ttl * 1000; // Convert TTL to milliseconds
this.cache.set(key, expiresAt);

The following is result of interaction with chat.bing.com

input: GSK-3 inhibitor and dyrk1a inhibitor , is there common or similar functionality?

Searching for: GSK-3 inhibitor and dyrk1a inhibitor

Searching for: GSK-3 inhibitor and dyrk1a inhibitor common or similar functionality

Generating answers for you…

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@shimondoodkin
shimondoodkin / fourex.py
Created April 2, 2022 08:03 — forked from tartakynov/fourex.py
Fourier Extrapolation in Python
import numpy as np
import pylab as pl
from numpy import fft
def fourierExtrapolation(x, n_predict):
n = x.size
n_harm = 10 # number of harmonics in model
t = np.arange(0, n)
p = np.polyfit(t, x, 1) # find linear trend in x
x_notrend = x - p[0] * t # detrended x
@shimondoodkin
shimondoodkin / toast.js
Created October 13, 2021 15:06
tiny vanilla JavaScript toast notification
var toast_top=8;
function toast(text,timeoutMs)
{
let atoast = document.createElement('div');
with(atoast.style) {
backgroundColor='#fef7e6'; border='1px solid #f0ac00';
boxShadow='5px 10px #888888'; color='#000000'; padding='8px';
left="50%"; width='-50%'; top=toast_top+'px'; display='block'; position='fixed';
zIndex=10000; }
atoast.innerText=text;
@shimondoodkin
shimondoodkin / eslintFormatter.js
Last active October 12, 2021 17:32
react-scripts start print errors with full filename search <<< in this file to know the changes
// file: node_modules/react-dev-utils/eslintFormatter.js
//
// I had thousands of errors it is hard to visit each., here is a simple fix, to have
// filename with line number for each error
//
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
@shimondoodkin
shimondoodkin / applemusic.js
Last active January 8, 2022 19:09
v1 apple music fixed 15 minutes timeout.
/* eslint-disable */
! function(e, t) {
"object" == typeof exports && "undefined" != typeof module ? t(exports) : "function" == typeof define && define.amd ? define(["exports"], t) : t(e.MusicKit = {})
}(this, function(e) {
"use strict";
var t = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
function unwrapExports(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e
@shimondoodkin
shimondoodkin / OpenIdRawRequestToken.java
Last active January 19, 2021 01:52
should be good for java 1.6
package open_id_raw_request_token;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
@shimondoodkin
shimondoodkin / opencv_helpers.hpp
Last active October 10, 2020 20:13 — forked from enpe/main.cpp
Deleting N rows (or columns) from cv::Mat.
void MatRemoveRows(cv::Mat& matIn, int row, int rowCount=1)
{
cv::Size size = matIn.size();
cv::Mat matOut(size.height - rowCount, size.width, matIn.type());
if (!(matIn.isContinuous() && matOut.isContinuous())) throw "both should be continous"; //fix later if required, maybe use the rect solution if not continious https://gist.github.com/enpe/369a7a17fd9b3856b544 OR use as https://kezunlin.me/post/61d55ab4/
int rowSizeInBytes = size.width * sizeof(matIn.elemSize());
//simple and correct math for money arithmetics
Number.prototype.add=function(a){ return parseFloat((this+a).toFixed(15)) };
Number.prototype.sub=function(a){ return parseFloat((this-a).toFixed(15)) };
Number.prototype.mul=function(a){ return parseFloat((this*a).toFixed(15)) };
Number.prototype.div=function(a){ return parseFloat((this/a).toFixed(15)) };
// use with one number each time.
// > 0.1.add(0.1).add(0.1).mul(10).div(10)