Skip to content

Instantly share code, notes, and snippets.

View amitmerchant1990's full-sized avatar

Amit Merchant amitmerchant1990

View GitHub Profile
@amitmerchant1990
amitmerchant1990 / keyboard_shortcut.js
Last active August 29, 2015 13:56
IMPLEMENT KEYBOARD SHORTCUTS FOR YOUR WEBSITE
$(document).ready(function() {
// I have used $(this) so it "listens" on any part of the webpage (document)
// Change this to a single or series of elements if required
$(this).live("keyup", function(e) {
if($("input, textarea").is(":focus")) {
// Do nothing because the user might be typing
return false;
} else {
switch(e.keyCode) {

My arbitrary thoughts

  • There are only 0b10 kinds of people; those who understand binary and those who don’t.
  • There is a dream I'm living.. There is a life I'm dreaming of.
  • Keep a green tree in your heart, the bird will come automatically.
  • For too long, you and I've been quiet..RISE UP!
@amitmerchant1990
amitmerchant1990 / ajax_abort.md
Last active August 29, 2015 13:56
JavaScript snippet for aborting ajax rquest if previous call has not been completed
jQuery(document).ready(function(){
    var currentRequest = null;
    jQuery('#searchbox').keyup(function() {
        var text = jQuery(this).val();
        currentRequest = jQuery.ajax({
            type: 'POST',
            data: 'search_text=' + text,
            url: 'AJAX_URL',
 beforeSend : function() { 
https://maven-global.slack.com/files/amit.merchant/F259FSJUW/correo-darwin-x64.zip
@amitmerchant1990
amitmerchant1990 / git-ingredients.md
Last active August 31, 2016 12:50
git-ingredients
git install on ubuntu
sudo apt-get install git

point your local repository to remote repository

git remote add origin git@....repo_url
@amitmerchant1990
amitmerchant1990 / hackernews_night_mode.css
Created November 9, 2016 09:22
HackerNews Night Mode
/**
A nifty little CSS to experience HN in night mode using Stylish.
1. Install the Stylish(https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe?hl=en) extension for Chrome.
2. Open up extension options and paste the whole CSS mentioned below.
3. Specify the "URLs on the domian to" to be `news.ycombinator.com`.
4. Add a title and save.
*/
body {
font-family: Verdana, Geneva, sans-serif;
@amitmerchant1990
amitmerchant1990 / github_code_previewer_dark_skin.css
Created November 9, 2016 12:29
GitHub Code Previewer Dark Skin
/**
A nifty little CSS to experience GitHub code previewer in Dark Skin using Stylish.
1. Install the Stylish(https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe?hl=en) extension for Chrome.
2. Open up extension options and paste the whole CSS mentioned below.
3. Add "URLs on the domian to" to be `render.githubusercontent.com`.
4 Add "URLs on the domian to" to be `raw.githubusercontent.com`.
4 Add "URLs matching the regexp" to be `^https?://((gist|guides|help|raw|status|developer).)?github.com((?!generated_pages/preview).)*$`.
4. Add a title and save.
*/
<html>
<head>
<title>Notepad - Offline capable</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#9b59b6">
<meta name="description" content="An offline capable notepad powered by ServiceWorker">
<meta name="keywords" content="note,offline,mobile,web,notepad" />
<meta name="author" content="Amit Merchant">
<meta name="application-name" content="Notepad" />
// Registering ServiceWorker
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
}
importScripts('js/cache-polyfill.js');
var CACHE_VERSION = 'app-v1';
self.addEventListener('install', function (event) {
event.waitUntil(
caches.open(CACHE_VERSION)
.then(function (cache) {
console.log('Opened cache');
return cache.addAll(CACHE_FILES);