Fork me on Github
Fork me on Github

Joe Dog Software

Proudly serving the Internets since 1999

Parse The Version Number With Ant

“The best programmers are all alike; every shitty programmer is shitty in his own special way.” –Anna Karenina

Earlier Your JoeDog mentioned a trait of good programmers. They model data so each element is stored in only one location. This principle is known as a Single Source of Truth. To illustrate that principle, he pointed to siege’s version numbering. The number had to be available in both the program and its helper scripts. In order to uphold SSoT, he stored the number in version.c and parsed that file with a helper script.

Here’s an astonishing fact: not everyone loves the C programming language. Some of you are Java weenies! Fear not, weenies, for you we have another example.

Same problem, different language. We want to store the version number in one location but it must be available for two mechanisms. The first mechanism is the program itself. That’s important, right? It helps answer the question “Which fscking version am I running?” The other mechanism is ant. When we build our jar file we’d like to add the version number to its name, i.e., pinochle-1.0.7.jar.

Let’s examine this is closer detail after the jump.

Continue reading Parse The Version Number With Ant



DRY Programming

“The best programmers are all alike; every shitty programmer is shitty in his own special way.” –Anna Karenina

Today we are going to discuss one of the most important traits of a good programmer: He’s DRY, which is an acronym for “Don’t Repeat Yourself.” This principle is also referred to as Single Source of Truth. DRY programmers rarely use a clipboard. Their data is structured so that every piece of information is represented exactly once.

DRY code is easy to maintain. When a data element is stored exactly once, a single edit changes its value throughout the system. As soon as this principle is violated, maintenance becomes a bitch. For you bean counters out there — you guys who thought cheap programmers would save you money — that means expensive.

“I thought I changed that!” You did. The last programmer typed the same thing multiple times. “Where are the other instances?” I have no idea. “What did he call them?” God only knows. “There’s 50,000 lines of code across twenty files.” Well then you better start searching …  “FSCK!”

The best programmers adhere to this principle no matter what. It doesn’t matter if the same piece of information is needed by two separate tool kits. They use one piece of data and parse it with two separate languages. Let me give you an example.

When you download siege, you get a tarball named siege-3.1.0.tar.gz When you run siege –version, it displays the version number. In one case, the number is interpreted by C code, in the other it’s interpreted by a shell script. No matter, in both cases it’s sourced inside a single file. You can find it in src/version.c

So while it would have been easy to type “3.1.0” in the C file and paste that value inside configure.ac, Your JoeDog would have to update it twice with every release. You know how often he’d miss one of those two edits? Every stinkin’ release.

In order to adhere to the DRY principle, he made the configure script parse a string in version.c  That string looks like this:

const char *version_string = "3.1.0";

And Your JoeDog parsed the number in configure.ac like this:

VERSION=`sed -ne 's/.*version_string.*"(.*)";/1/p' ${srcdir}/src/version.c`

NOTE the use of ${srcdir}; one copy of everything, people.

Look, I know some of you are going to be like “fsck that guy. I’ll copy and paste to my heart’s content.” That’s fine as long as you are now and will always be the only maintainer of your code. But if you expect another human to work that code and if you insist on being WET (We Enjoy Typing), then you’re a bad programmer. Hey — somebody had to say it.



Some People Need Structure

Charleston ShooterEarlier this week a young white man walked into a black church in Charleston. His name was Dylann Roof and he sat down with a prayer group. The church welcomes all so the stranger was no cause for concern. After about an hour, he rose from his seat, pulled out a gun and started shooting into the prayer circle.

According to a survivor, someone begged him to stop. He responded to that plea like this: “No, you’ve raped our women, and you are taking over the country … I have to do what I have to do.” And he shot the young man. Nine people died that night.

You can call Dylann Roof a racist asshole. You can say he’s a monster. Or a craven little pussy. Your JoeDog won’t disagree. Here’s something else he was: misguided.

From the Washington Post we learn that Roof dropped out of high school in ninth grade. He drifted aimlessly. He laid around the house and dabbled in drugs. His parents implored him to find a job and he went to the mall and pestered store managers but it doesn’t appear that he left with any job applications.

With no schedule he wandered aimlessly. With no agenda, he formed his own, a refinement of bad ideas. With nowhere to go, his interactions became fewer, his views more esoteric. There are plenty of young men in this rut. Most refrain from killing others but that doesn’t mean it’s not a problem. In the best scenario, Dylann Roof would have accomplished nothing, helped no one and achieved nothing.  The worst scenario was on display in a Charleston Church.

Some people have lots of ideas. They have long todo lists and insufficient time to check every item. For them an unstructured life is a blessing. They can align their tasks by their daily moods. A flexible schedule allows them to create many great things. When their mood changes, it’s not a problem for these folks. There’s always something else to do.

That doesn’t work for people like Dylann Roof. People like that need structure. They need schedules and task lists provided by others. They need things to do. Guns aren’t going away – not in America, anyway. If we hope to stop this endless chain of horrific mass shootings, then we need to find a way to help people like Dylann Roof organize their lives.  We have to find them something to do. As tasks become increasingly more automated, that might become ever more difficult.



Google Analytics And You

Your JoeDog is no marketing guru. He doesn’t use conversion tracking to see if he’s met business objectives. Heck, he doesn’t have business objectives. Ideally, he’d like to generate enough ad revenue to cover the cost of hosting this site but that’s the extent of the marketing plan.

Still he uses Google Analtyics. Why? Everyone says “You gotta use Google Analytics.” Okay, fine. He’s google-analyzing. That tool provides metrics that allow him to gauge long term trends. He reads those trends like this: “Up slope, good. Down slope bad.”

Google Analytics also provides demographic information. Your JoeDog has no idea what do with that. Basically, he looks at it and goes, “That’s more or less what I expected.” So according to Google Analytics, what does a typical JoeDogger look like?

Glad you asked. He — yes, he, 94% of you are men — is a 30 year old American technologist who’s also a bit of a news junkie and likes to travel. His favorite browser is Chrome but he prefers iPhone to Android. His ISP is Comcast and he arrived at this site by clicking a link.

The second most common JoeDogger is a Chinese technologist. Third most is a British technologist. Fourth most is a technologist from France. Apart from varied countries, you guys are basically the same: nerds!

Your JoeDog really has no plans to do anything with that information. He just thought he’d share it.



Friends Who Like ________

There’s a link going around the Facebooks. Exciting! It’s usually implemented like this: Click here to see who you should de-friend! Ha Ha! That’s only funny because they’re the lamest lamers who ever lamed.

Do you want to create a similar facebook link but you don’t know how? Well, Your JoeDog is here to help.

First: Find something you don’t like. Something like this:

https://www.facebook.com/MiamiDolphins?fref=ts

Now copy the path from that URL. In this case, we’ll put this on our clipboard: /MiamiDolphins

Second: Construct another URL so we can graph search for its ID. You’ll append the text on your clipboard to graph.facebook.com. The finished URL should look like this:

http://graph.facebook.com/MiamiDolphins

When you hit that URL in your browser, it will return some JSON. Don’t worry if you don’t understand all that stuff. There’s only one small bit of information that matters to us. We’re looking for the page ID. In this case it’s right at the top:

{
   "id": "87132269610",
   "about": "Welcome to the official Facebook home of the Miami Dolphins.",
   "can_post": false,
   "category": "Sports Team"

Third: Use that ID (87132269610) to construct your link: De-friend these people!!!

NOTE: Ha Ha! Your JoeDog switched IDs on you….



Sleeping Aids (Or How To Sleep After Turning Caffeine Into Code All Day)

When Your JoeDog was a kid his parents tried to put him to bed with little success. They yelled, they bribed, they pleaded but nothing seemed to work. There was always another teevee show to watch, another coke to drink and another toy to play with. After about six or seven years of futility, his parents said “fsck it.” They went to bed while he watched McMillan & Wife on the CBS Late Movie.

The fact is Your JoeDog has always been a pretty shitty sleeper.

It’s a trait that doesn’t seem to run in the family, though. By the time he was ten, Your JoeDog was known to cook himself a 3:00 am breakfast. He’d clang pots pans while the parental-units slept through the clatter.

After he graduated from college, Your JoeDog was surprised to learn the boss wanted him at work … on time … in the morning. It was a revelation that prompted a life-long quest for the perfect sleep aid. When he sees ads for these products online, Your JoeDog is quick to click. “Well, hey, let’s see what this can do.”

Tonight he was all Clicky McClickums and found himself reading reviews for Somnapure on Amazon. It’s a pill which contains herbal supplements. Some reviewers loved it while others thought it worthless. In a field of over 400 reviews, one stood out.  J. Charlton loved this pill so much he gave it five stars:

this cream is magical. My wrinkles are gradually disappearing since I started using this product.. I am 90 yours [sic] old and my skin is amazing for my age.

Mmmmm think I’ll pass….

So what does Your JoeDog recommend for insomnia? After all this time he’s only found one product that consistently works: Bob Marley Mellow Mood Tea. It’s a decaffeinated tea with herbal additives. The key ingredient is valerian root.

Unfortunately, he can’t just take valerian pills. In the US, supplements aren’t regulated and they rarely contain the ingredients listed on the bottle. That doesn’t appear to be the case with Mellow Mood. If Your JoeDog downs one of these before bedtime, he sleeps like a little tiny baby. Well, somebody else’s baby. He never actually slept as a child.

NOTE: This is not a paid promotional piece of bullshit. Your JoeDog truly loves Bob Marley’s Mellow Mood. He thinks you might love it, too.



Paul Krugman And The Virtue Of Skepticism

Yes, this is a nerdblog. Yes, we focus on technology. No, this post isn’t about technology. Today we turn our attention to Paul Krugman. Why? Your JoeDog studied economics and sometimes he likes to distribute nerdy turd droppings. Consider this a dropping.

In a recent post Paul Krugman devoted time to the virtue of skepticism. In particular, he says, you should be leery of studies that neatly correspond with your own political preferences.

That’s good advice. For illumination he offers this nugget:

For example, I’ve been aggressively skeptical of studies that seem to show a negative relationship between inequality and growth, precisely because that result is so convenient for my political tribe (which doesn’t mean that it’s wrong.)

Now Your JoeDog’s high-level macroeconomic views generally align with the New York Times columnist. Like Krugman, he was schooled on Paul Samuelson’s Macroeconomics textbook. That book provides a framework that is recognizable to Krugman’s readers.  Sadly the similarities end there. Krugman is a Nobel Laureate and Your JoeDog is a guy who yells at him on the Internets.

When he sees Krugman is extra skeptical of views that support his political position, that gives cause for pause.

Why?

When Thomas Piketty made a stir with Capital In the 21st Century, Krugman was an early cheerleader. Consider this column. It was written ten days after the book was available in the US. Krugman may have had an advance but how long is the period of extra skepticism? Two months?

Look, Piketty also supports Your JoeDog’s priors but he remains skeptical of his economic analysis. It contradicts much of what he learned in Macro 101. It probably contradicts what Krugman teaches his own students. When we follow the framework that Samuelson provides, we expect wages to rise as unemployment falls, amirite? That’s what happens when companies compete for workers. Supply and demand, motherfsckers.

What stands in the way of 1990s employment levels is politics. When governments prioritize low inflation over low unemployment they do the bidding of wealthy benefactors. Piketty makes more sense when he’s viewed in this context. People with money can (and do) influence policy. From a macroeconomic perspective, his data seems to track the symptom rather than the cause.

If Krugman now practices aggressive skepticism, that’s a good thing. Piketty should be scrutinized. In the meantime, the answers for wage stagnation already exist in Krugman’s own textbooks. Let’s hope he avoids distraction and promotes those ideas more aggressively. In the long run, we’ll know if Piketty was onto something but we already have the tools to fix wage stagnation. That’s is where our focus should be now.



Search, Search, Search … The Boys Are Missing!

bad chart - downward spiralYour JoeDog is confused. He can’t help it; Google can’t keep its story straight.

For example, in Google’s Webmaster Tools, they tell him 16 people clicked search results that pointed to www.joedog.org last month. In Analytics, they tell him 11,696 people clicked links over that same period. That’s quite a discrepancy.

Here’s another head scratcher: In Analytics, they say Your JoeDog had just under 50,000 page impressions in May but Adsense says it was over 60,000.  That’s unexpected, right? Many of you are running ad blockers — hey! why are you blocking Your JoeDog’s ads? — shouldn’t we expect more Analytics impressions than Adsense impressions?

The only analytics program we really trust is Webalizer.  That’s a log analysis tool which provides summary reports of all activity. If you make a request, it’s in the logs and therefore in the report. So while Analytics says 50,000 page impressions and Adsense says 60,000 page impressions, Webalizer says “No, yo, it was actually 317,490.”

None of the 260,000 people who eluded Google’s detection are reading this post. They are login attackers, link spammers, referrer spammers and an assortment of other dicks. Your JoeDog doesn’t know all the things they’re doing to this site but he’s confident of one thing: there were at least 260,000 of them last month.



US Government: We Suck At Security; Trust Us With Your Records

navalwarcollegehackers_168457_372093-300x193Your JoeDog is not one of those knee-jerk anti-gub’mint guys but god damn sometimes they test his patience.

By now you’ve heard of that database breach in which the Chinese allegedly stole the personal information of approximately 4 million government employees. About half of those records represent current employees, the rest are for previous workers. According to an unnamed US “official,” the data goes back to 1985.

CNN interviewed “experts” who told the network that the Chinese appear to be building a large database of Federal employees which will help them model the organization and setup insider attacks.

One-third of Your JoeDog’s visitors are from China and we’re starting to feel like an abused spouse. We give you free software and you break down the door and steal our records. Thanks, China. Thanks, a lot.

But here’s the real kick in the ass: US government officials cite this breach as a reason to pass a host of legislature which will, among other things, put more personal information into the hands of government. Information-sharing clauses in these bills will essentially channel more personal data from businesses to the Federal government. That makes Your JoeDog’s head explode. The government is essentially saying, “We can’t secure our own records so give us more records.”

The chairpersons of the select committee on cybersecurity have their hair on fire. They predict dire consequences if we don’t grant them more personal data: “Business and industry leaders warned us of the growing threats during various hearings, and this attack shows why the Senate needs to move quickly on a cyber bill.”

The shittier a bill is the quicker is must be passed, people. Don’t worry your pretty little heads about its contents.

Funny thing: Newton’s Third Law applies to politics as well as physics. For every asshole, there’s an equal and opposite anti-asshole. Are you from Oregon, Dear Reader? Then pat yourself on the back because your senator is our anti-asshole.

I believe sharing information about cyber-threats is a worthy goal, it is unlikely that information sharing by private companies would have made any significant difference in protecting federal employee data. That’s why cybersecurity experts say that passing a bill like this will do little to reduce security breaches.

“This is a bad excuse to try and pass a bad bill.”

Amen, Senator Anti-asshole. Amen.



Now That’s Underhanded

The Underhanded C Contest challenges participants to write straightforward and clearly written code which doesn’t perform its intended purpose. Winning entries should easily pass inspection by other programmers so they can be added to the code base in order to execute their intended purpose which is to miscount votes, shave money from transactions or pass along information to another party, etc.

Some of the techniques used in this year’s contest include the use of K&R style function declarations to circumvent type checks, #include statements that change the package structure, swapping user space #define with system ones and a misleadingly long loop execution.

The winning entry leveraged the __isleap() function in time.h. Because that function is actually a macro it expands into an expression when a user defined macro is invoked multiple times. The winning author placed a subtle bug in that macro which plausibly turns the year into a 0 and writes past a buffer thereby performs the author’s intended purpose: to leak information to the outside world.

[Karen Pease: The Underhanded C Contest Winner]