Skip to content

Instantly share code, notes, and snippets.

View shimondoodkin's full-sized avatar

Shimon Doodkin shimondoodkin

View GitHub Profile
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
// 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.
function encodeURIComponent($str) {
$revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
return strtr(rawurlencode($str), $revert);
}
class curl_onHeaders
{
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 November 7, 2018 12:19
real vps server performance benchmark - the idea of this script is to predict performance of software
#!/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 October 30, 2015 11:58
while learning machine learning i have noticed a very quick and efficient way to learn matlab syntax.

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 April 28, 2015 23:35
steaming Frequent Terms from Keywords. basic algorithm
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 September 16, 2022 15:02
android vibrate a vibrating bluetooth bracelet
/*
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 January 9, 2019 10:05
styling v21 compatibility android actionbar
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;
apt-get install fail2ban
apt-get install iptables-persistent
apt-get install ufw
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh/tcp
ufw allow www
ufw allow smtp
ufw allow pop3
ufw enable