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.
$ python -m SimpleHTTPServer 8000Each 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.
$ python -m SimpleHTTPServer 8000Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
| { | |
| "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", |
| // 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]); | |
| ); |
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.
| 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"; | |
| } |
| // 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 |
| axios({ | |
| url: 'http://localhost:5000/static/example.pdf', | |
| method: 'GET', | |
| responseType: 'blob', // important | |
| }).then((response) => { | |
| const url = window.URL.createObjectURL(new Blob([response.data])); | |
| const link = document.createElement('a'); | |
| link.href = url; | |
| link.setAttribute('download', 'file.pdf'); | |
| document.body.appendChild(link); |
| var BASE64_MARKER = ';base64,'; | |
| function convertDataURIToBinary(dataURI) { | |
| var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length; | |
| var base64 = dataURI.substring(base64Index); | |
| var raw = window.atob(base64); | |
| var rawLength = raw.length; | |
| var array = new Uint8Array(new ArrayBuffer(rawLength)); | |
| for(i = 0; i < rawLength; i++) { |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| Version 2, December 2004 | |
| Copyright (C) 2011 Jed Schmidt <http://jed.is> | |
| Everyone is permitted to copy and distribute verbatim or modified | |
| copies of this license document, and changing it is allowed as long | |
| as the name is changed. | |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |