Skip to content

Instantly share code, notes, and snippets.

View Munawwar's full-sized avatar
🍪
Cookies

Munawwar Firoz Munawwar

🍪
Cookies
View GitHub Profile
@Munawwar
Munawwar / array-diff.html
Last active April 29, 2023 08:56
O(n) array diff & patch algorithm in JavaScript (unlike LCS, this is a trade-off for speed than minimum changes).
<html>
<body>
<script>
/**
* This array diff algorithm is useful when one wants to detect small changes
* (like consecutive insertions or consecutive deletions) several times
* in short time intervals. Alternative algorithms like LCS woud be too expensive
* when running it too many times.
*/
@Munawwar
Munawwar / systemjs-less-cacher.js
Last active August 12, 2016 11:36
SystemJS LESS transpiling & caching plugin (uses IndexedDB, which is cleared after each session).
/*global Promise, console*/
/**
* Usage:
* Promise.all([
* System.import('./systemjs-less-cacher.js'),
* System.import('./less.js')
* ]).then(function (values) {
* var lessCacher = values[0],
* less_browser = values[1],
* url = 'localhost/some.less',
@Munawwar
Munawwar / segmentation1.py
Created August 29, 2016 13:56
Background Removal with OpenCV - Attempt 1 (http://codepasta.com/site/vision/segmentation/)
import numpy as np
import cv2
def getSobel (channel):
sobelx = cv2.Sobel(channel, cv2.CV_16S, 1, 0, borderType=cv2.BORDER_REPLICATE)
sobely = cv2.Sobel(channel, cv2.CV_16S, 0, 1, borderType=cv2.BORDER_REPLICATE)
sobel = np.hypot(sobelx, sobely)
return sobel;
@Munawwar
Munawwar / poc-cnn-svm-ounass.py
Last active September 26, 2018 17:04
Ounass image matching
import os
import tensorflow as tf
import tensorflow.python.platform
from tensorflow.python.platform import gfile
import numpy as np
from shutil import copyfile
#from sklearn import cross_validation, grid_search
#from sklearn.metrics import confusion_matrix, classification_report
from sklearn.svm import SVC
@Munawwar
Munawwar / Cordova-Install-Android.md
Last active August 19, 2017 08:33
Cordova Android dev setup

Down android sdk tool (without Android studio)

android-sdk/tools/android update sdk

Platform tools for Kitkat+ (Chrome webview is supported from KitKat onwards)

android-sdk/tools/bin/sdkmanager "platforms;android-19" "add-ons;addon-google_apis-google-19" "build-tools;19.1.0"

sudo apt install gradle

@Munawwar
Munawwar / caffee-install.md
Last active August 12, 2017 20:12
Buidling Caffe
@Munawwar
Munawwar / randomlyDistributedHash.js
Last active June 23, 2021 09:37
randomlyDistributedHash
// Deprecated: Dont use this. Just use fnv1a hash
function randomlyDistributedHash(s) {
// fnv1a hash
var h = 0x811c9dc5;
for (var i = 0, l = s.length; i < l; i++) {
h ^= s.charCodeAt(i);
h += (h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24);
}
h = (h >>> 0);
@Munawwar
Munawwar / leonardo-distribute.js
Created January 16, 2020 07:30
leonardocolor.io contrast distribution
const d3 = require('d3');
const d3hsluv = require('d3-hsluv');
const { generateContrastColors } = require('./leonardo');
Object.assign(d3, d3hsluv);
function interpolateLumArray(newColors) {
const lums = [];
for (let i = 0; i < newColors.length; i += 1) {
@Munawwar
Munawwar / redis-concurrency-control.js
Last active July 12, 2021 16:22
Redis concurrency control
const redis = require('redis');
const bluebird = require('bluebird');
const redisClient = redis.createClient({});
bluebird.promisifyAll(Object.getPrototypeOf(redisClient));
const luaScript = `
local newPayload = ARGV[1]
local newVersionStr, newData = ARGV[1]:match("^([0-9]+)|(.+)$")
local prevVal = redis.call("get", KEYS[1]) or nil
@Munawwar
Munawwar / upload.sh
Last active February 29, 2020 07:12
Simple node.js rsync
# exclude node_modules folder and files like .DS_STORE on OSX
rsync -rv --exclude 'node_modules' --exclude '.*' --delete-after --ignore-errors . [email protected]:AppDirectory/
# execute yarn install
ssh [email protected] 'cd AppDirectory && yarn install'