Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
| # best practice: linux | |
| nano ~/.pgpass | |
| *:5432:*:username:password | |
| chmod 0600 ~/.pgpass | |
| # best practice: windows | |
| edit %APPDATA%\postgresql\pgpass.conf | |
| *:5432:*:username:password | |
| # linux |
| function randomDate(start, end) { | |
| return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime())) | |
| } | |
| console.log(randomDate(new Date(2012, 0, 1), new Date())) |
| document.getElementsByTagName('button')[0].onclick = function () { | |
| scrollTo(document.body, 0, 1250); | |
| } | |
| function scrollTo(element, to, duration) { | |
| var start = element.scrollTop, | |
| change = to - start, | |
| currentTime = 0, | |
| increment = 20; | |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
| function readFile(file) { | |
| var reader = new FileReader(); | |
| var deferred = $.Deferred(); | |
| reader.onload = function(event) { | |
| deferred.resolve(event.target.result); | |
| }; | |
| reader.onerror = function() { | |
| deferred.reject(this); |
| function keepTrying(otherArgs, promise) { | |
| promise = promise||new Promise(); | |
| // try doing the important thing | |
| if(success) { | |
| promise.resolve(result); | |
| } else { | |
| setTimeout(function() { | |
| keepTrying(otherArgs, promise); |