Skip to content

Instantly share code, notes, and snippets.

View Amitesh's full-sized avatar

Amitesh Kumar Amitesh

View GitHub Profile
@Amitesh
Amitesh / flatten.js
Created December 5, 2016 17:38
Flatten the deep nested array
/**
* Function to flatten the deep array
*/
var sampleArray = [[1, 2],[3, 4, 5], [6, 7, 8, 9]];
// Solution for single level nested array
[].concat.apply([], sampleArray);
// If we want deep flatten then we can use recursive function strategy
@Amitesh
Amitesh / gist:85533c34d8f6ca5914d4ce9206836c03
Last active October 3, 2016 10:29
Create recent application dock item in Mac
Create recent application dock item in Mac
defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }' && killall Dock
https://discussions.apple.com/thread/3217726?tstart=0
Use smart folder option to create recent filter in sidebar.
@Amitesh
Amitesh / sublime-text3-users-keybindings
Created March 5, 2016 20:32
sublime text3 keybindings
[
{ "keys": ["alt+d"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["alt+w"], "command": "toggle_setting", "args": {"setting": "word_wrap"} },
{ "keys": ["ctrl+b"], "command": "toggle_side_bar" }
]
@Amitesh
Amitesh / sublime-text3-plugin-list
Last active May 2, 2017 11:38
My Choice of Sublime text 3 plugin list
Alignment
Terminal
DocBlocker
Emmet
trimmer
csscomb
Color Highlighter
jsFormat
plainTask
AllAutocomplete
@Amitesh
Amitesh / linear-congruential-generator.js
Created September 30, 2015 11:37
A linear congruential generator (LCG) is an algorithm that yields a sequence of pseudo-randomized numbers calculated with a discontinuous piecewise linear equation.
/**
* Linear Congruential Generator
* http://en.wikipedia.org/wiki/Linear_congruential_generator
*/
function RandomNumberGeneratorFn($log) {
'use strict';
$log = $log || console;
@Amitesh
Amitesh / table.css
Last active August 29, 2015 14:25
Table Sorting, Filtering - Fixed the empty cell filtering issue http://www.javascripttoolbox.com/lib/table/index.php
/* Striping */
tr.alternate {
background-color:#ffffcc;
}
/* Sorting */
th.table-sortable {
cursor:pointer;
background-position:center left;
background-repeat:no-repeat;
@Amitesh
Amitesh / color-console-messages.js
Last active August 29, 2015 14:23
Color console messages in chrome and firefox
console.log('%cHello world', 'font-size:100px;color:#fff;text-shadow:0 1px 0 #ccc,0 2px 0 #c9c9c9,0 3px 0 #bbb,0 4px 0 #b9b9b9,0 5px 0 #aaa,0 6px 1px rgba(0,0,0,.1),0 0 5px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.3),0 3px 5px rgba(0,0,0,.2),0 5px 10px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.2),0 20px 20px rgba(0,0,0,.15);');
@Amitesh
Amitesh / click-toggle.js
Created May 6, 2015 06:34
Click Toggle jQuery Plugin
(function($) {
$.fn.clickToggle = function(func1, func2) {
var funcs = [func1, func2];
this.data('toggleclicked', 0);
this.click(function() {
var data = $(this).data();
var tc = data.toggleclicked;
$.proxy(funcs[tc], this)();
data.toggleclicked = (tc + 1) % 2;
});
@Amitesh
Amitesh / question_render.js
Created April 20, 2015 18:13
sample-code-snippets
/**
* Module for QHash Application
* @author : Amitesh Kumar
*
*/
window.QHash = window.QHash || {};
( function ( QHash ) {
/**
* Answer Model
@Amitesh
Amitesh / gist:5719948
Created June 6, 2013 07:46
Add new device to eclipse for android development
sudo vi /etc/udev/rules.d/99-android.rules
http://developer.android.com/tools/device.html
http://www.reactivated.net/writing_udev_rules.html
http://eagle.phys.utk.edu/guidry/android/installOnDevice.html