Skip to content

Instantly share code, notes, and snippets.

Avatar

Shimon Doodkin shimondoodkin

View GitHub Profile
@shimondoodkin
shimondoodkin / fourex.py
Created April 2, 2022 08:03 — forked from tartakynov/fourex.py
Fourier Extrapolation in Python
View fourex.py
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
View toast.js
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
View eslintFormatter.js
// 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.
View applemusic.js
/* 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
View OpenIdRawRequestToken.java
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.
View opencv_helpers.hpp
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());
View money-arithmetics-prototype.js
//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)
View digging through node.js modules
function s(m,n){ var x=n&&m.children.filter(function(e){return e.filename.indexOf(n)!=-1})||[]; if(x.length) return x[0]; else console.log(n+' not found',m.children.map(function(e){return e.filename})); }
s(require.main)
to print a list
var xapp=s(require.main,'app')
@shimondoodkin
shimondoodkin / encaspulating header protocol
Created May 7, 2016 14:02
encapsulating header protocol, to minimize use of JSON.parse, which is cpu inefficient
View encaspulating header protocol
// encapsulating header protocol:
//
// FAQ:
//
// why it is useful?, answer: to minimize use of JSON.parse, which is cpu inefficient.
//
// where ware it was inteded to be used? answer: on a plain socket or a websocket, like sockjs.
//
// note: there is a similar "STOMP" protocol, which is simpler(not encapsulating).
//
@shimondoodkin
shimondoodkin / php_tiny_curl.php
Last active March 7, 2021 02:39
php tiny curl - a curl function with method, data, headers, cookies, simple to use.
View php_tiny_curl.php
function encodeURIComponent($str) {
$revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
return strtr(rawurlencode($str), $revert);
}
class curl_onHeaders
{