262 karma · joined Nov 19, 2011 (15y ago) · 131 submissions
comment 7y ago · link · parent
Another pattern to avoid the above is to remember that async functions return promises and that .catch() also returns a promise. So your above logic can be written as:
const result = await funcThatReturnSomeType().catch(doSomethingWithErr);
if (result) {
doSomething(result);
}2.
Show HN: Repo badge to count your repo badges(github.com ↗)
19 points · by shtylman · 10y ago · discuss
comment 11y ago · link · parent
comment 12y ago · link · parent
comment 12y ago · link · parent
comment 12y ago · link · parent
comment 12y ago · link · parent
comment 12y ago · link · parent
I wouldn't worry about the whole rewrite in c thing. If your server protocol is simple enough, writing clients in the native languages will be better than writing bindings. Installing bindings trips up a lot of users that are not used to compiled software.
comment 12y ago · link · parent
I want to clarify why this project exists (as many seem to point out that other projects or methods exist for doing this).
TL;DR; If you think of localtunnel as just a shitty ngrok (or name your project here), you are missing the point and probably don't have the same use cases I do.
1. It was made overnight at some hackathon because I was not satisfied with the other tunneling options I found. They required either an account or some stupid ssh setup. I got to thinking of ways to create a tunnel that simply had an CLI tool and instantly get a tunnel no setup. It worked, I kept it.
2. It is written as a library first, CLI tool second. This means it can be used to create tunnels in a test suite if you want to use services like saucelabs to run browser tests (see https://github.com/defunctzombie/zuul). This is leveraged by projects like socket.io and engine.io (among others). This is perhaps the main reason I keep it around despite there being alternative CLI tools.
3. Both the client and server code are availably and easy to install and use. Companies do this when they want to run their own tunnels for privacy (or whatever their reasons... I don't care).
4. Yes, I know the name is identical to the old ruby?python? one. Whatever. That one seems defunct now anyway.
comment 12y ago · link · parent
Once the "callback hell" example was re-written with named functions, it is not much different than the generator example and depending on how you are testing, easier to test because it separates out IO from logic (Which you could still do in the generator example).
One thing callback style code has begun to make me think about is the nesting/IO complexity of the functions a I write. When you nest, the IO/event boundary is visible in the code (by the indentation). As you continue to nest, you can start to get a clear idea of the amount of IO being done and where a particular function may be doing too much. Anyhow, most of this is preference anyway :)
comment 12y ago · link · parent
jQuery would be great if it broke up all those tiny little and completely orthogonal things it does into modules so that people could use them as needed. No one library is going to provide everything for every project but making everyone require your ajax code when all they wanted was an `offset()` function is equally backwards thinking. We have much better tooling now to work with modules and to reuse code.
Arguments about CDN caching are some sort of premature optimization (or I don't know what really). Most early projects don't need it and other projects can trivially use many of the free (or super low cost) CDN providers if they care that much.
My issues with jQuery are not at how awesome it has worked in the past or how well it has hidden/handled lots of browser quirks; it is that thinking in terms of "everything is dom manipulation" is the wrong abstraction for doing organized and maintainable front-end code. The things jQuery does well would be useful within smaller components or libaries but now we are back to the original issue of jQuery is one giant blob.
comment 12y ago · link · parent
Obviously I don't know for sure but I would venture to bet this block was more an automated response than malicious intent against the site.
comment 12y ago · link · parent
comment 12y ago · link · parent
comment 12y ago · link · parent
comment 13y ago · link · parent
comment 13y ago · link · parent
I don't know what algos they use to detect fraud but being a veteran does not always mean there won't be fraud on your bank account. Remember, this is not about those five 10 dollar transactions you authorized, this is about that one 5 thousand dollar one that was the result of fraud. From their point of view, a false positive is much better than a false negative.
comment 13y ago · link · parent
comment 13y ago · link · parent
http://www.scribd.com/doc/139975904/Aaron-Greenspan-lawsuit
In which case you are the Plaintiff suing these companies which is very different than the US government suing them.
comment 13y ago · link · parent