Skip to content

Instantly share code, notes, and snippets.

View imbdb's full-sized avatar
🎯
Focusing

Bharat D Bhadresha imbdb

🎯
Focusing
View GitHub Profile
@imbdb
imbdb / Node_port80_EACCESS_Solution.sh
Last active October 1, 2016 08:19
Node Port 80 EACCESS Solution
/*For Linux
Just run these two lines and you are good to go*/
sudo apt-get install libcap2-bin
sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``
@imbdb
imbdb / Solution_To_Nginx_Wordpress_Permission.sh
Last active October 1, 2016 08:29
Permission Problems Running WordPress on Nginx
chown -Rf www-data:www-data <path-to-wordpress>
@imbdb
imbdb / Find_Process_on_Port.sh
Created October 1, 2016 08:34
Find Process running on port Linux
sudo netstat -nlp | grep :<port>
@imbdb
imbdb / CountDown_Timer.html
Created October 6, 2016 21:50
CountDown Timer (Pure JS and CSS)
<html class=""><head>
<style class="cp-pen-styles">body{
text-align: center;
background: lightgrey;
font-family: sans-serif;
font-weight: 100;
}
@imbdb
imbdb / Handle_Events_on_Dynamically_Generated_Elements.js
Last active May 22, 2017 11:36
jQuery : handle events of dynamically generated elements
//SCDGE : Selector of Container containing dynamically generated element
//SDGE : Selector of Dynamically Generated elements
jQuery(<SCDGE>).on('focus',<SDGE>,function () {
var footerHeight = 200; //footerHeight = footer height + element height + buffer
var element = $(this);
if (element.offset().top - ($(window).scrollTop()) > ($(window).height() - footerHeight)) {
$('html, body').animate({
scrollTop: element.offset().top - ($(window).height() - footerHeight)
}, 500);
@imbdb
imbdb / jsonsearch.js
Created November 8, 2016 13:37
JS function to get index of json object in array
//Usage
//jsonSearch(jsonArray,{'key':'value})
var jsonSearch = function(json_array,needle){
return json_array.map(function(d) { return d[Object.keys(needle)[0]]; }).indexOf(needle[Object.keys(needle)[0]])
};
[ng\:cloak],
[ng-cloak],
[data-ng-cloak],
[x-ng-cloak],
.ng-cloak,
.x-ng-cloak {
display: none !important;
}
@imbdb
imbdb / safeapply.js
Created December 8, 2016 06:21
Angular safeApply
$scope.safeApply = function(fn) {
var phase = this.$root.$$phase;
if (phase == '$apply' || phase == '$digest') {
if (fn && (typeof(fn) === 'function')) {
fn();
}
} else {
this.$apply(fn);
}
};
@imbdb
imbdb / PHP_read_raw_data.php
Created December 25, 2016 07:51
PHP read raw data
$data = file_get_contents("php://input");
@imbdb
imbdb / addCommas.js
Created January 21, 2017 11:37
addCommas function to add commas in any amount string
var addCommas = function(nStr) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;