Skip to content

Instantly share code, notes, and snippets.

@christowiz
christowiz / web-servers.md
Created Mar 2, 2021 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

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
@christowiz
christowiz / web-servers.md
Created Mar 2, 2021 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

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
View console.js
// time and time end
console.time("This");
let total = 0;
for (let j = 0; j < 10000; j++) {
total += j
}
console.log("Result", total);
console.timeEnd("This");
// Memory
View git-rewrite-to-subfolder
#!/bin/bash
# We need the TAB character for SED (Mac OS X sed does not understand \t)
TAB="$(printf '\t')"
function abort {
echo "$(tput setaf 1)$1$(tput sgr0)"
exit 1
}
@christowiz
christowiz / docker-cleanup-resources.md
Created Dec 13, 2018 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks
View docker-cleanup-resources.md

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
View scroller.js
'use strict';
// * Scroll optimization using window.requestAnimationFrame
// *
// * https://developer.mozilla.org/en-US/docs/Web/Events/scroll
// *
// * @module scroller
// * @param {Object} element DOM element to attach listener to
// * @param {Func} cb Callback method to return event object
// * @returns {Func} Method to remove event listener from element