29
Nov 12

MongoDB capped collection fun facts

Today I was testing MongoDB capped collections for viability as a fast-access key/value store. My go-to solution for that is usually Redis, but this is for a project that is already using MongoDB and I didn’t want to introduce a separate dependency.

As with Redis, we ended up going with TTLs for this instead, but here are some things I found out about capped collections:

MongoDB capped collections don’t use _id to determine insertion order.

As you may know, the first 8 bytes of each document’s ObjectId is a hexadecimal Unix timestamp. I didn’t know if MongoDB used this to determine insertion order.

In other words, if I use my own custom _id to achieve constant time lookups based on some key that’s meaningful to me (say, a SHA-1 hash), will MongoDB get confused about which documents are the oldest and therefore should be removed first?

Turns out that MongoDB apparently keeps internal timestamp information for capped collections, because the custom _id makes no difference.

The `size` parameter is in bytes, not documents.

Obvious, perhaps–it’s in the documentation–but worth mentioning.

The minimum capped collection size is 4096.

See this issue. If the size is specified less than 4096, it will silently round up.

Like this post? You might also like Coalmine, my centralized error tracking service for your apps. Coalmine captures errors and all kinds of helpful debugging information, notifies you, and makes it all searchable. Check it out!

16
Jun 12

Text Ex Machina

Looking through my server logs, I noticed that when I moved my blog I somehow forgot to update my TextMate theme! Apparently someone likes it, because it’s been mirrored on the TextMate User Submitted Themes page, but I’ve also re-uploaded it here for anyone who’s interested.

Download TextExMachina.tmTheme

theme screenshot

Like this post? You might also like Coalmine, my centralized error tracking service for your apps. Coalmine captures errors and all kinds of helpful debugging information, notifies you, and makes it all searchable. Check it out!

19
May 12

Stop making it so hard for me to give you my money

Shut up and take my money!

I sent the following letter to shinywhitebox’s customer support today after trying to buy iShowU HD. iShowU HD is a terribly-named but genuinely good piece of Mac software. Unfortunately, the experience of buying it almost made me give up in frustration.


 

Dear shinywhitebox,

You guys made it really difficult to give you my money today. I was trying to buy the $69.95 iShowU HD Pro / Stomp bundle, but I couldn’t for about 15 minutes.

Using Safari 5.1.5 for Mac, I registered, then tried PayPal—it went to a sandbox account which I couldn’t log into. I tried my Visa and it was declined (the card is fine and I double checked the info). I tried Kagi but it only has iShowU for sale. Not inspiring a lot of confidence here.

I looked on the Mac App Store but it’s $30 more for both. That’s hard to swallow.

I started the process on the website over again in Chrome, because I had clicked several times on iShowU HD’s Add to Cart button but because of lack of feedback I thought it wasn’t working—instead it kept incrementing the quantity counter on the right, up to 5. Even though I had changed it to 0 and clicked Update before I tried my first purchase attempt, when I tried to start over in Safari the 5 still appeared.

Anyway, there was no record of the user I created. So I created it again (I guess it’s only created on successful payment). This time the card worked, and I was presented with the products I had just purchased.

Well, the names anyway. There were no download links. If I just purchased the software, you should present the download links immediately, even if I can easily find them on the website.

I checked my email and found two duplicate “Your new account details” emails—one from “LocalTestSupport” and another from shinywhitebox Support. The final third email did, in fact, have download links.

In the final email, there was a typo:

Load the app at least once (you’ve done this already right? cos you downloaded them demo … right? :-)

No, I had deleted the demo because I had tried to do the software update before all of this and it failed. It was probably a year old and I chalked it up to something breaking in the interim.

Guys, you make a great app, but you made it so hard for me to get a registered copy of it that I wonder how many potential customers you bounce in the process.

p.s. Your contact form declined my perfectly valid .name email address. If you care about customer feedback, you should make email optional anyway.


Update from Neil Clayton at shinywhitebox: Neil responded to this by email with a detailed reply that covered most of the issues I raised. It looks like I was somehow funneled to the test server, but he was unsure how it happened (and, I assume, will investigate). Besides that, he has:

  • Created a ticket to add download links to his emails.
  • Fixed the typos.
  • Removed the email validation on the contact form.

No word on the price discrepancy of the Mac App Store versus the website, or the different product offering on the Kagi store, but thanks to Neil for taking the time to address some of these concerns.

Like this post? You might also like Coalmine, my centralized error tracking service for your apps. Coalmine captures errors and all kinds of helpful debugging information, notifies you, and makes it all searchable. Check it out!

25
Mar 12

Why I moved on from PHP

Alex Hudson has written a good piece on Zend Framework 2, and why he’s moving on from Zend Framework. I was an active contributor to Zend Framework from 2006 until 2008, and I moved on also.  In fact, I mostly moved on from PHP altogether, in large part directly because of Zend Framework.

I’d like to say it was because of the Java influence which is on its face largely at odds with the language it’s built on—but really, it was because I was tired of PHP and its ecosystem. I was tired of the weak typing (not dynamic typing), inconsistent function names, anything-goes argument orders, the generally poor quality of libraries and open source projects, the community values that led to both, the resulting difficulty in hiring good developers from that community… well, I could go on.

There were counterpoints to most of these arguments, and I made them to others. But eventually the weight of the problems added up, and I wanted options. Zend Framework seemed to be trying to turn PHP into Java, and although I hadn’t yet made a value judgment about Java I knew that wasn’t appropriate for PHP. It’s essentially a glue language like Perl, and the “PHP way” (such as it exists) is about lightweight, quickly-bootstrapped solutions. Otherwise, what is PHP good for?

At best, most developers see PHP as a hammer—not particularly fast or elegant, but it gets the job done.

Zend Framework highlighted these problems for me.  It served as a stark contrast to the quality of other PHP components, but exemplified the schizophrenic direction of PHP as a whole since 5.0 (PHP’s SPL—its Standard PHP Library—is every bit as Java-like as Zend Framework).

I glanced at Symfony and some other projects, but what I really wanted was something that addressed my complaints: strongly-typed, consistent, good libraries and community, etc. Professionally I began writing Java, both with and without frameworks like Spring and GWT. At home I began writing a lot of Ruby, using the MacRuby project to supplement some Cocoa I had already learned using Objective-C. I also played with Rails 2 and Merb.

The Java started off well enough—I was creating the same types of complex multi-tier applications that I did under PHP, but this time backed by static typing and a huge library of components from Spring and Apache. But even after I was up to speed, development was slower. I had always heard how Java was heavy, but now I truly experienced it: Spring, a “lightweight” alternative to Struts, had so much explicit (and, to my mind, pointless) infrastructure setup that I was thoroughly disillusioned with it within six months.

I had already blogged about why I thought writing JavaScript by proxy was a bad idea, but I was questioning all my assumptions and so I decided to explore GWT as well. In the end, my experience was similar to Spring—it was all too slow. In the case of GWT I felt both too far removed from the end result and occasionally too near (when I needed to jump into writing native JavaScript using JSNI). This leaky abstraction was explained as a fundamental design decision, but never sat quite right with me. I knew it was necessary, and that was the problem.

At the same time, I experienced none of these problems with Ruby. During this time of exploration I wrote a variety of things: a parser library for a non-trivial binary file format, some GUI components using MacRuby, a website in Rails 2, and an API in Sinatra. I started looking into Merb, but learned it was merging with Rails and so started becoming familiar with Rails 3 instead.

Contrary to my experience in both PHP and Java, I loved every moment writing Ruby. Like Python, it is both strongly- and dynamically-typed. I found the libraries to be generally high-quality, and when they weren’t, the authors tended to be up-front about that fact. The community, inspired by the Rails philosophy, was constantly pushing the envelope by embracing the latest and greatest, almost to a fault. It had a good community that valued pragmatic solutions.

It’s four years later now and I still love Ruby. It’s not the best solution for everything, so I’ve continued to learn new languages (my latest being Python), but it’s generally my first choice.

I still occasionally write some PHP at work. There’s a lot of sighing involved. Zend Framework has some good components and when appropriate I recommend it as a library. I wish it were more modular.

I wouldn’t recommend the MVC—it’s slow, and it places things in the way of routing that should probably go elsewhere. Zend Framework architect Matthew Weier O’Phinney is a smart guy, but he’s trying to drag the PHP community almost single-handedly toward the PHP-as-Java point of view. Frankly, I don’t think it’s right for the community and I don’t think the community is that interested. I predict Zend Framework 2.0 adoption will be glacial. Most people probably won’t ever bother making the switch.

Like this post? You might also like Coalmine, my centralized error tracking service for your apps. Coalmine captures errors and all kinds of helpful debugging information, notifies you, and makes it all searchable. Check it out!

12
Mar 12

MacFusion on OS X Lion

It looks like the “latest” version of MacFusion and MacFUSE (sarcasm quotes because neither have been updated in a very long time) doesn’t work with OS X Lion 64-bit—at least it didn’t for me. I kept seeing this error in /var/log/system.log:

macfusionAgent[849]: dyld: Library not loaded: /usr/local/lib/libfuse.0.dylib
Referenced from: /Applications/Utilities/Macfusion.app/Contents/PlugIns/sshfs.mfplugin/Contents/Resources/ss
hfs-static

Yeah, that’s because /usr/local/lib/libfuse.0.dylib doesn’t exist. This site pointed me in the right direction, though. Install this version of MacFUSE and all will be well:

http://www.tuxera.com/mac/macfuse-core-10.5-2.1.9.dmg

Any superior alternatives to MacFusion someone can point me to?

Like this post? You might also like Coalmine, my centralized error tracking service for your apps. Coalmine captures errors and all kinds of helpful debugging information, notifies you, and makes it all searchable. Check it out!