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 / win32-node-installer
Created February 26, 2024 12:09 — forked from manuelbieh/win32-node-installer
Install node.js on Windows silently
1. Download the recent version from nodejs.org
2. Run `msiexec /qn /l* node-log.txt /i node-vX.X.XX-x64.msi`
@imbdb
imbdb / redirect-conditional.js
Created January 10, 2022 11:48
Function to redirect page based on condition
function redirect(sentence){
if(sentence.contains('airport'){
window.location('/airport')
}
else{
window.location('/home')
}
}
// Test function
@imbdb
imbdb / hotstar_domainlist.txt
Created June 24, 2021 06:58
Hotstar domains list
www.hotstar.com
hsprepack.akamaized.net
live09p.hotstar.com
live11p.hotstar.com
api.hotstar.com
webos.hotstar.com
tizen.hotstar.com
live12p.hotstar.com
hses3.akamaized.net
live11p.akt.hotstar-cdn.net
@imbdb
imbdb / get_formatted_date.js
Last active November 8, 2019 06:46
Takes a native date object and returns string containing date the specified format
/*
Takes a native date object and returns string containing date the specified format
Format segments are
{{dd}} - 2 digit date
{{D}} - Day of week
{{mm}} - 2 digit month
{{mmm}} - 3 letter month
{{MMM}} - Full month
{{yyyy}} - 4 digit year
{{H}} - 2 digit hour (24 hours)
@imbdb
imbdb / webkit-scrollbar.css
Created July 12, 2019 13:53
design-scrollbar-webkit
*::-webkit-scrollbar-track {
background: rgba(255,255,255,0.08);
}
*::-webkit-scrollbar-thumb {
background-color: rgba(0,0,0,0.2);
}
*::-webkit-scrollbar {
width: 6px !important;
height: 6px !important;
}
@imbdb
imbdb / rename-to-numbers.sh
Created July 5, 2019 10:37
Rename all files to numbers
# Find all files with specified pattern using find and then mv them to new numbered name
# eg. abc.jpeg, sdfs.jpeg,... --> 0001.jpeg,0002.jpeg,...
find -iname '*.jpeg' | # find files
gawk 'BEGIN{ a=1 }{ printf "mv \"%s\" \"%04d.jpeg\"\n", $0, a++ }' | # build mv command ( Change 04d(0000) to your number your files)
bash
@imbdb
imbdb / pdf-to-png.py
Created July 5, 2019 10:33
Extract PDF pages as PNG
# Uses convert cmdline tool
import os
def main():
dir_list = os.listdir('./pdfs') # change to your pdf directory
for full_file_name in dir_list:
base_name, extension = os.path.splitext(full_file_name)
if extension == '.pdf': # then .pdf file --> convert to image!
cmd_str = ' '.join(['convert',
'"./pdfs/' + full_file_name + '"', # change to your pdf directory
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));
// Internet Explorer 6-11
@imbdb
imbdb / bootstrap-affix.min.js
Created October 24, 2017 14:53
Just minified version of Bootstrap 2.3.2 Affix plugin
!function ($) {"use strict";var Affix = function (element, options) {this.options = $.extend({}, $.fn.affix.defaults, options);this.$window = $(window).on('scroll.affix.data-api', $.proxy(this.checkPosition, this)).on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this));this.$element = $(element);this.checkPosition();};Affix.prototype.checkPosition = function () {if (!this.$element.is(':visible')) return;var scrollHeight = $(document).height(), scrollTop = this.$window.scrollTop(), position = this.$element.offset(), offset = this.options.offset, offsetBottom = offset.bottom, offsetTop = offset.top, reset = 'affix affix-top affix-bottom', affix;if (typeof offset != 'object') offsetBottom = offsetTop = offset;if (typeof offsetTop == 'function') offsetTop = offset.top();if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(); affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?false : offsetBottom != null && (position.top
@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;