2,000 karma · joined Aug 9, 2012 (14y ago) · 391 submissions
comment 13y ago · link · parent
<?php while (have_posts()) : the_post() ?>
<h2><?php the_title() ?></h2>
<?php the_content() ?>
<?php endwhile ?>
There are four unique functions there. All of them depend on non-obvious global state and three of them are used specifically to produce side effects. the_post() invisibly overwrites a global and changes an iterator. It not only mutates global state, but it does something different if you accidentally call it twice. And WP's the_whatever() functions echo something and return nothing?! Want to do some filtering on the title before you print it? Better use get_the_whatever() instead. WTF?! Heres how it should work: <?php foreach ($post in $wpdb->get_posts() : ?>
<h2><?= $post->title ?></h2>
<?= $post->content ?>
<?php endforeach ?>comment 13y ago · link · parent
I'm curious, though, why they added an external dependency instead of just inlining a solution. There's a couple of good MIT licenced barebones implementations[1][2] floating around, and it's pretty straightforward to reimplement yourself in an hour or two if you prefer.
[1] https://github.com/Wolfy87/EventEmitter [2] https://github.com/hij1nx/EventEmitter2
comment 13y ago · link · parent
comment 13y ago · link · parent
Security is a tradeoff, and we tend to forget that complex, unique passwords have a very real cost. They drastically increase the risk that I will lock myself out of some service, and dramatically increase the workload of authorizing myself when I do want to use it. With a few obvious exceptions, this tradeoff is a huge net loss for the average user.
In other words, the risk of some stranger wanting to post as me in HN is acceptably small. The cost of having to install KeePassX, then download my passwords file from Dropbox then decrypt and copy/paste, then make sure the paste register is clear, then securely delete my passwords file every time I borrow a friend's computer is prohibitively high.
comment 13y ago · link · parent
NoSQL, on the other hand, is weakly typed and makes few if any attempts to validate your data, pushing that responsibility back onto you. They are very well suited to storing inherently inconsistent data (which, as a corollary, makes them very good for prototyping, when your data model is rapidly changing and growing). They also allow you to link much larger datasets into a 'document' which is retrieved as a unit with no extra computation.
So it mostly boils down to what kind of data you want to store. If you find yourself almost exclusively saying things like "All users have a username that is a string" or "I want to be able to find all products that cost less than $20" then you're probably looking for a traditional SQL database. If, on the other hand, you find yourself saying "some products have a width and height, but some just have a height, and a few have a volume instead" or "I want to be able to add custom fields to products on the fly" or "I never want to see purchases on their own, I always want to see them joined to the user that bought them" then you should probably consider a NoSQL solution.
comment 13y ago · link · parent
Which is exactly the problem. There's no strong reason to suggest that this difference is due to anything other than social pressure. Something in the way we socialize children is convincing half the potential talent pool that they shouldn't develop an interest in technology fields, almost certainly because they see few if any adult role models.
It's not really a failing of the industry, in the sense that we're probably not the ones who originally caused it. But it is a problem for the industry, and one that industry insiders are in a unique position to solve.
comment 13y ago · link · parent
The reading where being armed is a protected right of each individual _is_ a reinterpretation, and a fairly recent one at that. http://backstoryradio.org/straight-shot-guns-in-america-2/ (podcast, but well worth the time) has a wonderful summary of how this view has evolved over the last 2.5 centuries.
comment 13y ago · link · parent
Lets not forget that guns are devices whose primary function is to kill things very efficiently. I'd argue that if you're not willing to spend $50-$100 and wait a few days, then you're not treating that kind of transfer of power with the respect it deserves.
comment 13y ago · link · parent
This is fairly true of ember specifically, but much less so for some of the other frameworks. Backbone and Angular, in particular, are very well suited for building "islands of richness" in otherwise traditional sites. Even if you're doing something relatively simple, like a form with live validations and inline error messages, you're going to have an easier time writing it with something to handle the DOM manipulation for you.
If you're wanting to get into frontend JS, start with Backbone. It's much less powerful than the other frameworks, but is by far the easiest to grok, and having it under your belt will give you enough tools to start moving larger and larger chunks of functionality into the browser. Come back to Ember once you outgrow that.
comment 13y ago · link · parent
Individual employers are clearly demonstrating that they have a disincentive, rational or otherwise, from hiring potential employees with large gaps in their resumes. This obviously will tend to feed back on itself, making long gaps longer and unemployable applicants even more unemployable as time passes.
Society, on the other hand, has both economic and humanitarian interests in minimizing the number of unemployable individuals. Since the market has inadvertently began creating a large pool of these unemployable people, and it shows no sign of changing in the short to mid term, then society can and should apply non-market forces to advancing its interests.
Honestly, I'm not sure if direct employment is the best solution; I'd probably prefer some variation on tax incentives for employers. But reaching for the hammer, as you put it, is not always a knee-jerk reaction and seems like a pretty rational instinct in this situation.
comment 13y ago · link · parent
comment 13y ago · link · parent
You're still mentally translating a what into a how. You almost certainly don't want to highlight 5 lines down for its own sake, you probably want to highlight, say, the body of a function. Vim provides a command to just do that directly.
comment 13y ago · link · parent
comment 13y ago · link · parent
myAsyncFunc = function (param1, param2, callback) {
var usingPromises = (callback === undefined);
var returnVal = usingPromises ? Q.defer() : this;
someFunction(function (err, res) {
if (usingPromises) {
err ? returnVal.reject(err) : returnVal.resolve(res);
} else {
callback(err, res);
}
});
return returnVal;
};
So if I call myAsyncFunc(foo, bar) it returns a promise and if I call myAsyncFunc(foo, bar, cb) it returns itself for chaining.comment 13y ago · link · parent
comment 13y ago · link · parent
If you tell me something that you know or should know to be false, I act on what you told me, and you benefit from my action, then by definition I have been defrauded.
comment 13y ago · link · parent
Calling consumers 'complicit' for failing to understand a company's offerings significantly better than their own salespeople is at the very least insulting.
comment 14y ago · link · parent
Try exposing them to a few advanced topics in whatever they're overreaching on (like higher order functions for JS or named pipes in Unix). May not work, but you might get lucky and knock a few of them over the learning plateau and back on course to become real experts.
comment 14y ago · link · parent
Hiring through AA is _intentionally_ suboptimal. The whole point is to give members of disadvantaged communities access to opportunities they are less qualified for in the hope that they, and by extensions their communities, will over time become _less_ _disadvantaged_.
There are more important things in this universe than efficiency.
comment 14y ago · link · parent
So to take your example, assuming X=12 and C=1, if I sell my books for $6 and $9, respectively, I make $1 profit, but if I'm forced to sell them both at $6 I lose $2.
Price discrimination is often a Good Thing, on balance. The takeaway from allowing price discrimination isn't (mainly) that Americans get gouged, it's that Thai students get access to textbooks they wouldn't otherwise be able to afford.
comment 14y ago · link · parent
(1.2x2^-2) - (1.6x2^-3) = (1.6x2^-3) - (1.6x2^-4)
which is pretty clearly false. http://www.h-schmidt.net/FloatConverter/IEEE754.html has a pretty nice conversion tool, if you're curious.