Skip to content

Instantly share code, notes, and snippets.

@jarodium
jarodium / sw.js
Created December 25, 2018 15:12
Service Worker
'use strict';
var cacheVersion = 1;
var currentCache = {
offline: 'offline-cache' + cacheVersion
};
const offlineUrl = 'offline.html';
this.addEventListener('install', event => {
event.waitUntil(
@jarodium
jarodium / test1.php
Last active November 5, 2019 20:05
Predominant color with VIPS
<?php
require '../vendor/autoload.php';
use Jcupitt\Vips;
Vips\Config::concurrencySet(2);
Vips\Config::CacheSetMax(0);
//header("Content-type: text/plain");
//var_dump($_REQUEST);
$mime = "jpeg";
@jarodium
jarodium / downloader.js
Created July 3, 2020 12:19 — forked from jhidalgo3/downloader.js
Use NodeJS to download files
var path = require('path');
var url = require('url');
var http = require('http');
var fs = require('fs');
var write_file;
//what global variable do we have?
var complete = false;
var content_length = 0;
var downloaded_bytes = 0;
@jarodium
jarodium / sticky.js
Created April 26, 2022 16:02 — forked from javierarques/sticky.js
Sticky Sideabr With Vanilla Javascript. Detects scroll and set fixed the element. Live example: http://codepen.io/javiarques/pen/vKdgjR
// Sticky Nav Component
var Sticky = (function() {
'use strict';
var CSS_CLASS_ACTIVE = 'is-fixed';
var Sticky = {
element: null,
position: 0,
addEvents: function() {
@jarodium
jarodium / history_navigation.js
Created November 2, 2022 09:35 — forked from serin113/history_navigation.js
A simple JavaScript that lets you use your browser's back/forward buttons for in-page navigation by adding custom 'next' and 'previous' events to the window object.
/*
* Lets you use your browser's back/forward buttons for in-page navigation by
* adding custom 'next' and 'previous' events to the window object.
*
* Copyright (c) 2011 Tobias Schneider <[email protected]>
* This script is freely distributable under the terms of the MIT license.
*
* Example:
*
* window.addEventListener('next', function(){
@jarodium
jarodium / removehash.js
Created November 2, 2022 10:25
Remove hash
function removeHash () {
var scrollV, scrollH, loc = window.location;
if ("pushState" in history)
history.replaceState("", document.title, loc.pathname + loc.search);
else {
// Prevent scrolling by storing the page's current scroll offset
scrollV = document.body.scrollTop;
scrollH = document.body.scrollLeft;
loc.hash = "";
// Restore the scroll offset, should be flicker free
@jarodium
jarodium / script.turf-sandbox
Created December 1, 2022 13:49
turf-sandbox snippet
// simply return a valid GeoJSON and it will be rendered on the map
const a = turf.point(
[ -7.934943903756626, 37.01653427320952 ] ,
{'marker-symbol': 'rocket', 'marker-color': '#F00', 'marker-size': 'large'}
);
const b = turf.point(
[ -7.934943723892553, 37.01653427320952 ] ,
{'marker-symbol': 'rocket', 'marker-color': '#F0F', 'marker-size': 'large'}
@jarodium
jarodium / script.turf-sandbox
Created December 1, 2022 13:56
turf-sandbox snippet
// simply return a valid GeoJSON and it will be rendered on the map
const a = turf.point(
[ -7.935754126611641, 37.015448047817706 ] ,
{'marker-symbol': 'rocket', 'marker-color': '#F00', 'marker-size': 'large'}
);
const b = turf.point(
[ -7.935753143724182, 37.01589770731469 ] ,
{'marker-symbol': 'rocket', 'marker-color': '#F0F', 'marker-size': 'large'}
@jarodium
jarodium / script.turf-sandbox
Created December 1, 2022 14:07
turf-sandbox snippet
// simply return a valid GeoJSON and it will be rendered on the map
const a = turf.point(
[ -7.935581406636273, 37.01906884977351 ] ,
{'marker-symbol': 'rocket', 'marker-color': '#F00', 'marker-size': 'large'}
);
const b = turf.point(
[ -7.935580423701978, 37.0195185092705 ] ,
{'marker-symbol': 'rocket', 'marker-color': '#F0F', 'marker-size': 'large'}
@jarodium
jarodium / script.turf-sandbox
Created December 5, 2022 22:27
turf-sandbox snippet
// simply return a valid GeoJSON and it will be rendered on the map
const polyRecursos = turf.polygon([[
[-7.9433882,37.0254615],[-7.9435303,37.0252195],[-7.9434177,37.0251639],[-7.9432889,37.0251296],[-7.9430636,37.0251125],[-7.9431414,37.0253202],[-7.9433882,37.0254615]
]],
{stroke: '#0FF', fill: '#0FF', 'fill-opacity': 0.3, 'stroke-width': 6}
);
const poly = turf.polygon([[
[-7.9434775157632815,37.024837920790766],
[-7.943964787435284,37.02506342920393],