35% off Pulse Solo Dimmable LED Light with Dual Channel Bluetooth Speakers – Deal Alert

Pulse Solo is the world’s first LED light with dual speakers in one bulb. Pulse Solo combines the energy efficiency of a dimmable LED light with the high-quality audio of JBL Bluetooth speakers. Setup is easy, twist the Pulse Solo into any standard light socket, and adjust both lighting and sound from any Bluetooth enabled iOS or Android device. Experience the soaring highs and the rich stereo sound of JBL combined with warm, dimmable lighting, without the fuss of speaker wires, power cords, or an independent remote control. The intuitive iOS and Android App offers seamless control of both light and sound while listening to your favorite streamed music or media, offering you the ability to customize your light and music to suit any mood. The Pulse Solo typically lists on Amazon for $59.99, but is currently discounted 35% to $38.93.   See this deal on Amazon .

To read this article in full or to leave a comment, please click here

53% off Rockbirds 6-Pack LED Mini Super Bright 3 Mode Tactical Flashlights – Deal Alert

This mini LED tactical flashlight has 3 modes, an adjustable/zoomable beam, and is both rugged as well as water resistant. Its bright, long-lasting light operates on just a single AA battery. The list price on a pack of 6 has been reduced 53% to just $21.99, so for just $3.67/torch you’ll have a light tucked away in every room, every car, every backpack, or anywhere else this might come in handy. The flashlight averages 4.5 out of 5 stars from over 1,200 reviewers on Amazon (see recent reviews here). See this deal now.

To read this article in full or to leave a comment, please click here

How devops tools accelerate software delivery

Once upon a time, there was a developer who needed to write code against a database. So he asked the database administrator for access to the production database.

“Oh, dear me, no,” said the DBA. “You can’t touch our data. You need your own database. Ask operations.”

“Oh, dear me, no,” said the operations manager. “We don’t have a spare Oracle license, and it would take six months to get you that and the server on which to run it. But I’ll do what I can.”

You can see where this is going. You can even hear “bwahaha” after each answer. Of course, the DBA and operations manager are only doing their jobs, but the developer – and the needs of the business – are stuck in the slow lane.

To read this article in full or to leave a comment, please click here

65% off Etekcity 2 Pack Portable Collapsible LED Camping Lantern – Deal Alert

The Etekcity collapsible LED Lantern provides up to 12 hours of bright omnidirectional lighting for your surroundings. It’s lighter, brighter, and more portable than most flashlights while still featuring the rugged durability to withstand the outdoors. The military-grade exterior is water resistant for more practical use in a high range of environments. Save time, energy, and luggage weight with its simple design and practicality. The fold-out collapsible handles make the lantern portable and easy to hang. Keep it on a table or hanging on a branch to illuminate your environment, and the lantern will take care of the rest. Right now a 2-pack of lanterns, with batteries included, is discounted 65% to just $13.99. See this deal on Amazon.

To read this article in full or to leave a comment, please click here

JavaScript-Equivalent jQuery Code for Simple Tasks


There are developers who love jQuery and there are some who hate jQuery. The benefits of using jQuery now are debatable, but there was a time when solving the cross-browser issue was a nightmare and using JavaScript was painful. If you had been through that phase, you might understand the importance of jQuery. jQuery was born to overcome the biggest issues of JavaScript. Over the years, JavaScript has also evolved but we should be thankful for the fact that modern browsers are also becoming more and more standard-compliant. jQuery is still a powerful library and it can still reduce your efforts for client-side programming.

The aim of this post is not to discourage your use of JavaScript, but rather to give you an insight into how jQuery can help to solve simple tasks compared to JavaScript. jQuery can help in reducing the lines of code and your efforts, lessen cross-browser compatibility issues, result in faster development, and it makes AJAX calls and animations dead simple. To start with, we’ll take a look at the most basic requirements like selecting elements on the page by their ID, class, and tag name and then we will look at some complex examples. Let’s dive in!

Selecting an Element by ID

JavaScript code

document.querySelector(‘#elmID’); // Modern Way – IE8 and above

document.getElementById(‘elmID’); // Older Way

jQuery code


As you can already see, we’ve used less code to select the element in jQuery.

Selecting an Element by Tag

Consider a use case to select all the paragraph elements on the page:

JavaScript code


jQuery code


Again, shorter code in jQuery!

Selecting Elements by Class Name

To select all elements having dummy CSS class:

JavaScript code

document.getElementsByClassName(‘dummy’); // Older Way

document.querySelectorAll(‘.dummy’); // Modern Way – IE8 and above

jQuery code


We can see a continuing trend of fewer and shorter lines of code in jQuery.

Change Body Background Color on Load

JavaScript code

function changeBackground(color) {

document.body.style.background = color;


jQuery code

$ (‘body’).css(‘background-color’, ‘green’);

A single line of code accomplishes what takes four lines of code to accomplish in JavaScript.

Adding a CSS Class to Element

JavaScript code

if (el.classList)



el.className += ‘ ‘ + className;

jQuery code


That’s three fewer lines!

Making an Ajax Call

JavaScript code

function loadValues() {

var xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function() {

if (this.readyState == 4 && this.status == 200) {

document.getElementById(“demo”).innerHTML = this.responseText;



xhttp.open(“GET”, “/api/values”, true);



jQuery code

function loadValues() {


url: “/api/values”,

type: ‘GET’,

dataType: ‘json’,

success: function (data) {



error: function (response) {





The jQuery version looks much cleaner and more readable, it also offers a better method for error handling.

Making a Simple Fade-Out Animation

JavaScript code

function fadeOut(element) {

var op = 1; // initial opacity

var timer = setInterval(function () {

if (op <= 0.1){


element.style.display = ‘none’;


element.style.opacity = op;

element.style.filter = ‘alpha(opacity=’ + op * 100 + “)”;

op -= op * 0.5;

}, 500);


var element = document.getElementById(‘elm’);


jQuery code


There is no need to judge here who is better: jQuery is the clear winner.


We’ve just seen how jQuery can make life much simpler for easy tasks. Some functionality can be achieved by just one line of code in jQuery that requires 15-20 lines of JavaScript to achieve the same result. jQuery is an awesome library and it’s still very popular among developers. You should consider it as an alternative for fast development and without worrying about cross-browser issues. However, you should also be careful as it’s large file to load! 

Using jQuery to Delete All Inline HTML Styling

Inline HTML styling (when the style attributes for a particular element are written within the HTML tag) is not something that’s considered a best practice when it comes to HTML and CSS, and it’s becoming less and less common. You don’t often come across inline styling unless a site’s code hasn’t been touched since the 90s or early 2000s, but it’s certainly not unheard of. If you find yourself trying to do a redesign of an older site that contains inline styling within the HTML, you’ll almost absolutely find that overriding the inline styling can be a huge pain.

Rather than go through every HTML file to remove inline styling, all of your inline styling woes can be eradicated using a very simple jQuery code snippet, which will completely get rid of all of the style attributes that can be found within your HTML tags. To see how it works, take a look at the code snippet below:


The code snippet above uses jQuery to select every single style attribute (using the * selector in combination with the [style] attribute) and, using the .attr method, removes all of the values from the inline style elements by replacing the text with nothing (thanks to those empty quotation marks).

This is a super simple solution to getting rid of inline styling that can save you tons and tons of time and aggravation. If you’re working on a smaller site with less instances of style attributes within the HTML tags, then it might be wiser to just go through and remove them manually, but if you’ve got a big size with inline styling on every single page, then this is a great, super straightforward, and rather lightweight solution that will easily and quickly remove every single instance of inline style attributes so that the site in question can be updated to look its very best.

How to Use jQuery to Dynamically Open Links in New Tabs

Even if you’re a new or beginning developer, you probably know that you can easily make links open in new tabs by using the target attribute with your anchor tags. To make a link open in a new tab, all it takes is to make your HTML look like this:

The target=”_blank” attribute is all you need to make your links open in new tabs. But what if your anchor tags weren’t written this way, and you still want your links to open in new tabs? You can go back through your HTML and hand code it yourself, but if you’ve got a lot of anchor tags this could take you a really long time. Luckily, jQuery is here to save the day.

With jQuery,  you can use some really straightforward snippets to dynamically open all external links in new tabs without having to go through every line of your HTML with a fine-toothed comb. To see the snippet for yourself, check out the code below:

     this.target = "_blank";

That’s it. All it takes are two lines of  jQuery to make sure that all of your external links open in new tabs. The function is triggered by the .click() event method, so the function won’t run unless any of the external links are clicked on, so it’s a pretty lightweight solution. You can see that the snippet above uses the ‘a[@rel$=’external’]‘ selector. This can be used to select all of the external links, and apply the target=”_blank” attribute to it. But, if you find yourself wanting to select all of the anchor tags on your page, you can remove the rel code and simply use ‘a’ as the selector. You can also use a similar concept to select all links of one class or ID type by placing the class or ID name in the selector.


Hacker, Hack Thyself

We’ve read so many sad stories about communities that were fatally compromised or destroyed due to security exploits. We took that lesson to heart when we founded the Discourse project; we endeavor to build open source software that is secure and safe for communities by default, even if there are thousands, or millions, of them out there.

However, we also value portability, the ability to get your data into and out of Discourse at will. This is why Discourse, unlike other forum software, defaults to a Creative Commons license. As a basic user on any Discourse you can easily export and download all your posts right from your user page.

Discourse Download All Posts

As a site owner, you can easily back up and restore your entire site database from the admin panel, right in your web browser. Automated weekly backups are set up for you out of the box, too. I’m not the world’s foremost expert on backups for nothing, man!

Discourse database backup download

Over the years, we’ve learned that balancing security and data portability can be tricky. You bet your sweet ASCII a full database download is what hackers start working toward the minute they gain any kind of foothold in your system. It’s the ultimate prize.

To mitigate this threat, we’ve slowly tightened restrictions around Discourse backups in various ways:

  • Administrators have a minimum password length of 15 characters.

  • Both backup creation and backup download administrator actions are formally logged.

  • Backup download tokens are single use and emailed to the address of the administrator, to confirm that user has full control over the email address.

The name of the security game is defense in depth, so all these hardening steps help … but we still need to assume that Internet Bad Guys will somehow get a copy of your database. And then what? Well, what’s in the database?

  • Identity cookies

    Cookies are, of course, how the browser can tell who you are. Cookies are usually stored as hashes, rather than the actual cookie value, so having the hash doesn’t let you impersonate the target user. Furthermore, most modern web frameworks rapidly cycle cookies, so they are only valid for a brief 10 to 15 minute window anyway.

  • Email addresses

    Although users have reason to be concerned about their emails being exposed, very few people treat their email address as anything particularly precious these days.

  • All posts and topic content

    Let’s assume for the sake of argument that this is a fully public site and nobody was posting anything particularly sensitive there. So we’re not worried, at least for now, about trade secrets or other privileged information being revealed, since they were all public posts anyway. If we were, that’s a whole other blog post I can write at a later date.

  • Password hashes

    What’s left is the password hashes. And that’s … a serious problem indeed.

Now that the attacker has your database, they can crack your password hashes with large scale offline attacks, using the full resources of any cloud they can afford. And once they’ve cracked a particular password hash, they can log in as that user … forever. Or at least until that user changes their password.

⚠️ That’s why, if you know (or even suspect!) your database was exposed, the very first thing you should do is reset everyone’s password.

Discourse database password hashes

But what if you don’t know? Should you preemptively reset everyone’s password every 30 days, like the world’s worst bigco IT departments? That’s downright user hostile, and leads to serious pathologies of its own. The reality is that you probably won’t know when your database has been exposed, at least not until it’s too late to do anything about it. So it’s crucial to slow the attackers down, to give yourself time to deal with it and respond.

Thus, the only real protection you can offer your users is just how resistant to attack your stored password hashes are. There are two factors that go into password hash strength:

  1. The hashing algorithm. As slow as possible, and ideally designed to be especially slow on GPUs for reasons that will become painfully obvious about 5 paragraphs from now.

  2. The work factor or number of iterations. Set this as high as possible, without opening yourself up to a possible denial of service attack.

I’ve seen guidance that said you should set the overall work factor high enough that hashing a password takes at least 8ms on the target platform. It turns out Sam Saffron, one of my Discourse co-founders, made a good call back in 2013 when he selected the NIST recommendation of PBKDF2-HMAC-SHA256 and 64k iterations. We measured, and that indeed takes roughly 8ms using our existing Ruby login code on our current (fairly high end, Skylake 4.0 Ghz) servers.

But that was 4 years ago. Exactly how secure are our password hashes in the database today? Or 4 years from now, or 10 years from now? We’re building open source software for the long haul, and we need to be sure we are making reasonable decisions that protect everyone. So in the spirit of designing for evil, it’s time to put on our Darth Helmet and play the bad guy – let’s crack our own hashes!

We’re gonna use the biggest, baddest single GPU out there at the moment, the GTX 1080 Ti. As a point of reference, for PBKDF2-HMAC-SHA256 the 1080 achieves 1180 kH/s, whereas the 1080 Ti achieves 1640 kH/s. In a single video card generation the attack hash rate has increased nearly 40 percent. Ponder that.

First, a tiny hello world test to see if things are working. I downloaded hashcat. I logged into our demo at try.discourse.org and created a new account with the password 0234567890; I checked the database, and this generated the following values in the hash and salt database columns for that new user:


Hashcat requires the following input file format: one line per hash, with the hash type, number of iterations, salt and hash (base64 encoded) separated by colons:

type   iter  salt                                         hash

Let’s hashcat it up and see if it works:

./h64 -a 3 -m 10900 .one-hash.txt 0234567?d?d?d

Note that this is an intentionally tiny amount of work, it’s only guessing three digits. And sure enough, we cracked it fast! See the password there on the end? We got it.


Now that we know it works, let’s get down to business. But we’ll start easy. How long does it take to brute force attack the easiest possible Discourse password, 8 numbers – that’s “only” 108 combinations, a little over one hundred million.

Hash.Type........: PBKDF2-HMAC-SHA256
Time.Estimated...: Fri Jun 02 00:15:37 2017 (1 hour, 0 mins)
Guess.Mask.......: ?d?d?d?d?d?d?d?d [8]

Even with a top of the line GPU that’s … OK, I guess. Remember this is just one hash we’re testing against, so you’d need one hour per row (user) in the table. And I have more bad news for you: Discourse hasn’t allowed 8 character passwords for quite some time now. How long does it take if we try longer numeric passwords?

?d?d?d?d?d?d?d?d?d [9]
Fri Jun 02 10:34:42 2017 (11 hours, 18 mins)

?d?d?d?d?d?d?d?d?d?d [10]
Tue Jun 06 17:25:19 2017 (4 days, 18 hours)

?d?d?d?d?d?d?d?d?d?d?d [11]
Mon Jul 17 23:26:06 2017 (46 days, 0 hours)

?d?d?d?d?d?d?d?d?d?d?d?d [12]
Tue Jul 31 23:58:30 2018 (1 year, 60 days)

But all digit passwords are easy mode, for babies! How about some real passwords that use at least lowercase letters, or lowercase + uppercase + digits?

Guess.Mask.......: ?l?l?l?l?l?l?l?l [8]
Time.Estimated...: Mon Sep 04 10:06:00 2017 (94 days, 10 hours)

Guess.Mask.......: ?1?1?1?1?1?1?1?1 [8] (-1 = ?l?u?d)
Time.Estimated...: Sun Aug 02 09:29:48 2020 (3 years, 61 days)

A brute force try-every-single-letter-and-number attack is not looking so hot for us at this point, even with a high end GPU. But what if we divided the number by eightby putting eight video cards in a single machine? That’s well within the reach of a small business budget or a wealthy individual. Unfortunately, dividing 38 months by 8 isn’t such a dramatic reduction in the time to attack. Instead, let’s talk about nation state attacks where they have the budget to throw thousands of these GPUs at the problem (1.1 days), maybe even tens of thousands (2.7 hours), then … yes. Even allowing for 10 character password minimums, you are in serious trouble at that point.

If we want Discourse to be nation state attack resistant, clearly we’ll need to do better. Hashcat has a handy benchmark mode, and here’s a sorted list of the strongest (slowest) hashes that Hashcat knows about benchmarked on a rig with 8 Nvidia GTX 1080 GPUs. Of the things I recognize on that list, bcrypt, scrypt and PBKDF2-HMAC-SHA512 stand out.

My quick hashcat results gave me some confidence that we weren’t doing anything terribly wrong with the Discourse password hashes stored in the database. But I wanted to be completely sure, so I hired someone with a background in security and penetration testing to, under a signed NDA, try cracking the password hashes of two live and very popular Discourse sites we currently host.

I was provided two sets of password hashes from two different Discourse communities, containing 5,909 and 6,088 hashes respectively. Both used the PBKDF2-HMAC-SHA256 algorithm with a work factor of 64k. Using hashcat, my Nvidia GTX 1080 Ti GPU generated these hashes at a rate of ~27,000/sec.

Common to all discourse communities are various password requirements:

  • All users must have a minimum password length of 10 characters.
  • All administrators must have a minimum password length of 15 characters.
  • Users cannot use any password matching a blacklist of the 10,000 most commonly used passwords.
  • Users can choose to create a username and password or use various third party authentication mechanisms (Google, Facebook, Twitter, etc). If this option is selected, a secure random 32 character password is autogenerated. It is not possible to know whether any given password is human entered, or autogenerated.

Using common password lists and masks, I cracked 39 of the 11,997 hashes in about three weeks, 25 from the ████████ community and 14 from the ████████ community.

This is a security researcher who commonly runs these kinds of audits, so all of the attacks used wordlists, along with known effective patterns and masks derived from the researcher’s previous password cracking experience, instead of raw brute force. That recovered the following passwords (and one duplicate):


If we multiply this effort by 8, and double the amount of time allowed, it’s conceivable that a very motivated attacker, or one with a sophisticated set of wordlists and masks, could eventually recover 39 × 16 = 624 passwords, or about five percent of the total users. That’s reasonable, but higher than I would like. We absolutely plan to add a hash type table in future versions of Discourse, so we can switch to an even more secure (read: much slower) password hashing scheme in the next year or two.

bcrypt $2*$, Blowfish (Unix)
  20273 H/s

  886.5 kH/s

  542.6 kH/s 

 1646.7 kH/s 

After this exercise, I now have a much deeper understanding of our worst case security scenario, a database compromise combined with a professional offline password hashing attack. I can also more confidently recommend and stand behind our engineering work in making Discourse secure for everyone. So if, like me, you’re not entirely sure you are doing things securely, it’s time to put those assumptions to the test. Don’t wait around for hackers to attack you — hacker, hack thyself!

[advertisement] At Stack Overflow, we put developers first. We already help you find answers to your tough coding questions; now let us help you find your next job.

How to Use JavaScript to Detect Browser

Wouldn’t it be nice if all of our code looked the same and worked the same no matter what browser our users are viewing our projects or web pages on? That’s the dream, right? Unfortunately, cross browser compatibility isn’t something that a site can achieve without adding some extra code.

There a few ways that you can use code to compensate for different browsers. You can us CSS selector browser hacks, which is a good option, especially if any changes you need to accommodate for are mostly cosmetic and can be fixed with CSS. For more dynamic browser selections, JavaScript is actually a valid way to go.

Below, you’ll find a code snippet that you can use to check for Internet Explorer, Chrome, Firefox, Safari, and Opera. The function checks for these browsers, and will execute any code you insert within the if/else if statements for each browser if the code is run on any of the browsers in question. Use the code to dynamically add classes to your HTML based on the browser, to send alerts to the user based on the browser, to trigger events based on the browser.

The code snippet is lightweight and straightforward, so even the most beginner coders should be able to add it to their projects. Play around with it and see if you can’t achieve that elusive cross-browser compatibility!

function BrowserDetection() {

 //Check if browser is IE
 if (navigator.userAgent.search("MSIE") >= 0) {
 // insert conditional IE code here
 //Check if browser is Chrome
 else if (navigator.userAgent.search("Chrome") >= 0) {
 // insert conditional Chrome code here
 //Check if browser is Firefox 
 else if (navigator.userAgent.search("Firefox") >= 0) {
 // insert conditional Firefox Code here
 //Check if browser is Safari
 else if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
 // insert conditional Safari code here
 //Check if browser is Opera
 else if (navigator.userAgent.search("Opera") >= 0) {
 // insert conditional Opera code here