Skip to content

Instantly share code, notes, and snippets.

View gokulkrishh's full-sized avatar

Gokulakrishnan Kalaikovan gokulkrishh

View GitHub Profile
@gokulkrishh
gokulkrishh / Atom Editor Config
Last active November 18, 2015 17:46
Atom editor config
3dd2222c-c7ea-ebf2-c4fb-86c36ffbe4ed
"*":
"exception-reporting":
userId: "3dd2222c-c7ea-ebf2-c4fb-86c36ffbe4ed"
welcome:
showOnStartup: false
core:
themes: [
@gokulkrishh
gokulkrishh / objectObserve.js
Created November 3, 2015 07:33
Use Object.observe with polyfill
/*
Example for Object.observe
Polyfill: https://github.com/MaxArt2501/object-observe
Detects: Add, Update, Delete properties
Supported Browser: http://caniuse.com/object-observe
@gokulkrishh
gokulkrishh / sublime user.json
Last active November 19, 2015 06:02
Sublime user configuration for dotfile
{
"auto_complete": true,
"bold_folder_labels": true,
"caret_extra_width": 2,
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
"CVS",
@gokulkrishh
gokulkrishh / Atom Config.cson
Created November 19, 2015 06:04
Atom Editor configuration
"*":
welcome:
showOnStartup: false
core:
themes: [
"atom-dark-ui"
"one-dark-syntax"
]
editor:
invisibles: {}
@gokulkrishh
gokulkrishh / Align an element horizontally & vertically center in css.markdown
Created January 7, 2016 07:18
Align an element horizontally & vertically center in css
@gokulkrishh
gokulkrishh / basicServiceWorker.js
Created January 14, 2016 03:57 — forked from adactio/basicServiceWorker.js
A basic Service Worker, for use on, say, a blog.
'use strict';
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function() {
// Update 'version' if you need to refresh the cache
var staticCacheName = 'static';
var version = 'v1::';
@gokulkrishh
gokulkrishh / sw.js
Last active February 11, 2016 12:08
Service worker installation steps
//Cache polyfil to support cacheAPI in browsers
importScripts('/cache-polyfill.js');
//Cache name
var staticCache = "my-static-files";
//Files to cache
var filesToCache = [
"/",
"images/logo.jpg",
@gokulkrishh
gokulkrishh / sw.js
Last active July 21, 2020 14:38
Service worker fetch event
//After install, fetch event is triggered for every page request
self.addEventListener("fetch", function (event) {
console.log("Request -->", event.request.url);
//To tell browser to evaluate the result of event
event.respondWith(
caches.match(event.request) //To match current request with cached request it
.then(function(response) {
//If response found return it, else fetch again.
return response || fetch(event.request);
@gokulkrishh
gokulkrishh / sw.js
Last active February 11, 2016 12:37
Service worker activate event
//Activate event will be triggered once after registering, also used to clean up caches
self.addEventListener("activate", function (event) {
var cacheWhitelist = ['my-static-files'];
event.waitUntil(
caches.keys()
.then(function (allCaches) {
//Check all caches and delete old caches here
allCaches.map(function (cacheName) {
@gokulkrishh
gokulkrishh / Singly Linked List.js
Created February 27, 2016 04:25
Implementation of linked list in javascript
function singlyLinkedList() {
this.length = 0; //Default value
this.head = null;
}
//To store in a new node
function storeNode(data) {
this.data = data;
this.next = null;
};