Skip to content

Instantly share code, notes, and snippets.

View danielgindi's full-sized avatar

Daniel Cohen Gindi danielgindi

  • Self Employed, CTO at eyedo fielding technologies ltd.
  • Israel
View GitHub Profile
@danielgindi
danielgindi / get_distant_brightness_color.js
Created November 15, 2016 12:55
Find the color (out of an array of colors) that is most distant (brightness-wise) to the target color.
var getDistantBrightnessColor = (function () {
// Calculate grayscale color (luma) according to ITU-R Recommendation BT. 709
var grayscaleLuma709Color = function(color) {
return Math.round(0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b)
};
var linearDiffColor = function(color1, color2) {
return Math.abs(color1.r - color2.r) +
Math.abs(color1.g - color2.g) +
@danielgindi
danielgindi / exec_fun_w_args_isolated.js
Created September 18, 2016 12:50
JS: Execute function given name and args - in an isolate scope
var execIsolated = (function () {
var exec = function () {
arguments[0](arguments[1]);
};
return function (funcname, args) {
args = args || [];
@danielgindi
danielgindi / list_files_group_by_ext.sh
Last active April 3, 2016 14:12
(Linux) List file counts grouped by file extension
find ./ -maxdepth 1 -type f | grep -E ".*\.[a-zA-Z0-9]*$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq -c | sort -n
@danielgindi
danielgindi / numlock_on.sh
Last active January 17, 2016 09:24
Enable NumLock on Ubuntu by default
sudo apt-get -y install numlockx
sudo sed -i 's|^exit 0.*$|# Numlock enable\n[ -x /usr/bin/numlockx ] \&\& numlockx on\n\nexit 0|' /etc/rc.local
# http://askubuntu.com/questions/155679/how-to-enable-numlock-at-boot-time-for-login-screen