Reductio ad absurdum
| #!/usr/bin/env bash | |
| # Utility to change the connection method for a git repo. | |
| # === Colour Definitions === | |
| red='\e[0;31m' | |
| green='\e[0;32m' | |
| purple='\e[0;35m' | |
| orange='\e[0;33m' | |
| # No Color, i.e. turn off color |
| { | |
| "name": "npm-scripts-example", | |
| "version": "1.0.0", | |
| "description": "npm scripts example", | |
| "scripts": { | |
| "list?": "echo It lists all json files", | |
| "list": "ls *.json", | |
| "time?": "echo It prints current time in UTC", | |
| "time": "date -uIs", | |
| "numbers?": "echo It prints numbers from 1 to 10", |
| { | |
| "name": "npm-scripts-example", | |
| "version": "1.0.0", | |
| "description": "npm scripts example", | |
| "scripts": { | |
| "help-list": "echo It lists all json files", | |
| "list": "ls *.json", | |
| "help-time": "echo It prints current time in UTC", | |
| "time": "date -uIs", | |
| "help-numbers": "echo It prints numbers from 1 to 10", |
by Rafał Pocztarski
One of my answers on Stack Overflow where I explain the difference between promises and traditional callbacks on the example of AJAX in jQuery - jQuery: Return data after ajax call success - had a 4th birthday few days ago and it still gets upvotes so I decided to explain few concepts that I think are important but rarely considered.
I noticed that there are many people who prefer callbacks, or promises, or events - as though they were all equivalent ways to do the same thing in a different style - but they are not. Of course they are equivalent in some sense in a way that you can do with one what you can do with the other, but there is some impedance mismatch that is often overlooked.
Using events vs. promises is not like using using curly braces vs. indentation to divide code in blocks. It's more like using functional programming vs
by Rafał Pocztarski
(This gist should be called "An asynchronous file and stream I/O API of my dreams for Node.js and a postulate to never mix concepts perfect for the events abstraction with concepts perfect for the promises abstraction, because those are non-overlapping magisteria never to be confused or interchanged" but it just doesn't sound as good.)
(See also a newer post: Promise You Call Me Back for some background.)
Let's say that I open a file for writing and everything is fine. I start writing like there was no tomorrow and then suddenly I fill the entire disk and get an error. I can handle it by truncating the file or not, or maybe deleting some other files but even though I got an error I still might be able to do something else later. The point is that after some errors I don't have to give up all my hope. The error is saying: Your stream has some problems. But it still exists.
The Save for Posterity bookmarklet has been moved here:
https://rsp.github.io/save-for-posterity/
Use it whenever you want to save the content of the page that you're reading for future generations.
I want a filesystem that doesn't use c/m/atime. It would use SHA-1 (or other) hash to identify data.
Possible ways to do it:
- hash the entire file (probably not practical unless it could use partial/incremental computations)
- hash every block and then hash the list of hashes
- ...
Programs like Make instead of relying on the mtime would have to keep track of which hashes the sources had for any given target and if the hashes on disk are different then rebuild but at that point no hashes would need to be computed because they would be stored in the file system.
How to quickly download Lorempixel images.
You can directly use URLs like this: http://lorempixel.com/400/300/nature/1/ but they will be downloaded every time from the Lorempixum server (they are not cached). For better performance or cache control you may want to save them locally. You can use cURL with its little known syntax for its input and -o arguments to do it easily.
Save filenames like nature-400x300-5.jpg:
curl 'http://{lorempixel}.com/{400}/{300}/{nature}/[1-10]/' -o '#4-#2x#3-#5.jpg'
Note: this is a temporary solution for anyone who would like to see statistics of minification+gzipping vs. just gzipping the HTML before the gzipped stats are properly integrated into the main benchmark.
How to run the benchmarks from https://github.com/rsp/html-minifier/tree/gzip-benchmark
Clone the repo:
git clone https://github.com/rsp/html-minifier.git