HNHacker News
TopNewBestAskShowJobs

mwpmaybe

907 karma · joined July 27, 2015

[ my public key: https://keybase.io/mwp; my proof: https://keybase.io/mwp/sigs/IgRJbBXIMpIG5ILaErmbmjkyttiEoe4ov_JqABTpuoQ ]
submissionscomments
mwpmaybe··on Async JavaScript Generators
Generators are used to great effect in Ember thanks to the ember-concurrency[0] addon. It was far and away the most frequently talked-about topic at EmberConf last week. If you're interested, I'd highly recommend machty's talk[1] from last year where he introduced it. His talk from last week was also very good, but it does not appear to be available yet.

I don't think it's currently using async generators (have yet to read the linked article), but I suspect this new language feature may lead to some improvements!

0. http://ember-concurrency.com

1. https://vimeo.com/162329769

mwpmaybe··on Containers vs. Zones vs. Jails vs. VMs
> That being the case, why not just use the OS? And processes and shared libraries?

That's essentially what a Linux container is: a process (that can fork) with its own shlib. If you have lots of processes that don't need to be isolated from each other and can share the same shlib, then no, you don't need this mechanism.

mwpmaybe··on Glimmer – Fast and light-weight UI components
This will do the trick:

    yarn global add ember-cli/ember-cli
mwpmaybe··on Glimmer – Fast and light-weight UI components
Glimmer.js may be more your speed!
mwpmaybe··on Republicans pull healthcare legislation plan in blow to Trump
On one end of the spectrum, you have the 25 year old single dude who works for a big company. He pays $60 every two weeks for his PPO and doesn't understand what the big deal is. Can people really not afford $60 every two weeks? He votes Republican because he's a maker, not a taker, and he wants a tax cut. He fundamentally misunderstands the nature of his coverage: his employer pays 80% (or 100%!) of his premium.

On the other end of the spectrum, you have a family of five that makes too much money to qualify for a subsidy. They live in a red state that didn't expand Medicaid, uses the federally-managed exchange, and suffers from a lack of competition because there's only one insurer on that exchange. An HDHP for the family would cost $1,300/mo, which they can't afford, so they pay the penalty and go without insurance. They vote Republican because as they see it the government is forcing them to buy something they can't afford, and they want it to be better... or at least go back to the way it was.

A lot of people and families had plans and doctors they liked before the ACA was passed, and one of two things happened:

1. because year-over-year premium increases are regulated by the government per the ACA, insurers were forced to make their plans more efficient by reducing the size of their networks in one way or another. This meant that a lot of people lost access to their doctors and had to find another, often having to travel further and/or wait longer to see their new doctor.

2. they had terrible insurance before the ACA was passed, but didn't realize it. Perhaps they had unreasonably high deductibles, or access to few essential services, or ridiculously low lifetime limits, or punitive coinsurance rates, or... Perhaps they'd refuse to cover something because it was a "preexisting condition." Perhaps they'd drop you mid-treatment, making it impossible to get further treatment without going into severe debt. This insurance wouldn't have been much use to anyone in the event of cancer, or a heart attack, or a broken leg, but they were paying the premiums anyway, and it sure helped them feel insured. ACA made all of these practices illegal, or at least put some controls on them to ensure a baseline quality of insurance. These plans went away or became as expensive as other plans.

These people vote Republican because from their point of view ACA took away their plans and their doctors, and Obama had stupidly promised them that wouldn't happen. They had it good, or so they thought, and it was taken away from them.

Everyone else is experiencing rising deductibles and premiums with no end in sight. What most people fail to realize is that deductibles and premiums would be rising with or without ACA—as they were before the passage of ACA—at a greater rate! ACA bent the curve, so they're still increasing, but less so. Yes, your insurance cost $300/mo last year, and it costs $400/mo this year, but how much would it cost if ACA hadn't been passed seven years ago? Would you even be able to get insurance? Do you or a family member have a preexisting condition? Our minds aren't wired to think like this, though... all we see is a higher bill and want someone to blame, so we vote Republican.

I could go on. ACA did a lot, but it didn't do enough to encourage competition and control costs. Clearly. A public option and "death panels" would have helped a lot, but of course these were dropped to encourage bipartisan support for the bill... which it didn't get. Oh well.

mwpmaybe··on Modern JavaScript for Ancient Web Developers
Great post—and the title got a laugh out of this self-described "ancient" web developer—but interestingly, there's not much (any?) info in there about learning JavaScript/ECMAScript the language. It and the articles it links are mainly focused on the ecosystem and tooling.

I held JS at arm's length for way too long, trying to use it without actually learning it. I finally grew tired of being illiterate and read "You Don't Know JavaScript" by Kyle Simpson[0] and it was eye-opening. The preface[1] really spoke to me and I suspect it will speak to many others like me. I only wish I'd read it two years ago.

0. https://github.com/getify/You-Dont-Know-JS

1. https://github.com/getify/You-Dont-Know-JS/blob/master/prefa...

mwpmaybe··on Programs that have saved me 100+ hours
With set -o vi:

    <ESC> k cw zcat <ESC> A <SPACE> | <SPACE> less <CR>
Very natural for any Vi user: go up a "line", change the first word, then append.
mwpmaybe··on CoreOS's rkt and Docker's containerd jointly donated to CNCF
Are you suggesting that there's no money in any open-sourced technology? Is there money in Linux?
mwpmaybe··on How I Made $70k Self-Publishing a Book about Ruby on Rails
> I remember when I was learning Ruby, and everyone online was "Read that _why guide it's great!!" It was a mess. I couldn't learn anything from it at all.

I had the same experience (started Rubying in late 2015). I had much more success with RubyMonk, Metaprogramming Ruby 2, and some other "Ruby for Perl hackers" blog posts and such.

mwpmaybe··on JSON Web Tokens should be avoided
Thanks for your response.

> 2. it doesn't, internal session class does and IMO most apps do not need expire claim.

If you're generating a token to send to an SPA or native app, you can't rely on any other expiration mechanism. It needs to be embedded in the token or stored server-side in a database-backed session or what have you.

> 3. Just put issuer/issued_at/whatever in your object

You're missing the point that these features would require additional SLOC to verify the "claims."

> 4. I suggest to look at messageverifier and do your own (and use sha256 hmac). Why? Lets consider 50 lines of code not "maintaining your crypto fork" but merely helpers.

By this logic, ruby-jwt isn't crypto, just helpers. It seems to be frowned upon simply because it includes additional features some people may not need, and those features and alternative signing methods require more SLOC than your presumed "optimal" implementation. Do you see no value in a flexible, reusable library?

> 5. JWT has more LOC inside, say header payload is just useless. I believe having OpenSSL::HMAC helpers is better and simple enough to not do it wrong

How can critics justify the position that people should write their own OpenSSL::HMAC helpers because they can't correctly call the JWT helpers?

mwpmaybe··on JSON Web Tokens should be avoided
CSRF protection:

* Use SameSite cookies (unfortunately, not yet supported by all browsers)

* Don't accept application/x-www-form-urlencoded, multipart/form-data, or text/plain at your endpoints, or

* Use CSRF tokens if you need to accept server-side rendered HTML forms

mwpmaybe··on JSON Web Tokens should be avoided
This drives me nuts. To expand on your point, there are a number of separate, debatable design decisions that seem to get conflated all the time:

* Transport: how the session ID or token is shipped between clients and servers (authorization header, cookie headers, or payload).

* Storage: how the session ID or token is stored on clients (cookies, localStorage, sessionStorage, or in memory).

* Statefulness: whether to use a stateless token (with or without a revocation list) or a stateful, server-side session.

* Encryption and/or signing

* Structure/standardization

Examples:

* JWT generates structured, stateless tokens that are signed—and optionally encrypted (JWE)—with the implementor's choice of algorithm. The tokens can be transported and stored by any mechanisms.

* Rack::Session::Cookie (in Ruby) generates unstructured, stateless tokens that are signed—not encrypted—with HMAC. The tokens are transported and stored as cookies.

* Rack::Session::Pool (also in Ruby) maintains an in-memory store of unstructured, stateful sessions. Unsigned and unencrypted session IDs are transported and stored as cookies.

The point being that you can really mix and match. You can even send a session ID in a header and store it as a non-HttpOnly-cookie on the client. Anything goes!

mwpmaybe··on JSON Web Tokens should be avoided
* MessageVerifier defaults to SHA1. That hasn't been a good default for a few years now.

* It doesn't support expiry as a claim; you have to check it against the current time manually, and factor in leeway if you want that. Because no one ever screwed up a timestamp check.

* It doesn't support any other verifiable claims, for that matter, so if you want to add e.g. issuer and issued-at, you'll have to do so manually.

* If you're not writing a Rails app, you have to pull in ActiveSupport... or copy code, as you suggest, which seems bad for other reasons. Surely maintaining your own crypto fork is almost as bad as writing your own crypto in the first place?

* To the best of my knowledge, ruby-jwt has not suffered either of the two JWT vulnerabilities discussed in this thread.

Finally, why is this "simple":

    @verifier = ActiveSupport::MessageVerifier.new('s3Krit', digest: 'SHA256')

    cookies[:remember_me] = @verifier.generate([@user.id, 2.weeks.from_now])
But this is "bad":

    payload = { sub: @user.id, exp: Time.now.to_i + 1_209_600 }

    cookies[:remember_me] = JWT.encode(payload, 's3Krit', 'HS256')
They seem fairly equivalent to me?
mwpmaybe··on JSON Web Tokens should be avoided
> The approach I use is to have a 'use once' refresh token (long timeout) and a security token (short time out) and JTIs to hold a list of logged out/invalid (refresh token used twice) security token IDs.

Here's what I've never understood about this approach: the browser can send many requests at the same time, over the same (HTTP/2) or different (HTTP/1.1) connections. If, say, six requests hit your backend at the same time, all with the same refresh and security tokens, with four more queued up on the user-agent, and the security token is expired, how do you know:

1. that all ten requests are valid,

2. to revoke the security token once,

3. to generate one new security token,

4. to mark the refresh token as used,

5. to generate one new refresh token?

Is it as simple as granting some leeway on how long the tokens can be used after they expire/are revoked? Do you have some way of serializing requests on the client to prevent this from happening? Or do you assign all ten requests the same "batch" ID and tie them together on the backend somehow? Do you do a preflight request to refresh the security token if it's expired?

mwpmaybe··on JSON Web Tokens should be avoided
Probably not. If the Pg instance is replicated, as indicated above, it'll be challenging to keep the Memcached copy in sync. In other words, you can't just use the caching feature of your ORM, you'll need another piece.
mwpmaybe··on Has Python killed Ruby?
> For package management, I think npm is on par with bundler

NPM is non-deterministic and doesn't have lockfiles, so it's a bit of a stretch to say it's on par with Bundler.

Yarn solves both those problems for JavaScript projects, and it's much faster.

mwpmaybe··on Can sleep deprivation cure depression?
As an interesting anecdatum, I've noticed that when I binge-sleep, i.e. for more than 8.5 hours, I feel depressed.
mwpmaybe··on Eating less and more than needed on alternate days prolongs life (2006)
I just started doing this a few weeks ago, along with counting calories during my "feeding" window (which I actually try to restrict to six hours). So far so good.

I find I'm actually more successful at counting calories on this schedule. I think it's easier for me to completely abstain during the fasting period, and I'm less tempted to snack with lunch and dinner so close together. I've been planning and allocating my calories like I never have before, even though I've tried many carb- and calorie-counting schemes in the past.

I'm also toying around with taking a little MCT oil in the morning to help with cravings and mental focus and give me a little keto boost. It's unclear to me whether or not this defeats the purpose of the fast. Many people seem to think it's fine ("fat fasting") and maybe even a good idea, but I'm not yet convinced one way or the other.

mwpmaybe··on The Collapse of the Unix Philosophy
For those of you who might be fooled into thinking this is about things like SystemD and Docker—it's not!
mwpmaybe··on Do we really need swap on modern systems?
Also... Linux. Not macOS.
mwpmaybe··on The Other Half
I am not a doctor. Here are some thoughts (addressed to both you and the GP):

I have a hietal hernia[0] that causes reflux and dyspepsia (trouble swallowing) and mimics these heart symptoms: shortness of breath, arrhythmia, chest pain, and tachycardia. A ketogenic diet helps, as does an OTC PPI[1] (e.g. Prilosec, Nexium). You might consider getting scoped to see if you have one as well (or just take a PPI for two weeks and see if it helps).

I've had arrhythmia since I was a teenager. Some of it is sinus (i.e. pressure on my vascular system caused by breathing) and some of it is not[2]. I've found that taking a daily multivitamin helps considerably, as does a diet rich in magnesium and potassium (occasionally supplemented), so I must have some deficiencies. I can't take too much pseudoephedrine (and try to avoid it completely after a particularly scary episode). Regular exercise helps as well. If I start to freak out about a particularly bad spell of arrhythmia and/or palpitations, I tell myself to eat an apple or a banana and go for a walk.

Alcohol and caffeine wreak havoc on all of the above, so I can't drink like I did in my 20s, and I try to limit myself to one pot of coffee per day. ;-)

> "your EKG is normal and you're fat"

If I had a nickel for every time I've heard that...

If you have bacterial endocarditis[3], that could explain why a low-carb diet is helpful: lower blood sugar -> less fuel for bacteria -> reduced heart valve inflammation. Maybe.

I have something else going on right now that I don't understand: waking up at night with back pain under my right shoulder blade, anxiety, and arrhythmia. I went to the hospital after the third incident and the EKG, blood work, chest X-ray, CT scan, etc. didn't reveal anything. I suspect it's stress-related and either an ulcer or bacterial endocarditis, so I need to get those looked at by specialists. I also had a clot in my leg last year for which I needed six months of blood thinners, so I wonder if that's related...

Getting old sucks.

0. https://en.wikipedia.org/wiki/Hiatus_hernia

1. https://en.wikipedia.org/wiki/Proton-pump_inhibitor

2. https://en.wikipedia.org/wiki/Premature_ventricular_contract...

3. https://en.wikipedia.org/wiki/Infective_endocarditis

mwpmaybe··on Docker in Production: An Update
You don't need a custom kernel to run Docker on Linode. Just change the storage driver to overlay (as you do in this stack script) and you're good to go. Otherwise this is a very nice script. I typically install the vim-nox package (instead of vim) but I'm not sure it makes a difference.
mwpmaybe··on White House Bars NYT, CNN, and Politico from Briefing
Sure. A lot of people were against it after it started, especially when it began to go south. That's not what we're talking about. We're talking about statements like this:

"[H]ad I been in Congress at the time of the invasion, I would have cast a vote in opposition." — Donald Trump at an education event on 8-Sep-2016[0]

Considering that the vote was on 11-Oct-2002, and we have audio of Trump expressing hesitant, wishy-washy support for the war on 11-Sep-2002, that is almost certainly not true.

0. https://www.usnews.com/news/politics/articles/2016-09-10/ap-...

mwpmaybe··on White House Bars NYT, CNN, and Politico from Briefing
"I was totally against the war in Iraq." — Donald Trump on NBC News in 2016[0]

That's a lie, and one he's repeated often. Wishy-washy, hesitant support for a thing is not the same as being totally against a thing. His assertion that he was in opposition to it from the very beginning is a deliberate, egregious misrepresentation of his past views intended to convey authority on a subject that he simply does not possess.

I'll update the wording of my initial point to be more clear, since you have my original wording quoted here for posterity.

0. https://www.washingtonpost.com/news/the-fix/wp/2016/09/07/th...

mwpmaybe··on White House Bars NYT, CNN, and Politico from Briefing
Start here: http://www.politifact.com/personalities/donald-trump/stateme...

How about:

* Lying about his past opposition to the Iraq war

* Lying about Russia only hacking the DNC (they hacked the RNC too, or at least tried to, but didn't release anything)

* Lying about the size of the crowd at his inauguration

* Lying about his "historic" electoral win (it wasn't)

* Lying about the election being rigged against him (before the election)

* Lying about the state of African American communities

* Lying about inner-city crime rates

* Lying about Obama and Clinton literally "founding" ISIS

* Lying about Ted Cruz's father being involved in the JFK assassination

* Lying about his charitable donations and activities

* Lying about his inability to release his tax returns because of an ongoing IRS audit

* Lying about his association with David Duke and the white national movement

* Lying about his history and relationship with Vladimir Putin

That's just a taste. I could go on.

mwpmaybe··on Fasting diet 'regenerates diabetic pancreas'
Undiagnosed what?
mwpmaybe··on Do we really need swap on modern systems?
Yes, with oom_score_adj[0], which I've mentioned several times. Setting it to -1000 for a process protects it from OOM killing.

0. http://man7.org/linux/man-pages/man5/proc.5.html

mwpmaybe··on Do we really need swap on modern systems?
Nope, just a rule of thumb. :-)
mwpmaybe··on Do we really need swap on modern systems?
Thank you for sharing this. There's an interesting conversation thread in the comments on that post. It's a little over my head, but my takeaway is that with the kernel change, in an OOM event, MySQL is unable to be swapped out due to the type(s) of memory pages it's using, so the kernel is forced to kill it (or itself). In practice, it's relatively straightforward to tune MySQL/MariaDB for a certain memory allocation, and if it's on a shared host, oom_score_adj can be set to protect it.
mwpmaybe··on Docker in Production: An Update
No, that's not what I'm saying. I'm saying that Ubuntu Server 16.04 LTS comes out of the box without AUFS and Device Mapper, and that you either need to enable one or the other before installing Docker or prevent Docker from starting automatically at install time. It sucks, yes, but your description of the problem and its solution is beyond hyperbolic. Googling "docker ubuntu install hang" takes you right to the GitHub issue with the solution at the bottom. And I think it's fixed in Docker 1.13 (it will prefer OverlayFS if AUFS and Device Mapper are not available), although I have not tested it.
← PreviousPage 5 of 12Next →