Get your Apple device model name in a readable format

August 1, 2011 – 13:36 Share on Twitter

With OSX Lion, when you select “About this Mac” => “More Info” (or open the System Profiler), it displays your computer model name in a readable format.

About This Mac

After a little snooping with HTTPScoop, I found that the name comes from an Apple server.

System profiler will send the last 3 characters of your machine serial number and the server will send back the machine name, in xml format.

My iMac serial ends with “5RU” so calling the url below and passing “5RU” as a parameter:

curl -o - "http://support-sp.apple.com/sp/product?cc=5RU&lang=en_US"

gives:

<?xml version="1.0" encoding="utf-8" ?>
<root>
<name>CPU Name</name>
<configCode>iMac (27-inch, Late 2009)</configCode>
<locale>en_US</locale>
</root>


Changing the locale works:

curl -o - "http://support-sp.apple.com/sp/product?cc=5RU&lang=fr_CH"

gives:

<?xml version="1.0" encoding="utf-8" ?>
<root>
<name>CPU Name</name>
<configCode>iMac (27 pouces, fin 2009)</configCode>
<locale>fr_FR</locale>
</root>


It works also with the iPhone:

curl -o - "http://support-sp.apple.com/sp/product?cc=A4S&lang=en_US"

gives:

<?xml version="1.0" encoding="utf-8" ?>
<root>
<name>CPU Name</name>
<configCode>iPhone 4</configCode>
<locale>en_US</locale>
</root>

Enjoy.


It’s not my fault

February 1, 2011 – 21:44 Share on Twitter

Bugs are always your fault. Actual bugs in the framework accounts for an infinitesimal percentage of bugs, and even if there is a bug in there, you’re the one who pissed it off.

Mike Lee, aka @bmf

So many times I’ve heard people say: “it’s not my fault, it’s a bug in the framework/OS/firmware/WTFware”.

Do what you’re paid for. Make it work.

Read the complete post here: Layers + Ruler = Swearing


APNS Resources

March 13, 2010 – 11:43 Share on Twitter

Just a reminder: I keep my list of Apple Push Notification Service Gateways up-to-date.

You can find it on my blog here.


NSConference 2010

February 9, 2010 – 17:51 Share on Twitter

I was in Reading UK last week to attend the NSConference 2010. I will not write a full report of what happened there, because others will do that better.

The only thing I want to say is:if you want to improve your skills in Cocoa, for Mac, iPhone or iPad, you should go: you’ll have the best speakers, the best organization you can dream of. And you will come back with new contacts, new ideas, new code to try.

You can (should) read Alex Repty report here.


Tablet, iSlate, iPad, …

January 26, 2010 – 23:54 Share on Twitter

If, like me, you are tired seeing all these rumors about the absolutely freaking crazy product that Apple MAY announce tomorrow, and you are tired of reading about these rumors on absolutely every website in the world, I have a solution for you.

It’s a GreaseMonkey (and GreaseKit) script that will obliterate all mentions of the words “Tablet”, “iSlate”, “iPad”, “iTablet” and replace them with “Unicorn”, because more people have seen Unicorns than the famous iTablet.
Read the rest…


Extend UIWebView to handle all special links

October 29, 2009 – 23:57 Share on Twitter

Have you ever wanted to add an UIWebView to your application, so you can browse the internets without leaving your application? While it is a trivial task to add an UIWebView to a project, there are some links that an UIWebView will not handle.

These are:

  • mailto
  • YouTube
  • maps.google.com
  • iTunes
  • AppStore

I’ve written a generic BrowserViewController, code available on GitHub here: http://github.com/sburlot/browserviewcontroller which handles all these cases:

mailto links are handled with a MFMail: I tried to handle all variations on the link: “to”, “cc”, “subject” and “body”.

YouTube, Map, iTunes and AppStore links are opened in their respective apps.

You can customise the view and decide if you want a navigation tab bar or not.

The navigation tab bar will add standard web buttons: Back, Forward, Stop, Reload and also a button to send the url of the current page via email, or open it in Safari.

Enjoy!


As Seen On TV

October 6, 2009 – 16:41 Share on Twitter

The swiss TV (TSR) made a portrait of me, for the tech show “Nouvo”. Grab it here while it’s hot: Nouvo, sept. 30 2009


Designing an iPhone Application: tools round up

September 24, 2009 – 11:44 Share on Twitter

There are different schools on how to start the design of an iPhone app. Some will prefer designing on paper (I do), others will use the computer to design their next breath-taking GUI.

So here is a list of some of the tools, template to design your next iPhone application.

Templates:

Specialized Tools

For pen & paper aficionados:

In Pragmatic Thinking and Learning: Refactor Your Wetware, Andy Hunt recommends using pen and paper to use your right brain and free your creative mind. When using a computer, you will concentrate on the details, not the complete user experience.

Another drawback of using a computer: if you show your design to the client, he also will concentrate on the details (“can you change the shade of this red button? It’s TOO red.”). Showing a hand-drawn design will let him imagine how the final product will look. This can be a double-edged sword, so you better know what the customer is expecting before using one of these techniques.


Arbitrary rotation of a CGImage

September 4, 2009 – 11:13 Share on Twitter

For my current project, I have to rotate a CGImageRef by an arbitrary angle.

Here is the code:


- (CGImageRef)CGImageRotatedByAngle:(CGImageRef)imgRef angle:(CGFloat)angle
{
  CGFloat angleInRadians = angle * (M_PI / 180);
  CGFloat width = CGImageGetWidth(imgRef);
  CGFloat height = CGImageGetHeight(imgRef);

  CGRect imgRect = CGRectMake(0, 0, width, height);
  CGAffineTransform transform = CGAffineTransformMakeRotation(angleInRadians);
  CGRect rotatedRect = CGRectApplyAffineTransform(imgRect, transform);

  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
  CGContextRef bmContext = CGBitmapContextCreate(NULL,
                                                 rotatedRect.size.width,
                                                 rotatedRect.size.height,
                                                 8,
                                                 0,
                                                 colorSpace,
                                                 kCGImageAlphaPremultipliedFirst);
  CGContextSetAllowsAntialiasing(bmContext, FALSE);
  CGContextSetInterpolationQuality(bmContext, kCGInterpolationNone);
  CGColorSpaceRelease(colorSpace);
  CGContextTranslateCTM(bmContext,
                        +(rotatedRect.size.width/2),
                        +(rotatedRect.size.height/2));
  CGContextRotateCTM(bmContext, angleInRadians);
  CGContextTranslateCTM(bmContext,
                        -(rotatedRect.size.width/2),
                        -(rotatedRect.size.height/2));
  CGContextDrawImage(bmContext, CGRectMake(0, 0,
                                           rotatedRect.size.width,
                                           rotatedRect.size.height),
                     imgRef);

  CGImageRef rotatedImage = CGBitmapContextCreateImage(bmContext);
  CFRelease(bmContext);
  [(id)rotatedImage autorelease];

  return rotatedImage;
}

Apple Push Notification Service Gateways

August 7, 2009 – 20:32 Share on Twitter

I’ve not yet had the request to implement Push in an iPhone app, but a thread on the Developer Forums gave me a hint:

Some companies are already providing (or planning to provide) a gateway to the APN:

These are:

These are in closed beta:

Urban Airship and iLime also provide In App Purchase.

Or you can build your own: Open Source & Tutorials

I will try to keep this list updated.

Edit: added ApnsPHP & pyapns.org
Edit: separated the active services from the beta, added msgpush.com and C# Library
Edit: added a Rails plugin
Edit: added AppNotify (in Beta)
Edit: AppNotify is no more in Beta.
Edit: Added EasyAPNS source code
Edit: Removed Bigcurl HTTPush, since it’s reserved for bigcurl agency customers
Edit: added a Perl module