Ubuntu 11.10: setting up Apache2 and SSL with self-signed certificate

Create a self-signed certificate:

$ make-ssl-cert generate-default-snakeoil --force-overwrite

It creates the following files:

  • /etc/ssl/private/ssl-cert-snakeoil.key
  • /etc/ssl/certs/ssl-cert-snakeoil.pem

Activate Apache SSL module:

$ a2enmod ssl

Activate Apache default ssl virtual host:

$ a2ensite default-ssl

Restart Apache:

/etc/init.d/apache2 restart

You should now see the following page on your webserver:

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

How I upgraded my iPhone 3GS from 3.x to 4.x

When I tried to upgrade my phone 3GS 3.x to a 4.x firmware found on osxdaily.com, I got the famous “this device isn’t eligible for the requested build”.

My jailbroken device was on a 3.1.3 firmware with Cydia installed. After trying different 4.x firmwares, I googled this error message and found an interesting thread here.

I followed their advice and it worked:

  • Install TinyUmbrella,
  • Clicked on my device,
  • went to Advanced tab and unchecked “Request SHSH from Cydia”,
  • Started TSS Server,
  • Entered Recovery,
  • and finally in iTunes clicked on Restore (with option key) and selected a 4.1 firmware,
  • done!
I can now test my apps on a 4.x device.

Learn iOS Application Development with Stanford

The new Fall 2011 courses from Stanford on iTunes U are available!

Courses by Paul Hegardy released with a Creative Commons BY-NC-ND license in full HD.

7 courses are available:

  • MVC and Introduction to Objective-C
  • My first iOS App
  • Objective-C
  • Views
  • Protocols and Gestures
  • Multiple MVCs and Segues
  • iPad Apps

Debugging EXC_BAD_ACCESS

A helpful article explaining how to use gdb to debug EXC_BAD_ACCESS:

Also, if you don’t know about NSZombieEnabled you should read the following articles:

iOS device and OS version

If you are interested in device class and OS version statistics, I’ve compiled a list of recent articles:

Install DataMapper MySQL adapter on Mac OS X (10.6.6)

I’ve just installed MySQL 5 from mysql-5.5.9-osx10.6-x86_64.dmg package, see MySQL download website or mirrors.
This package installs MySQL in /usr/local/mysql (symlink to mysql-5.5.9-osx10.6-x86_64).
When I wanted to install DataMapper MySQL driver, I ran into the following error:

$ sudo gem install dm-mysql-adapter --no-rdoc --no-ri
Fetching: data_objects-0.10.3.gem (100%)
Fetching: do_mysql-0.10.3.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing dm-mysql-adapter:
	ERROR: Failed to build gem native extension.
/opt/ruby-1.9.1/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
[...]

This means while compiling the extension, compiler can’t find mysql librairies. It’s because they haven’t been installed in standard include folders. They actually are in /usr/local/mysql.
To indicate to the compilation process to check this folder you need to add the following parameter to the command line:

$ sudo gem install dm-mysql-adapter --no-rdoc --no-ri -- --with-mysql-dir=/usr/local/mysql/

Building native extensions.  This could take a while...
Fetching: dm-do-adapter-1.0.2.gem (100%)
Fetching: dm-mysql-adapter-1.0.2.gem (100%)
Successfully installed do_mysql-0.10.3
Successfully installed dm-do-adapter-1.0.2
Successfully installed dm-mysql-adapter-1.0.2
3 gems installed

You’re done!

Editorial Calendar WordPress plugin

WordPress doesn’t make it easy to see when your posts are scheduled.

That’s exactly what I was thinking!

Browsing WordPress Plugin Directory, I found Editorial Calendar.

This plugin shows you all your posts through a calendar view instead of the classic list view:

You can also manage your posts, drag and drop between dates, etc… A must have when you schedule your posts.

CSSMERR_TP_NOT_TRUSTED with Xcode

After switching to a new MacBook (and copying everything through Firewire cable), I couldn’t compile any app on my iPhone.

Compilation was always ending up with the following message:

/.../build/Debug-iphoneos/xxxxxx.app: CSSMERR_TP_NOT_TRUSTED
Command /usr/bin/codesign failed with exit code 1

I checked my provisioning profiles, certificates and everything and couldn’t find a solution.

Finally, while browsing the iOS Provisioning Portal, I read this under my Development Certificate:

*If you do not have the WWDR intermediate certificate installed, click here to download now.


I downloaded this certificate and added it to Keychain Access:

I compiled my app again and it worked!

I don’t know why this certificate disappeared during my MacBook migration…

Xcode tips and tricks

Starting or not Mac OS X / iOS development, it’s worth reading articles to find tips that suits you.

Tint UIButton and UIBarButtonItem

Edit 2011-11-04

Since iOS 5.0, UIButton and UIBarButtonItem have a tintColor property.

 

You may have noticed that the tint property is not available for UIButton and UIBarButtonItem.

Two common techniques to change the color, you can find around are drawing button with CoreGraphic or using a stretchable UIImage.

Lately, I found a new technique based on UISegmentedControl which you can use the tint property to change the color of your button. This control can be tweaked to have only one segment with a UIButton style (UISegmentedControlStyleBar).

A standard UISegmentedControl

Tweaking the control

We will now create a UISegmentedControl with one segment and set its tint color:

UISegmentedControl *button = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Add", nil]] autorelease];
button.frame = CGRectMake(0, 0, 160, 33);
button.center = self.view.center;
button.momentary = YES;
button.segmentedControlStyle = UISegmentedControlStyleBar;
button.tintColor = UIColorFromRGB(0x0000DD);
[self.view addSubview:button];

Compile your code, your button will look like the following screenshot:

Refer to the UISegmentedControl class reference for a detailled explanation of its properties.

I used a macro in this code to define my tint color. Macro definition is:

#define UIColorFromRGB(rgbValue) [UIColor \
  colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
  green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
  blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

You can read more about defining macro or function here and here.

In a toolbar

You can also use this technique to tint UIBarButtonItem used in UIToolBar.

UIToolbar *toolbar = [[[UIToolbar alloc] init] autorelease];
toolbar.barStyle = UIBarStyleDefault;
[toolbar sizeToFit];
toolbar.frame = CGRectMake(0, self.view.frame.size.height-44, self.view.frame.size.width, 44);
[self.view addSubview:toolbar];

/* Create our tinted buttons */
UISegmentedControl *button = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Add", nil]] autorelease];
button.momentary = YES;
button.segmentedControlStyle = UISegmentedControlStyleBar;
button.tintColor = UIColorFromRGB(0x0d9c23);

UIBarButtonItem *barButton = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
UISegmentedControl *button2 = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Delete", nil]] autorelease];
button2.momentary = YES;
button2.segmentedControlStyle = UISegmentedControlStyleBar;
button2.tintColor = UIColorFromRGB(0xC84131);
UIBarButtonItem *barButton2 = [[[UIBarButtonItem alloc] initWithCustomView:button2] autorelease];

[toolbar setItems:[NSArray arrayWithObjects: barButton, barButton2, nil]];

You now have a toolbar with 2 tinted buttons that look like that:

Download on GitHub.com

This source code is created and enhanced in my leisure time for free. Your donation allows me to continue my development and any amount is greatly appreciated.