3 ms·
(I apologize in advance for linking to my own blog, but I had not seen this issue reported on any tech blog nor appeared in the "new" queue on HN, so I wrote a
by minimaxir 14y ago
(I apologize in advance for linking to my own blog, but I had not seen this issue reported on any tech blog nor appeared in the "new" queue on HN, so I wrote a quick post this morning on the issue, as it's technically interesting.)
- esrauch 14y agoSorry to comment off of the content of the post, but when I load the page the Like button flickers shown/not shown a bunch of times causing annoying visual jitter. I'm on Chrome 22 if that is relevant.
- minimaxir 14y agoFrom what I can tell, that's on Facebook's end, as all the Facebook plugins seems to flicker occasionally as well. I'll look into it, although there's nothing unusual with my front-end code that should be causing unusual behavior...maybe CloudFlare caching issues? Thanks for letting me know btw. :)
- minimaxir 14y agoI figured out the error (I was wrong, it was indeed my code) and fixed it. No more flickering. :)
- spicyj 14y agoOut of curiosity, what was the bug?
- minimaxir 14y agoOn my main page, I use AJAX to load the Share buttons when the user mouses-over the post itself, so that they aren't loaded all at once. Specifically, it loads the HTML, then runs it through each social service's HTML parser to render the buttons. On individual blog posts, the buttons did not load because the DOM element is not present for that template. However, the parser still ran on mouse-over, which is what caused the flickering. So I just disabled the parser when the user is on an individual blog post.
- spicyj 14y agoGotcha. :)
- gabemart 14y agoIs there a problem with linking to your own blog?
- mparlane 14y agoSelf promotion [of your own blog/site] is frowned upon I believe. We have SHOW HN: for when you want to show something off that you have done. I think it's mainly to stop reporters at Gawker from linking to all their articles though ;)
- ars 14y agoSelf promotion is not frowned upon. As long as the content is good it doesn't matter who submits it.
- artursapek 14y agoRight. People get their friends to link their blogs anyway, I see no difference in effect.
- bryanlarsen 14y agoWhat is frowned upon is blogspam, rewriting somebody else's article and submitting your own version. Original content is always welcome.
- Evbn 14y agoIt doesn't stop. Jen at Betabeat's Reddit-Gawker gawking junk has been on the front page for days.
- deleted 14y ago[deleted]
- rcfox 14y agoThat's okay. You did a better job than what any of the popular tech blogs would have done.
- Negitivefrags 14y ago> The proper way to implement a promo code is logical: when the user attempts to apply a promo code, the server checks, has the user used this promo code before? by querying SELECT FROM transactions WHERE user_id = current_user AND promo_code = “OS3874XVC”. If the result set is empty, then the user hasn’t used the code, and everything’s good to go. Be very careful here, it's not as simple as it looks. If you don't do the correct locking it is very easy to have timing attacks which allow keys to be used twice. We learned this the hard way after posting a one use key for our game on 4chan. A thousand people rushed to try the key and around 100 people managed to get in using it.
- ams6110 14y agoIt really isn't as easy as it sounds, is it? A better approach might be to UPDATE promo_codes SET used = 1 WHERE ... AND used = 0, and then check that one update occurred. Or if your db supports it, SELECT ... FOR UPDATE OF ... and then update if the code is not yet used. You want the check and the update to occur atomically. And this varies depending on databases, for example in Oracle even if you explicitly begin a transaction, a select does not lock the row (unless you specify FOR UPDATE OF) so if you do the check and the update in separate statements, you still have a race condition).
- Negitivefrags 14y agoI actually wasn't personally involved in the solution, but I believe that we went with something involving SELECT FOR UPDATE.
- deleted 14y ago[deleted]
- nvmc 14y agoJust out of interest, what is your game?
- Negitivefrags 14y ago
- NoPiece 14y agoI don't think you have characterized the problem accurately (or at least completely). The coupon allowed you to add dozens of games to your cart, then applied the $20 off to each individual item instead of just one, or against the total. It was a logic problem in applying the coupon on the server side.