Use Break Statements, People

A few years ago, Your JoeDog was re-working someone else’s code. Fun times!  It was written in java by a professional web shop out of Chicago. He’s not going to name the shop but it rhymes with “Oxy Dom.”

In one particular segment, there was a big mother of a switch statement with perhaps a couple dozen case conditions. That’s quite a few case conditions! But here’s the thing about this code which was executed by a highly paid software engineer. It contained no break statements.

Why does that matter? Let’s find out after the jump! Continue reading Use Break Statements, People



Big In India

According to Alexa. Your JoeDog is ranked 300,052nd in the world. That’s cool — I guess — but in India, it’s ranked 127,320 and that’s stinkin’ awesome. “Big in India, tonight. Big in India, alright…”

Here’s the thing: We’re big India even though we drop references to archaic Western things like Alphaville and a 1980 Pennsylvania lottery drawing. Imagine if we dropped the names of attractive Indian women. Imagine if we mentioned Kareena KapoorAishwarya Rai and Rani Mukherjee. We could be 126,00 by Friday…

 



A Nerd Dream Becomes Reality

xrayGreg Charvat has been tinkering with things his entire life. He’s well-known in the maker community where he’s published a lot of neat hacks. In his garage he builds vacuum tube audio equipment and restores antique autos. He’s also a university professor who’s written a course on building RADAR systems. Now comes the fun part. Greg recently combined his maker skills with his scientific knowledge to make every nerd’s wet dreams a reality. He’s developed x-ray vision!!11!1!!



Hacking Computers

stallmanYour JoeDog has blogged about cyber intrusions recently. (Yeah, we know, how about discussing something else?) In these discussions, he tends to avoid the terms “hacked” or “hackers.” While those words commonly refer to infiltrations and intruders, they are erroneously applied by the tech media. Hacking is an ethic to which hackers subscribe.

This ethic was popularized by Steven Levy in the book “Hackers.” To Levy, the last true hacker was Richard Stallman, founder of the Free Software movement.

In the early 1980s, software producers began putting restrictions on their products and stopped distributing their source code. This put a damper on the hacker community which was used to a free flow of information. Stallman was peeved that he couldn’t freely alter, copy and share licensed software with colleagues. It struck him as highly unethical. In “Hackers” he contrasted this ethic with his own:

“The hacker ethic refers to the feelings of right and wrong, to the ethical ideas this community of people had—that knowledge should be shared with other people who can benefit from it, and that important resources should be utilized rather than wasted.”

When it became apparent that he couldn’t fight City Hall, Stallman decided to build his own operating system. Its copyright would mandate code sharing. You could use the source however you liked as long as you published your changes and made the source available. Distributors could not restrict access to the code. This is the essence of the GNU Public License.

So the key points of hacker ethics were free access, freedom of information and the betterment of all. Yet somehow the term is now almost universally known for breaking-and-entering. Are these people hackers? Well, maybe.

Your JoeDog considers guys like Richard Stallman hackers. He considers himself a hacker as well. When dickheads were attacking his site, he published his method of thwarting them. That’s hacking. Breaking-and-entering guys? They’re just dicks.

Unfortunately, Your JoeDog doesn’t control the lexicon so the term is now applied to the world of cyber-security. And within that community, subcultures have formed. We now have white-hat, black-hat and grey-hat hackers. The first group is dedicated to finding, publishing and fixing security flaws. They are most assuredly hackers that Stallman would recognize.

Black-hats are dedicated to finding and exploiting computer vulnerabilities. Are they hackers? It’s a tricky question: they could be. There are many who publish and share their vulnerabilities. They may do that for LULZ instead of a desire to share for the betterment of the community but the result is the same. These guys often benefit the community but it’s a small community comprised of other black-hats. They tend to restrict information to the outside world.

Grey-hats are morally ambiguous types who fall in between the white and black communities. Your JoeDog considers them the least likeable of all the dark side. Grey-hats are the guys who will work within the white-hat community then sell a zero-day exploit on the black market. Fsck those guys.

As a general rule, if the tech media properly applies the term “hacker” then it probably pulled a Homer, i.e., properly applied the term despite the ignorance of the author.

 



The Massive Scale of AWS

Here’s an interesting peek behind the scenes at Amazon Web Services:

Scale is perhaps the most important thing, and no one needs to teach an online retailer like Amazon anything about that. With Amazon, there is very little talk of public cloud, and that is because Amazon believes that, by its nature, cloud means it cannot be private. Over the long haul, Amazon believes the massive scale of the public cloud will mean that very few organizations will run their own datacenters.

Interesting throughout.  (H/T to Tim for bringing it to my attention)

[Enterprise Tech: A Rare Peek Into The Massive Scale of AWS]

 



Valgrind: Apology Edition

The things Your JoeDog will do for you….

A couple weeks ago he complained about Valgrind (and probably a whole bunch of other stuff but we’re talking about Valgrind now). His snippet was leaking memory and valgrind was unable to identify the leak. The leak was manually identified in this function:

ARRAY
array_destroy(ARRAY this) 
{
  int i;

  for (i = 0; i < this->length; i++) {
    xfree(this->data[i]);  
  } 
  xfree(this->data);
  this = NULL;
  return this; 
}

While we freed the elements of the array, we never freed the array itself. The leak is fixed like this:

ARRAY
array_destroy(ARRAY this) 
{
  int i;

  for (i = 0; i < this->length; i++) {
    xfree(this->data[i]);  
  } 
  xfree(this->data);
  xfree(this);
  this = NULL;
  return this; 
}

Today Your JoeDog was coding on the train again.  Before he boarded, he downloaded the above code onto his snazzy Linux laptop.  He was turning caffeine into code when wouldn’t you know it? Another stinkin’ memory leak. “What the hell,” he thought. “Let’s give valgrind another try.” Unfortunately it wasn’t installed on snazzy Linux laptop. For some reason, Amtrak’s proxy won’t allow downloads larger than 10MB. Stupid Amtrak.

That’s easy to bypass. Your JoeDog established an ssh tunnel from his laptop to this webserver and proxied to the Ubuntu repository.

 

--2014-10-25 10:15:13--http://us.archive.ubuntu.com/ubuntu/pool/main/v/valgrind/valgrind_3.10~20140411-0ubuntu1_amd64.deb
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:11111... connected.
Proxy request sent, awaiting response... 200 OK
Length: 15078790 (14M) [application/x-debian-package]
Saving to: ‘valgrind_3.10~20140411-0ubuntu1_amd64.deb’
100%[=============================================>] 15,078,790 290KB/s in 73s
2014-10-25 10:16:26 (202 KB/s) - ‘valgrind_3.10~20140411-0ubuntu1_amd64.deb’ saved [15078790/15078790]
 Funny thing. That copy of valgrind found the leak. Guess where it was? Give up?
ARRAY
array_destroy(ARRAY this) 
{
  int i;

  for (i = 0; i < this->length; i++) {
    xfree(this->data[i]);  
  } 
  xfree(this->data);
  //xfree(this);
  this = NULL;
  return this; 
}

In order to illustrate his first post on valgrind, Your JoeDog commented out the fix he told you about. Well, this second copy of valgrind found it. So what gives?

1. Valgrind works and I’m sorry I busted on it.

2. RedHat’s version doesn’t seem to work but Ubuntu’s does.