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 / caffee-install.md
Last active August 12, 2017 20:12
Buidling Caffe
@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 / 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 / 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 / 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 / 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.
*/
<!DOCTYPE html>
<html>
<head>
</head>
<script>
/**
* The problem: Binding functions (using function.bind()) and adding listeners is messy,
* since a bind creates a new function everytime and one needs to keep reference to the new function.
* When having many event handlers this gets messy.
*
/**
* jQuery 2.1.3's parseHTML (without scripts options).
* Unlike jQuery, this returns a DocumentFragment, which is more convenient to insert into DOM.
* MIT license.
*
* If you only support Edge 13+ then try this:
function parseHTML(html, context) {
var t = (context || document).createElement('template');
t.innerHTML = html;
return t.content;
@Munawwar
Munawwar / html-validator.js
Last active April 18, 2022 07:38
Unbalanced HTML markup detection
/**
* Detect unsafe (and potentially unsafe) unbalanced tags in a given HTML snippet.
* Hints taken from an html parse (https://gist.github.com/cburgmer/2877758).
*
* Example:
* An unclosed div tag is considered unsafe, because if the snippet is pasted in between two div tags
* then it could end up breaking the HTML document.
* Self closing tags (tags that you can intentioanlly leave open like <table><tr><td>some text</table>) are also considered unsafe, for the same reason.
* However an unclosed void tag (like meta tag) is safe, because browsers will ignore it without any side effects.
*
@Munawwar
Munawwar / contrast.js
Last active December 31, 2015 17:09
Two functions: i. To find contrast (actually luma) ratio of two colors. ii. To find contrast grey shade of any color.
/* Taken from http://stackoverflow.com/a/13558570.
* aka inverse gamma. Some call it "inverse sRGB companding".
* All the constants are taken from sRGB spec.
* Read about it at http://en.wikipedia.org/wiki/SRGB (I didn't understand how they derived the approximation).
*/
function linear(R) { //in sRGB as hex string
var s = parseInt(R, 16) / 255;
if (s <= 0.04045) {
return s / 12.92;
} else {