Skip to content

Instantly share code, notes, and snippets.

View shimondoodkin's full-sized avatar

Shimon Doodkin shimondoodkin

View GitHub Profile
//
// 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 / 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());
@shimondoodkin
shimondoodkin / app.js
Last active January 3, 2016 23:39 — forked from katanacrimson/app.js
nodejs app - expressjs 3.0 + socket.io v9 + passport + redis (made to work)
var express = require('express'),
passport = require('passport'),
GoogleStrategy = require('passport-google').Strategy,
connect = require('express/node_modules/connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
var express = require('express'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
connect = require('connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
/* based off of tinyxhr by Shimon Doodkin - license: public doamin - https://gist.github.com/4706967
Added ontop of Simon's code:
- Serialization of the object
- Moved some arguments to line up with jQuery( url, data, callback )
- Will attempt to parse JSON from the response if it's valid JSON
- Added a tinyPost and tinyGet method
Some other things that'd be good:
- Seprate error callback for failed responses
/*
These next two functions work together to lock down bbPress forums based on PMPro membership level.
Check that the current user has access to this forum. Be sure to update the $restricted_forums array based on your needs.
*/
function pmpro_check_forum()
{
global $current_user;
/*
//licence: 2 clouse mit, by Shimon Doodkin
function ObserverPubSub(parent, key_of_myself) {
this._topics = {};
this.length = 0;
this._subUid = -1;
this._parent = parent;
this._name = key_of_myself;
}
ObserverPubSub.prototype = {
@shimondoodkin
shimondoodkin / APPNAME
Created July 2, 2011 17:33 — forked from peterhost/node_debian_init.sh
init.d script for node.js for debian
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
/*
It looks like there is a problem with http
If I define the on end and on data callbacks (too late) - like
after like 120 ms (like after all data is transfered)
it does not calls the callbacks (on data, on end).
or maybe because it is clousre inside a clousre,
the request object looks okay, but it does not fire the events,