Skip to content

Instantly share code, notes, and snippets.

View jhm-ciberman's full-sized avatar

Javier "Ciberman" Mora jhm-ciberman

View GitHub Profile
@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);
@CGavrila
CGavrila / singleton_es6.js
Created August 22, 2015 19:11
Singleton pattern in ECMAScript 6
let _singleton = Symbol();
class Singleton {
constructor(singletonToken) {
if (_singleton !== singletonToken)
throw new Error('Cannot instantiate directly.');
}
static get instance() {
@roNn23
roNn23 / laravel.js
Last active July 16, 2019 11:41 — forked from JeffreyWay/laravel.js
Updated delete-script of Jeffrey Way to work with Laravel 5. And optimized the implementation for the CSRF token. #laravel
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
Add this to your view:
<script>
window.csrfToken = '<?php echo csrf_token(); ?>';