@benguild: The official homepage of Ben Guild.

Fixing AutoLayout on UILabel(s) in iOS Development

15 Jul 2014  |  Tags: ,

AutoLayout is a really quick way to create responsive layouts on iOS 6, 7, and higher / Mac OS(es). However, I found that there's a really stupid problem with UILabel(s) in getting them to act like actual paragraphs that resize themselves to their own contents. They often don't do that properly using just AutoLayout constraints....

Oddly enough, calling “[label sizeToFit]” manually can band-aid the issue, but then hose the rest of your AutoLayout in some instances. — So what's wrong? Isn't AutoLayout supposed to “compress” UILabel(s) to their minimum required size based on their assigned constraints?

iOS AutoLayout UILabel Bug demonstrated (graphically)
As you can see, without this fix the pink-colored label is taller in the same context when the view is loaded on a larger screen.

The tricky thing about UILabel(s) is that they generally will actually resize themselves, but this doesn't always work predictably due to this bug in UIKit. On iPads, you might end up with taller labels… where as on a 3.5-inch iPhone they might look just fine with the display oriented vertically and then grow taller when rotated horizontally.

The easiest solution to this behavior is to subclass UILabel and add this little gem to force the “PreferredMaxLayoutWidth” on the label to reset automatically whenever the view is resized. This makes its width 100% of its container's width (as it most likely should be), and leaves only its height to be adjusted dynamically by whatever the UILabel's content and AutoLayout constraints actually should negotiate between themselves:

- (void)layoutSubviews
{
    [self setPreferredMaxLayoutWidth:[self bounds].size.width];
    [super layoutSubviews];
}

This approach not only keeps your code clean but also keeps the issue isolated. One can now rely almost solely on AutoLayout for controlling text and content variations amongst varying localizations and differing device resolutions or aspect ratios. (… and in the least annoying way possible!)

  Comments  | 

Announcing "Accounts"

18 May 2014  |  Tags: , , , ,

I started this project called Accounts on a plane ride last year… while thinking, “What would a social network that I'd actually want to use look like?” — All in all, it came down to one thing: the lowest common denominator.

Accounts (logo)

[ Download the 1.0.16 beta for iOS… ]

Nowadays, we try new Apps and services constantly, but the “lock-in” of social networks somewhat limits our mobility. Our contacts list on our mobile-devices is more or less our only form of portability, and yet it doesn't provide much interactivity beyond just the traditional contact methods themselves. — No notifications, no seamless updates… you're responsible for your own address book presently, and many of them are in complete disarray.

Enter Accounts. It's currently for iOS, but there are also mobile-web and desktop (then Android) versions coming soon. It detects the Apps on your device, and gives you a list of three things: your services, your contacts, and your contacts' services.

…That's it. (oh, and their basic contact information such as email/telephone)

Account screenshot #1   Account screenshot #2   Account screenshot #5

It keeps this information up-to-date, and serves as a longterm reference. It's time for something like this to exist on all platforms, and remain simple. Forever.

“Won't I be locked into this, as well,” you ask? No, because there's nothing on it. It's just your contacts, and the services that they use. If you want to leave, there's nothing to leave because your content isn't there.

We'll even make it easy to leave by syncing your contacts through our future API interface, for both your own use and other third-party developers' use.

Account screenshot #3   Account screenshot #4

I think that this is a great way to stay connected, because it actually forms a longterm connection with no strings attached. There's no featureset to judge or become bored with, no content to manage, and no complex settings to control. We're not cramming features down your throat, violating your privacy, or making you look at ads in a spammy news feed. It's just you, the people you know, and the services that you both use for getting in touch with them. Accounts updates this information automatically for you, and through the API it can become the “contacts backbone” of the Apps that you'll love in the future. It's a stable and simple ‘base’ product, with powerful tools for developers.

This could eliminate social network lock-in, and provide true contacts and relationship portability. With your interest, I'm building a company around this idea.

Check out the beta App, and stay tuned for updates. http://www.accounts.ms

  Comments  | 

Longterm storage: NAS + HDDs + CrashPlan Unlimited (for ARM devices) vs. costly Amazon Glacier [cost analysis]

17 May 2014  |  Tags: , , , , , , ,

OK, it's not really fair to call Amazon Glacier “costly”. However, it might not be your cheapest option for storing a few terabytes of data for a few years (or more)....

01010100 01101000 01101001 01110011 00100000 01101101 01100101 01100001 01101110 01110011 00100000 01101110 01101111 01110100 01101000 01101001 01101110 01100111 0101110

For large-volume data storage with a target lifespan of 2 years or less, Glacier can be a great option. It costs just $0.01/GB per month at this time of writing. — The costs can definitely add up, though. To store 2TB (2,000GB) it would cost $240/year, and there's no longterm discount currently. While they may drop their prices at some point, the current costs are still too high for most consumers needing to store more than a few hundred gigabytes longterm.

  • If you're storing a few hundred GB, then chances are a NAS is not worth the cost to you.
  • If you're storing a lot more than that, to get the best of both worlds, the best option for this is to get a network-attached storage device (NAS) and back that up to CrashPlan for $60/year unlimited instead of paying Amazon $0.01/GB every month.

A NAS is a box of hard-drives with a lightweight computer embedded to ideally mirror your data across multiple drives (using RAID technology) for redundancy in the event of one or more drives failing. It can run some basic software (such as CrashPlan for offsite backups, or BitTorrent Sync for your own secure Dropbox-like syncing folders), and also, if a drive has a failure, can recreate that drive's data onto a freshly inserted drive using the data already sharded across the other drives that are still operating. Cool, huh?

The case for Glacier

Cost: $0.01/GB per month ($120/year per TB, 1000GB)

If you're storing data for less than 2-3 years, or not very much data at all, then Glacier is probably going to be cheaper. If you're archiving lots of photos, videos, or other large files, you'd most likely want to invest in a NAS and back that up to CrashPlan as your cloud storage option. — If you already own a NAS, then there's no need for Glacier unless your new data is too large for the NAS's existing storage configuration. (but you could also expand that by buying larger drives!)

Amazon Glacier (logo)

It's possible that Amazon Glacier could drop significantly in price in the future. Storage technology keeps getting cheaper and more efficient, and people are already questioning how Glacier is able to operate at such a low cost. Some speculate that they are using the offline cold-storage of optical media (BDXL).

  Read more of the full post »

  Comments  | 

The weekend that I tried to sell three plasma TVs: FOBO, vs. Craigslist, vs. "Fulfilled by Amazon"

10 Feb 2014  |  Tags: , , , , , ,

How best to resell three TVs, whilst also trying to figure out the best way to sell stuff in the future? Watch these services duke it out: it's the ultimate electronics resale showdown!

TL;DR Don't ship TVs! eBay wasn't considered for this reason, but Amazon was due to their heavily discounted rates for inbound warehouse shipments. — FOBO = item sold in under two hours, made $20 less than Craigslist but with least effort, coolest people, best experience for the buyer, Craigslist = took 2 weeks, made an extra $20 over FOBO (lucky), no fees, Fulfilled by Amazon = after 3 weeks it sold for almost 150% more, but the “oversize item” fees actually made it around ~20% less. Read on for more details!

I'd been wanting to try out this new service in San Francisco called FOBO. It's a “quick” auction service for used electronics. They come and pickup your electronics from you if nobody buys them, but otherwise allow nearly anyone to “bid” up the price in a short auction. It's like eBay, but only 97-minutes in duration for each item. You're guaranteed a certain minimum price (which you're presented with upfront), and that's the price that FOBO pays you if nobody bids. They come pick it up from you, so it's definitely gone within 48 hours and you'll get cash directly in your bank account for it.

The three TVs!
For some, there's a long road ahead. But for the lucky ones, a new home is just days away!

Sound good? It is, but it also depends on what you're selling and how quickly you want to sell it. Once, I tried to use FOBO for a Retina MacBook Pro, and they offered me $1350 as their minimum starting price. I felt like I could maybe make a bit more by sending it to Amazon's warehouse. I've written about this before. — I ended up selling it on Amazon for $1579 (= around $1460 net after shipping costs and Amazon's ~9% fees), but it required some extra effort on my part. — It's possible that FOBO users could have bid the laptop's selling price from $1350 to something higher, but within only a 97-minute auction it can be a bit chancy. On top of that, you're also paying a 15% fee, so you have to kind of do the math beforehand. Either way, it's gone the same day, but FOBO settles the transaction much faster vs. waiting for a buyer on Amazon.

FOBO even buys stuff from you for the minimum starting price if nobody else bids, so it's definitely out the door and gone within 48 hours. Nice. — I literally sold the TV on FOBO and bought a Fitbit Force from someone else on there before I even received the box that I purchased from Amazon to ship one of the other two TVs to Amazon's own warehouse. I see why the service is catching on, because there are a lot of sweet deals on it and it's ridiculously convenient by comparison to what other options are available.

FOBO (logo)

As a classic alternative to FOBO and Amazon, there is also “good ol' fashioned” Craigslist. Craigslist offers free, local classifieds that are completely user-regulated and offer no sort of structured negotiation or payment/delivery. This freedom can be both great and terrible at the same time, due to the potential of being scammed or hassled by “no shows” or trolls. The potential to be scammed in all three of these services is the same ranking in which they were mentioned… with FOBO being the lowest potential for a scam, Amazon offering insurance and “customer service” for sellers as well as buyers (including returns), and Craigslist offering virtually no insurance or guarantees what-so-ever.

All three services are very different but ultimately all aim to accomplish the same task: get rid of excess or outdated stuff as quickly, conveniently, and profitably as possible. — Watch me try to sell three near-identical plasma TVs… three different ways! Bring on the TVs!

  Read more of the full post »

  Comments  | 

Flat iOS 7 design: LifeSim game I built for iOS based on "Conway's Game of Life"

24 Nov 2013  |  Tags: , , , ,

During my parents' recent visit to San Francisco, my mother and I checked out the local Exploratorium science museum. I loved some of their interactive visual displays, and decided to build my own rendition of “Conway's Game of Life” for the iPhone/iPad that same night.

LifeSim, based on Conway's Game of Life and built stylishly for the iPhone/iPad and iOS 7

It's a pretty simple game, but has some nice effects and only took me a few hours to code. There's iPad support as mentioned, and it of course bears a stylishly flat “iOS 7” design and icon. Check it out! (it's free)

  Comments  | 

Did you know that you can't undo text edits on Android? Here are 4 other major reasons why I won't switch...

20 Nov 2013  |  Tags: , , , , ,

The Nexus 5! I'd been Android-curious for a while. Aside from losing iMessage access, I was honestly willing to give it a solid “go”. Maybe I could get all of my friends to use Google Hangouts instead? Ha.

I hated the original iPhone. Things like copy-and-paste, lack of tethering, the inability to attach a photo to an email after you'd drafted it, etc. — The simplicity drove me away. I didn't switch back to iOS until the iPhone 4, and had adopted a BlackBerry until then for its then superior communications and ability to do things like tethering, copy-and-paste, and the ability to attach a photo to an email after you'd drafted it. Things like the Retina screen on the iPhone 4 didn't really matter to me at the time, but I quickly began to love the device and appreciate iOS as well thereafter. My main requirement, though, was that I didn't want my phone to get in my way.

Nexus 5, brand-new in box!

The Android OS itself looks great from the pictures. I was excited! And yet, I kept hearing random tidbits from people about how Android “sucks” or how it was a “UX nightmare”. Also, I heard about how nearly every Android phone had a “terrible camera”.

The most uniform complaint was the inconsistent experience across carrier builds and the inconsistent customization by various manufacturers. These parties would apply their own custom software interface “skins” and “bundled Apps” (bloatware) that generally varied from tolerable to terrible. The Nexus 5 avoids all of this by shipping with the latest, vanilla, updatable build of Android… straight from Google with no “bloatware”.

Switching now wasn't the right choice.

Many of the people trash-talking Android have never used it. Many people trash-talking anything have never used the latest version of that something.

Wrong way roadsign

Android is so close, but just not quite there for me. — On paper (or in mind), the Nexus 5 seemed like the ideal phone: simple, discreet looking hardware with vanilla Android and no carrier bloatware! It had the latest Android v4.4 KitKat pre-installed, an integrated Google cloud-based backup services, and the rest of Google's services and email/calendar built-in. Nice!?

  Read more of the full post »

  Comments  | 

Remerging iTunes Match music libraries from multiple computers locally using AppleScript + external drive(s).

04 Nov 2013  |  Tags: , , , , , , , , ,

Solid-state drives have created serious storage constraints on today's portable computers. I originally purchased a 128GB MacBook Air in 2010 with the intention of only using it while in class (at school) and while traveling. When I moved to San Francisco, this machine became my primary computer… although temporarily. Because of its limited storage, I had had to leave behind the majority of my multimedia on my older desktop machine (ie. music collection, photos/videos from travel, etc.), and only recently (this weekend) have I been able to solve this problem.

The temporary bandage for this situation had previously been hosting my entire music collection “in the cloud” using Apple's own iTunes Match service. ($24.99 USD per-year)

iTunes Match completed within iTunes on a Mac

A few months after adopting my MacBook Air as my primary computer in 2012, I was having terrible problems with eye-strain. I'd never had issues like this before! Its tiny 11.6-inch display was causing me to see double after using it for several hours at a time. After visiting two eye doctors with no conclusive explanation, I ended up replacing the computer with a 15.4-inch Retina MacBook Pro based on my own suspicions. The main driver of this purchase was that I'd found that using a Retina iPad was much more comfortable, and I'd hoped that the larger screen on the MacBook Pro (which was also Retina) would help solve this. — Luckily, it did!

This machine was so much faster than my 2006 Mac Pro desktop that I decided to migrate solely to portable machines again. The only problem with this was that the Mac Pro desktop had offered a 2TB RAID of storage, where as my new MacBook Pro only offered 256GB of solid-state storage. — For over a year thereafter, I kept using iTunes Match exclusively for my music because of this. Recently though, Apple revised its MacBook Pro line yet again (this being the “Late 2013” revision), and these updates brought along the option for 1TB of SSD storage! I decided to order this computer, with the plan of reorganizing and clearing out my data thereafter by defragmenting it from so many different external storage solutions.

To alleviate storage constraints on my previous MacBook Pro (256GB SSD), I had already bought an external Drobo storage array and crammed it full of 5 x 1TB hard-drives in a semi-permanent backup archive. On this Drobo, I had put my music collection, raw video footage from the various trips I'd been on, and anything else bulky that I did not need to access very often. I have some backups of the Drobo itself as well, and a live backup of my music “in the cloud” through this iTunes Match service.

While still I plan to leave the bulky video-files stored externally from now on… with this new computer I knew that I could finally “undo” the iTunes Match migration and store all of my music locally again! — And, here's how I did that.

  Read more of the full post »

  Comments  | 

Fulfilled by Amazon: How to get rid of old stuff immediately, sell it for more, and use Amazon as a cheap storage facility

20 Oct 2013  |  Tags: , , , , , , ,

Most people don't know that you can ship stuff to Amazon's warehouse and have them simultaneously store it and offer it up for sale to their customers. Sounds cool, right?

Amazon (logo)

It is. And it's super convenient.

Most people also don't even know where to begin when they're cleaning out their house. Every single small gift that you have ever received, every book that you have ever read that you still own, every power adapter for every small electronic device you ever owned… where does this stuff all end up? Usually: a landfill

Landfill

That's right! Everything you've ever owned is still sitting somewhere unless it was lucky enough to be recycled or incinerated. However, there is a better way to avoid waste or e-waste! Ship it to Amazon.

First of all, it's not as bad as it sounds. I've sold things for way more on Amazon than they were going for on eBay at many times. Previously, I've also blogged about how eBay's fees can be kind of a rip off. — For example, I had a 2006 Apple “Mac Pro” desktop that I could have sold for about $300 USD on eBay, but I instead sold it while traveling for about $900 USD through Amazon's marketplace (after shipping it to them a month prior). All it cost me upfront was about $20 in discounted UPS shipping (which they provide) for its giant, heavy box to reach their warehouse. Post-sale, they even took a smaller commission than eBay would have and I had sold it for 3x the price! The best part is that it got it out of my house immediately and also made it available for same day shipping via Amazon Prime to another customer once it arrived and was processed by their warehouse. This efficiency is the beauty of why you can sell for more using “Fulfilled by Amazon”.

What's the catch? Returns.

So, besides being able to sell stuff for more money because Amazon markets it and ships it the same day to Amazon Prime customers, there is one drawback: people can return stuff.

  Read more of the full post »

  Comments  | 

Peggy (v2), Round 2 for Peggy. A new LED sign: Ignignokt!

03 Oct 2013  |  Tags: , ,

Back in 2008, I built an “Err” sign for a friend using Peggy. Peggy is an electronics hardware kit by Evil Mad Scientist that powers a programmable LED grid. Its most recent “Peggy 2” version is now Arduino-based! For those not familiar, Arduino is an open-source hardware and software prototyping platform bearing a USB interface.

Peggy (version 2) demo cycling through a 2x2 “super-pixel” RGBW setup.

You can do all sorts of cool things with Peggy. Above is a “RGBW super-pixel” setup, which uses red, blue, green, and white LEDs (4 total per super-pixel) to craft a non-primary color in any 2x2 given segment on the grid. My particular project this time was to build some wall art for my new apartment: Ignignokt, the first of the two Mooninites….

A picture of my Ignignokt sign (right), next to one of the original “Err” signs from 2007 (left).

A picture of my now completed Ignignokt sign (right), next to one of the original “Err” signs from 2007 (left).

In early 2007, as a marketing project for the Aqua Teen Hunger Force movie, several of these LED signs were installed in 10 cities (nationwide). However, this promotion literally “bombed” when someone called in a bomb-scare over one of the signs being “suspiciously” mounted to the underside of a highway overpass in Boston, Massachusetts. The signs had already received attention on the internet, but after this event they began to appear on eBay for as much as $5,000 USD.

  Read more of the full post »

  Comments  | 

Get a "Popular Posts" widget for your blog!

19 Sep 2013  |  Tags: , , , , , ,

Nowadays, blogs are primarily hosted on static content-generators in order to serve as many pageviews as possible from as few physical server computers as possible. However, this approach (while more scalable) also prevents dynamic content from being generated on-the-fly by the server computer that's serving it. Things like hit counters, guestbooks, and live commenting at one point often relied on this layer to support their dynamic properties.

One particularly tricky feature to implement nowadays is a “popular posts” list for a blog that updates automatically and displays what is being read the most on your site. — Many big news sites now feature this, yet adding this feature to a smaller site may not seem as being worth the added technical complexity. Having it operate and update on a “static” website presents a small challenge, as this requires some sort of backend service.

Screenshot of the Popular Posts widget homepage

To solve this, I decided to build this simple online service called “Popular Posts over the last few days. I'm selling lifetime access to it for blogs and simple websites. Nothing else like it currently exists, and it works by simply funneling select data from your Google Analytics profile (free to setup) to offer an embeddable widget that updates automatically and will display a formatted list of the most popular pages on your site. It's supported by Jekyll, Blogger, Wordpress, Tumblr, and other platforms, too!

There are even several customization options for things such as removing a common prefix or suffix from each page's title when it's displayed, and the ability to display dynamic pageview counts in the list, for example.

The end result is a simple, Google-hosted, JavaScript-embeddable plugin for your blog or website that works just the way you'd expect it to. And it's cheap! — If you're a blogger, try it out!

  Comments  |