My latest project: TwitterTranslate

Tonight I made this little Safari 5 extension: TwitterTranslate

Pretty simple – it finds any foreign tweets on your Twitter feed and translates them to English, or Spanish, or Japanese, or whatever your native language is. Enjoy!

Posted in Coding, News | Leave a comment

India to monitor BlackBerry messages

As expected, more governments are jumping on the BlackBerry-monitoring bandwagon. The latest to join the craze is India, which has set an August 31 deadline for RIM to “provide technical solutions that will allow security agencies to monitor the company’s BlackBerry corporate email and messenger services.”

Posted in Mobile, News | Leave a comment

A chink in RIM’s armor

The UAE and Saudi Arabia, in remarkably short time, convinced RIM to set up data centers and allow surveillance of BlackBerry Messaging in their nations. India and the United States have been asking for surveillance options for years, but Saudi Arabia convinced them to set it up within the span of a week. The UAE has a deadline of October 11, that it seems likely, RIM will meet.

RIM has built a reputation of having a very secure network, which is unique for the mobile messaging industry. Messages on the BlackBerry network are encrypted, so even intercepting wireless signals can fail to be effective. RIM’s data centers are in Canada and, to the best of my knowledge, even the Canadian and United States governments don’t have easy access to messages in RIM’s servers. How did the UAE and Saudi Arabia convince RIM, so quickly, to give them access to messaging data within their nations?

With a relatively small security force, the UAE relies heavily on electronic eavesdropping to monitor for any potentially subversive activities. The Gulf nation has been particularly on edge after a Hamas leader was assassinated in Dubai earlier this year” – Tom Peter, Christian Science Monitor

Since that assassination, the UAE has put pressure on RIM to open up message data for snooping. Supposedly, BlackBerry messaging was involved in the assassination – but even if it wasn’t, BlackBerry messaging remains conspicuously absent from the UAE’s surveillance program, and that’s making the nation’s government nervous.

But RIM has, until now, remained consistent and resilient: they do not give surveillance abilities to one government and not others. Even if they did, they don’t possess the keys used for encrypting corporate networks. This is reassuring for businesspeople, government officials, and maybe even terrorists who travel internationally and send confidential information over the BlackBerry network.

Until Saudi Arabia called RIM’s bluff and shut off the BlackBerry network for two hours. RIM quickly conceded and agreed to set up a data center in Saudi Arabia that the government could snoop on. Now RIM has lost their higher ground and they’ll have to concede to other nations’ demands: UAE wants their own data center to snoop on, India does too, Kuwait wants pornography filtered from the BlackBerry network, and other nations are sure to have demands of their own in the next few weeks.

Most likely, this will just mean headaches for RIM and more overhead operating overseas. They’ll no longer be able to boast such a secure network, except to corporate users with their own data centers who should be unaffected. But realistically, most BlackBerry users won’t be affected. Consumers who use it domestically (in the U.S., Canada, Europe, etc) don’t care about what’s going on in the UAE or Saudi Arabia or India. Corporate users will be on a corporate server if it matters to them. But now that RIM has caved to the UAE and Saudi Arabia, they will have to cave to other nations’ requests too.

Posted in Mobile, News | Tagged , | 2 Comments

Environmental History of Ladysmith

In my Freshman year at UW-Madison I wrote this paper on the environmental history of Ladysmith, WI, my mother’s hometown. I’m linking to the PDF here for posterity.

Ladysmith, Wisconsin – Mushroom City

Posted in History, News, Personal | 2 Comments

iPhone photo and music compression

While happily exceeding the bandwidth limit on my 200 MB 3G data plan with AT&T, it occurred to me that a large chunk of that bandwidth has been devoted to uploading photos. I decided to look into if/how the iPhone stores photos and how they’re compressed, and found some details on music compression along the way.

Music compression

Over at Just Another iPhone Blog, @ragart details the new option in iTunes 9.1 that allows music compression on the iPhone. This is pretty straightforward: it just lowers the bitrate of your music and saves about 40% disk space in the process. You’ll notice the lower quality if you’re using decent earbuds, headphones or a stereo setup.

Image compression

To see how compression works, I did some very informal testing. I uploaded three Photos to MobileMe: one is a portrait indoors, one is a sunset photo, and one is a poster outside. I uploaded them to my MobileMe account and according to MobileMe, the original photos are 2592×1936 pixels and average 1.5 MB each.

The “actual size” photos on MobileMe are scaled down to 764×1024 pixels and average 149 KB each. This means that the scaled-down photos are 10% the disk space of the originals. Running jpegoptim on all the photos resulted in savings of only 2 KB per image, so MobileMe is doing a pretty good job at compression.

Which leads me to this question: Why should I be uploading 1.5 MB photos over 3G when all I’ll ever be viewing are the scaled-down images at 10% the file size? Other popular services are scaling down too, think Facebook and Twitter image services.

I’ll post my answer to that question another time. Until then, let me hear your thoughts.

Posted in News, iPhone | 4 Comments

iPhone 4 MMS / Group Messaging

I just got an iPhone 4, less than a week ago. It’s my first iPhone. As a self-described textaholic, I’ve been having a lot of fun with it.

The only trouble I’ve had texting so far is with MMS and group messaging. If you turn on MMS and group messaging, all group messages will be sent as MMS regardless of whether or not they include photos/video/etc. This is because all the recipients are sent along with each text, so if you send a group text to iPhone users, any replies will go to all of the original recipients.

Cool, right? Usually – but if one of your recipients can’t receive MMS (probably because of their phone’s model) they won’t receive that text at all. Or any replies.

Unless you send texts exclusively to iPhone users, it’s probably safest to turn MMS on and keep group messaging off.

Posted in News, iPhone | Leave a comment

A Certain Elephant #98

A Certain Elephant #98: Tina's Sense of Awesome: feeling okay.

Please rate:
Next

Updated Sometimes

Help me transcribe this comic


Posted in A Certain Elephant, News | Leave a comment

PHP best practices #1: duplication is evil

I am very opinionated about my code.  The source of most of my opinions is the DRY/DIE principal: Don’t Repeat Yourself / Duplication Is Evil.

 

Take, for instance, a Human Resources application I worked on recently. It is a collection of web forms to get information to and from the HR department at work.  I inherited the system and had to make several improvements: form field validation had to be more robust, submitted form data had to be formatted in a prettier way, fields had to be removed/added, etc.

This was a pain. This application was simple – two forms, less than 50 fields total across each. Total lines of PHP code: 1000 maximum, including comments and HTML. That’s tiny! And yet, within this tiny code base, information was duplicated at least six times. And it was inconsistent – each duplicated piece of information told a different, contradictory story about the web form.

This is why I have internalized the DRY/DIE principal. If you stick with this principal from the get-go, applications are much more robust and easier to maintain. Luckily, my story has a happy ending: I ported 90% of it to PHP-Frame and modified the forms with time to spare, and even got a few nice cosmetic extras in.

tl;dr for this post: next project you’re working on, count how many places you duplicate similar information. Try to minimize that number. I reduced it from 6 to 2 in my application (all the form field validation requirements laid out in the application’s Model; and all the form fields laid out in HTML).  Many methods can be used to avoid (or eliminate, when refactoring) duplicated code and information, including solid framework design (which I have focused on thus far) and using generated code (which I haven’t delved into very much). Regardless of which path you take: don’t duplicate code, and don’t duplicate information.  Duplication is evil.

 

Further reading:

Rule three [wikipedia]

Single source of truth [wikipedia]

Don’t Repeat Yourself [wikipedia]

Separation of concerns [wikipedia]

Posted in Coding, News | Tagged | Leave a comment

PHP Best Practices: Introduction

 

I started programming when I was about 12, did so continuously until I was 18, took a couple years off to be a kid again, and recently started programming again seriously (in professional, production, multiple-developer environments).

I have a lot of standards and ideals with programming, but there are also a lot of gaps. This “best practices” series will be my attempt to explain every facet of my programming philosophy, and hopefully start a conversation.

I think this conversation is necessary because most code we see on a daily basis is bad – real bad. It’s bloated and slow when it works at all. It’s brittle and doesn’t like to change. It probably took forever to get the initial product, but it probably needs a LOT of work – and that’s unfortunate since it’s so difficult to change.

I will probably talk a lot about unit testing and MVC. The reason you should read more is because I don’t like the way those are done now, at all; I think we can do better. The reason I want you to read more is because I know you, as a programmer, are uncomfortable with a lot of what you do. There should be a better way to do things, and I intend to discover it – with your help.

 

So, before I write my next post, a note : any methods I come up with should be general enough to port to other languages. PHP is what I’m most familiar with, but I don’t intend to be exclusive.

 

Thanks for reading.

 

Posted in Coding, News | Leave a comment

Fancy command-line alarm for Mac OS X

I have a Calc exam in the morning. Instead of studying for it, I decided to program a command-line alarm for myself so I don’t sleep through the exam. It doesn’t help that my phone is MIA and I’ve never owned a regular alarm clock.

Here:


#!/bin/bash
osascript -e 'tell app "iTunes" to pause' > /dev/null
osascript -e "set Volume 3"
say "Wake up, Josh. Time to get out of bed. You have an exam to take."
sleep 5
osascript -e "set Volume 0.5"
osascript -e 'tell app "iTunes" to play playlist "morning music"' > /dev/null
sleep 5
osascript -e "set Volume 1"
sleep 5
osascript -e "set Volume 1.5"
sleep 5
osascript -e "set Volume 2"
sleep 5
osascript -e "set Volume 2.5"
sleep 5
osascript -e "set Volume 3"

Save it in your ~/bin folder, reference it from your crontab, set up a “Morning music” playlist in iTunes and customize the wakeup message. Also, the tiered volume is fun but really janky.

And my crontab, IN CASE YOU WONDERED:


0 8 * * mon,tue,wed,thu,fri ~/bin/alarm.sh > /dev/null
30 8 * * mon,tue,wed,thu,fri ~/bin/alarm.sh > /dev/null
0 9 * * sat,sun ~/bin/alarm.sh > /dev/null
30 9 * * sat,sun ~/bin/alarm.sh > /dev/null

A snooze feature would be nice, but that can wait.

Posted in Coding, News, Personal | Leave a comment