Skip to content

Instantly share code, notes, and snippets.

View abhikhatri's full-sized avatar
💭
I may be slow to respond.

Abhi Khatri abhikhatri

💭
I may be slow to respond.
View GitHub Profile
@abhikhatri
abhikhatri / selection-prevent
Created May 20, 2015 13:27
Prevent user from selecting elements on all browsers including mobile safari & chrome
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
@abhikhatri
abhikhatri / smooth-scroll-jquery
Created September 28, 2015 05:47
Simple jquery function to smooth scroll on in-page links
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
browser-sync start --server --directory true --files "**/*.css, **/*.js, **/*.html"
@abhikhatri
abhikhatri / bootstrap-3-carousel-keyboard.js
Created December 10, 2015 05:27 — forked from dylanvalade/bootstrap-3-carousel-keyboard.js
Bootstrap carousel keyboard event controls for next and previous slides.
@abhikhatri
abhikhatri / client.js
Created August 23, 2016 12:47 — forked from crtr0/client.js
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
//Resize to Width Height
ffmpeg -i input.mp4 -s WxH -qscale 0 -vcodec mpeg4 output.mp4
//Compress the output file
ffmpeg -i output.mp4 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -vcodec h264 -acodec mp2 output-final.mp4
browserName: 'chrome',
chromeOptions: {
binary: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome',
args: [
'headless',
// Use --disable-gpu to avoid an error from a missing Mesa
// library, as per
// https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
'disable-gpu',
]
@abhikhatri
abhikhatri / VsCode-List-Extensions
Created October 17, 2018 06:22
command to list all the extensions to install in other machine
code --list-extensions | xargs -L 1 echo code --install-extension
@abhikhatri
abhikhatri / Snapshot Delete
Last active November 13, 2018 08:18
Rough Snippet to delete snap in firebase
ref.orderByChild('key').equalTo('something').once('value')
.then(function (snap) {
snap.forEach(function (snap) {
if (item.key === '-LTRAB3DKkK4FC765') {
snap.remove();
}
});
});
@abhikhatri
abhikhatri / loopback-automigration
Created January 6, 2019 15:14
Loopback script to migrate tables for default tables boot/server.js. EOS
//Importing the db structure for default apps
var appModels = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role'];
var ds = app.dataSources.postgres;
ds.isActual(appModels, function (err, actual) {
if (!actual) {
ds.autoupdate(appModels, function (err) {
if (err) throw (err);
});
}