Archive for the ‘Coding’ Category

Handy Linux Command

I don’t know why I never thought of this before.

#add current directory to $PATH
export PATH="$PATH":`pwd`

Personally, aliased to ‘pathhere’. Crazy helpful.

Kindle Now Available in Japan

Just a quick note to highlight the news that the Kindle Paperwhite and Kindle Fire HD tablets are now available for order in Japan. I’m very proud of my work on the Silk browser and the Fire tablets more generally, and it’s awesome to get to see them ship to new countries. The kindle devices are incredible pieces of technology and I hope that our Japanese customers get as much enjoyment out of them as I have gotten out of mine.

Dear Java Coders: JUnit Assert Inserts Double Quotes?

ATTENTION CONSERVATION NOTICE: This was caused by an insidious combination of a bug in the Eclipse debugger and a Unicode homeograph problem.

Has anyone ever had JUnit’s Assert API pad strings with extra double quotes? I hope this is a known issue, because the other option is that I’m going insane. The situation I’m running into is as follows:

class Constants {
    public static final String exampleString = "example";
 
    //No constructing for you!
    private Constants() {};
}
 
class exampleTests {
    public void testExample() {
        //Do some work  
        //assert fails. Debugger says exampleString contains "\"example\""
        assertEquals(example, someString); 
    }
}

Anyone seen this before? I tried the Googles, searching for e.g. “extra quotes in strings” and “java Assert pads strings with quotes” and “oh for fucks sake, JUnit, why you be breaking my shit with these double quotes?”

Alas, no luck.

Has anyone seen this issue before?

UPDATE: So this ended up being a bit of a tricky bug. It was a combination of a bug in the Eclipse debugger and Unicode homeograph issue with my string. See, the reason the two strings (which looked identical to my eyes) actually differed by one character. My test string had a lower-case ‘x’, but the input string actually contained the Unicode multiplication symbol, code point U+00D7. Those look an awful lot alike, so I didn’t realize the x/× homeograph confusion was the reason the assertEquals was failing, and assumed it has something to do with the extra quotes the debugger was telling me were in the string.

In my flailing, I moved the offending test string into the test class and the quotes from the Eclipse debugger went away. When the string still failed, that’s when I investigated more closely and realized that the strings actually differed. Once I fixed that issue, the test started passing.

On a hunch, I moved the test string back into the external class. Sure enough, Eclipse started telling me the test string had quotes around it. But the test still passed. Java saw the two strings as being value-equal, but the Eclipse debugger insisted that one had quotes around it, but the other didn’t.

I’ll be trying to repro this weekend on non-proprietary code so that I can file a bug to Eclipse.

New Kindles == Teh Sexy

In case anyone missed it, Amazon announced a new generation of Kindles today. It includes a new generation of E-Ink kindle, a refresh of the Kindle Fire, and the new Kindle Fire HD in two sizes. We also showed off a huge number of cool new features like X-Ray for movies, Time to Read, and tons more. If you missed the launch announcement (shame on you), here’s a good live-blog from the folks at The Verge.

The new devices are super slick, the new features are insanely cool, and the launch event was very well done. I’m very proud and extremely excited to have had a (very small) part in getting these devices ready for launch. They’re insanely cool, and I truly believe that Amazon is well-poised to take over the tablet market. We’ve got great hardware, killer features, and the best ecosystem.

We’ve also got the right strategy. Because as Jeff said in the launch event, we win when our customers win.

Oh, and to all the other tablet manufacturers out there:


Disclosure Notice

Fork -> Spoon -> Knife

I can’t wait to introduce my team to our new Git workflow:

Data Archival == Solved Problem

Ever needed secure archives of data? AWS has got your back. Amazon Glacier seems like a dead-simple, dead-sexy solution to the problem of making sure your bits are preserved for the long term.

This is one of the things I love about working for Amazon and especially being in the AWS group. Amazon is in the process of perfecting (through re-invention where necessary) every common tech world use case and doing is securely and scalably in the cloud. The shear range of products being released by AWS truly amazing, and every one I’ve had the chance to use has been executed on incredibly well.

Congrats to the Glacier team on their launch!


Disclosure Notice

Android Resources Prefers .png Over .xml Selectors

…Even if it’s the wrong .png.

So imagine you’re working on a low-dpi device. In order to select a drawable, you’re using a basic selector called “my_image.xml”. This is in res/drawable. For whatever reason, on medium-dpi devices, you just want a static image, so you make a “my_image.png” and drop it in /drawable-mdpi:

/res
    /drawable
        my_image.xml
    /drawable-mdpi
        my_image.png

On your low-dpi device, layout references in XML to (“@drawable/my_image”) will actually reference the medium-dpi PNG, instead of the selector in the drawable folder. In other words, Android’s resourcing system prefers PNGs to XML selectors, even if the PNG is for devices with the wrong dpi.

Moral(s) of the story?

  • Avoid naming collisions where possible.
  • Avoid mixing generic drawables with drawable-xdpi whenever possible.
  • Android will pick images over selectors if there is a conflict.

Happy Edge Case Awareness Day!

Once every four years, we programmers celebrate an obscure but important day of awareness and solemn reflection. And by that I mean we eagerly cruise the web looking for other programmers’ Date/Time fuckups whilst hoping that we haven’t committed any of our own in the four years. Here’s a couple good examples, courtesy of the always excellent Daily WTF.

Some Notes in Passing

I have a back log of stuff I’ve been meaning to post about and probably would have last week if I hadn’t been lying blissfully semi-comatose on a beech.

So here is that backlog:

Go Go Gadget Bulleted List!

  • The British Government, after torturing Alan Turing to the point where he took his own life, has now decided not to issue him a pardon. I don’t think I can accurately describe the rage this engenders in me as a programmer, a libertarian, and a person with even a passing sense of justice.
  • My friend Jonathan, over at his excellent Trade Diversion blog, has a fantastic post on globalization and local prices. It is title, appropriately, Don’t go to Shanghai for your Big Mac
  • I’ve been meaning to post for awhile about the minor kerfuffle over President Obama signing statement calling out a measure that would restrict the government from using certain funds to advocate for gun control. Now I love the Pro-2A camp and I think we do a lot of good work. But the backlash against Obama was, in this case, wrong. Now take as read that I think signing statements are several varieties of bullshit. And I definitely don’t think that the government shouldn’t be advocating for more gun control. But in this case, Obama is accurately pointing out that the text, as written, could potentially impinge on his job as written in the constitution. To whit, Obama’s constitutional authority to suggest to congress whatever measures he finds necessary and expedient. So Obama is, in this exceedingly rare instance, actually protecting the Constitution. And the Pro-2A camp attacked him for it. *Headdesk*
  • What SHOULD the libertarian and pro-2A camps be worried about and about which I’ve heard barely a peep? Meretricious, mendacious fuckwittery like this. Alan Gura, one of the best friends Lady Liberty has in this country at the moment, got shat on by a bunch of beauracrats who are paid on the taxpayers dime because, in these trying economic times, we must be careful with the taxpayer’s money. So apparently it’s okay for DC politicos to impinge the rights of the taxpayer on the taxpayer’s dime, but when it comes time to pay the man who put them in their place, well, then we have to be tight with the purse strings.
  • Finally, on a lighter note, I present the latest from comedic genius Tim Minchin:

Amazon Silk is Hiring!

By now, my loyal readers should know that I’m a programmer for Amazon. Just over a month ago, I started on the Amazon Silk team. It’s a talented team of hard-working engineers at an amazing company. We’re a team that’s growing quickly, and we’re in desperate need of smart programmers. Here’s why you should apply to Amazon:

  • Excellent compensation and benefits. I have to confess that I have something of a mercenary streak. So I won’t beat around the bush and just say that Amazon pays very, with compensation philosophy that fairly balances cash, stock, and bonus. One of the best aspects of this is that Amazon doesn’t give you stock options. They give you actual stock. I’m basically of the opinion that stock options are an amateur-hour scam, and so I’m happy that when my Amazon stock vests, it’s mine.
  • An unbeatable corporate culture. Many corporations have “Corporate Virtues” or similar. Handy sappy phrases they put in press releases more for PR impact than to act as guiding principles. Amazon is the only company at which I’ve worked where those principles are taken seriously. Amazon has an amazingly customer-centric culture that values ownership and inventiveness and rewards accomplishment.
  • A career path for engineers. Many tech companies has two positions for programmers: Programmer and Senior Programmer. The difference being that the senior programmer threatened to leave at one point. Amazon, on the other hand, is a company that’s been built almost entirely engineers. It’s a company that understand that programmers are craftsmen and they have unique interests, talents, and areas of specialties. They also understand that programmers don’t stop growing at the mythical 5-year mark. So at Amazon, there’s a complete engineering path, going from introductory level SDE I positions all the way up through Distinguished Engineers. Each level is well-defined, without being constraining. The company encourages you to develop your skills and improve your craft, and they reward that improvement with increased responsibility and freedom.
  • Nerf Wars Several of the guys in this video are on Silk now. Work with some of the best Nerf Marksmen in the software industry.
  • Complete mobility. Amazon understands that programmers have diverse interests and tend to appreciate novelty and interesting new problems. Which is why Amazon encourages people to switch teams and job roles on a regular basis. Many programmers switch teams every year or so. I only spent thirteen months on my initial team, and when the chance came to apply to join the Silk team, it was as easy as letting my manager know. Even international transfers are available, as Amazon has developers all across North America, Europe, and Asia.
  • Be the worst person in the band. Pat Metheny, the legendary jazz guitarist, once said that the secret to his success was that he always made sure he was the worst guy in every band he was in. That goes for any art and any craft, programming not excepted. I often feel like I’m the worst guy in the band. I can tell you honestly and without hyperbole that I work with some of the smartest programmers in the world. I’ve learned more in fifteen months at Amazon than I learned in four years of college and four years of diverse industry experience. There’s no better place to learn and sharpen your craft, and to get to know some of the brightest technical minds in the world.
  • Kegerator. Amazon’s official motto is “Work hard. Have fun. Make History.” They definitely take all three parts of it seriously. And part of having fun is things like having a Kegerator in kitchen.
  • No, seriously — Make History. Amazon solves problems that no one else in the world has solved. There aren’t many places in the tech industry where you can do that. On the Silk team, we’re rewriting what it means to have a browser in the era of cloud computing. We’ve had great success so far, but we’re only just getting started. We’re going to make history and we want smart, hard-working engineers to help us do that.

So that’s the hard sell. If you want to learn more feel free to drop me a line in the comments or shoot me an email. If you want to apply, you can email me your resume at aabrown@amazon.com.


Disclosure Notice

Return top

Magic Blue Smoke

House Rules:

1.) Carry out your own dead.
2.) No opium smoking in the elevators.
3.) In Competitions, during gunfire or while bombs are falling, players may take cover without penalty for ceasing play.
4.) A player whose stroke is affected by the simultaneous explosion of a bomb may play another ball from the same place.
4a.) Penalty one stroke.
5.) Pilsner should be in Roman type, and begin with a capital.
6.) Keep Calm and Kill It with Fire.
7.) Spammers will be fed to the Crabipede.