List of helpful shortcuts for faster coding
If you have any other helpful shortcuts, feel free to add in the comments of this gist :)
| 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); |
| Number.prototype.pad = function(size) { | |
| var s = String(this); | |
| while (s.length < (size || 2)) {s = "0" + s;} | |
| return s; | |
| } | |
| (1).pad(3) // => "001" | |
| (10).pad(3) // => "010" | |
| (100).pad(3) // => "100" |