Skip to content

Instantly share code, notes, and snippets.

Shimon Doodkin shimondoodkin

Block or report user

Report or block shimondoodkin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
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 Jan 9, 2018
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
{
View fix vanilla forum hhvm
fix vanilla forum hhvm
An iterator cannot be used with foreach by reference.
find /var/www/forum -type f -exec perl -i -p -e "s/(foreach.+?as\s*)&/\1/" {} \;
@shimondoodkin
shimondoodkin / bench.sh
Last active Nov 7, 2018
real vps server performance benchmark - the idea of this script is to predict performance of software
View bench.sh
#!/bin/bash
# if memory to memory is 0kb/s then the size is too large or problem writing /run/shm
# instant use:
# wget -O- https://gist.githubusercontent.com/shimondoodkin/defae1e5f9c1aaabb1c7/raw/bench.sh | size=150 bash
# wget -O- https://gist.githubusercontent.com/shimondoodkin/defae1e5f9c1aaabb1c7/raw/bench.sh | size=512 bash
# download then use
@shimondoodkin
shimondoodkin / learning matlab in an hour.md
Last active Oct 30, 2015
while learning machine learning i have noticed a very quick and efficient way to learn matlab syntax.
View learning matlab in an hour.md

from https://www.coursera.org/learn/machine-learning/supplement/Mlf3e/more-octave-matlab-resources

More Octave/MATLAB resources

Octave Resources At the Octave command line, typing help followed by a function name displays documentation for a built-in function. For example, help plot will bring up help information for plotting. Further documentation can be found at the Octave documentation pages.

MATLAB Resources At the MATLAB command line, typing help followed by a function name displays documentation for a built-in function. For example, help plot will bring up help information for plotting. Further documentation can be found at the MATLAB documentation pages.

@shimondoodkin
shimondoodkin / steamingFrequentTermsKeywords.java
Created Apr 28, 2015
steaming Frequent Terms from Keywords. basic algorithm
View steamingFrequentTermsKeywords.java
package com.nini;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
@shimondoodkin
shimondoodkin / ThinBTClient.java
Last active Aug 10, 2018
android vibrate a vibrating bluetooth bracelet
View ThinBTClient.java
/*
licence pubilc domain
prepered by Shimon Doodkin
vibrate a vibrating bluetooth bracelet
a simple bt client it sends "RING" AT command to a device named "BRACELET"
it is a good "android bluetooth client example".
@shimondoodkin
shimondoodkin / 1)src_MainActivity.java
Last active Jan 9, 2019
styling v21 compatibility android actionbar
View 1)src_MainActivity.java
package com.doodkin.example;
import android.support.v7.app.ActionBarActivity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
You can’t perform that action at this time.