Skip to content

Instantly share code, notes, and snippets.

View robertoentringer's full-sized avatar
🖥️
Nomadic

Roberto Entringer robertoentringer

🖥️
Nomadic
View GitHub Profile
@robertoentringer
robertoentringer / Array.move.js
Created February 13, 2019 21:39
JavaScript Array move
// Append a move method to the Array prototype
Array.prototype.move = function(from, to) {
this.splice(to, 0, this.splice(from, 1)[0]);
return this;
};
// Start with an existing array
var orig = ["Sam", "Tom", "Ben", "Sophie"];
// Use the new method to move the last item in the array to the first position
@robertoentringer
robertoentringer / sw.js
Created February 4, 2019 09:29 — forked from ireade/sw.js
Handle broken images with the service worker
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}
@robertoentringer
robertoentringer / dnsmasq OS X.md
Created November 24, 2018 11:11 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.

Requirements

Install

@robertoentringer
robertoentringer / shuffle.js
Created May 30, 2018 10:33 — forked from guilhermepontes/shuffle.js
Shuffle array element ES2015, ES6
// original gist
const shuffleArray = arr => arr.sort(() => Math.random() - 0.5);
// fully random by @BetonMAN
const shuffleArray = arr => (
arr
.map(a => [Math.random(), a])
.sort((a, b) => a[0] - b[0])
.map(a => a[1]);
);
@robertoentringer
robertoentringer / package.json
Created April 16, 2018 14:19 — forked from addyosmani/package.json
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
@robertoentringer
robertoentringer / README.md
Created April 13, 2018 15:09 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@robertoentringer
robertoentringer / web-servers.md
Created April 13, 2018 02:08 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000