Nick Carroll

Metabolising caffeine into code

Fast NTLM authentication proxy with tunneling

without comments

If you are using Linux behind a corporate firewall that only supports Windows, and the Windows proxy authentication is causing you pain, then I suggest installing and using CNTLM.

The problem I was experiencing behind my corporate firewall is that I need to authenticate using the windows domain prepended to my username. It seems that you are not able to have a backslash in your username when setting your http_proxy environment variable using the below format.

http://username:password@host:port/

In other words I was getting strange errors when using the following in my .bash_profile.

export http_proxy=http://domain\username:password@host.com/.

You can’t escape the backslash, nor wrap everything in quotes etc. The only solution I came across was to use an NTLM authentication proxy such as CNTLM, which is a fast NTLM authentication proxy written in C. The Ubuntu package is described as follows.

Cntlm is a fast and efficient NTLM proxy, with support for TCP/IP tunneling,
authenticated connection caching, ACLs, proper daemon logging and behaviour
and much more. It has up to ten times faster responses than similar NTLM
proxies, while using by orders or magnitude less RAM and CPU. Manual page
contains detailed information.

It can be installed using the command, but you’ll need to do this when you are connected directly to the internet, and thus bypassing your corporate proxy!

sudo apt-get install cntlm

You will then need to configure CNTLM by modifying the config file at /etc/cntlm.conf. You’ll need to specify your windows domain login credentials in the config file.

Once configured, restart CNTLM using the command:

sudo /etc/init.d/cntlm restart

Once CNTLM has been configured and restarted, you can then update your http_proxy settings to use http://localhost:3128, or whatever port number you used in the CNTLM config file. By default CNTLM listens on port 3128. Now you will be able to use apt-get, but this time behind your corporate proxy.

Written by Nick

September 1st, 2011 at 2:18 pm

Posted in Random

Estimation Deck is now available in the App Store

without comments

Estimation Deck is now back in the App Store. Estimation Deck saves you from carrying around a deck of cards for your next Agile estimation session.

estimation-deck-512 IMG_0259 IMG_0260 IMG_0263 IMG_0262 IMG_0261

Estimation Deck provides a set of fibonacci numbers that can be used during an Agile estimation session. This application allows the Agile professional to swipe through the deck of cards until the desired estimate is found for the proposed story. Tapping on the estimate card will flip the card to hide your estimate from your colleagues. Tapping the back of the card will flip the card again to reveal your estimate to the group.

Use the settings to switch between Fibonacci, t-shirt sizes, and powers of 2 decks.

Find out more about Estimation Deck

Written by Nick

June 16th, 2011 at 8:51 pm

Posted in Programming

Tagged with , , ,

Checkbox is now available in the App Store

without comments

Checkbox has been unleashed upon the masses and is now ready for sale in the App Store.

icon-appstore Screenshot 2011.01.06 15.25.42 Screenshot 2011.01.06 15.26.48 Screenshot 2011.01.06 15.28.51

Checkbox allows you to take a photo of your task list, add checkboxes to the photo, and track the tasks that you have completed.

Use Checkbox to quickly capture your shopping list on your fridge, the meeting actions jotted on your notebook, or the menu of your favourite restaurant. Then turn the photo into a checklist by adding checkboxes to items in the photo that you want to track. Simply tap on the checkboxes to keep track of tasks that you have previously completed.

Find out more about Checkbox

Written by Nick

May 29th, 2011 at 10:35 am

Posted in Programming

Tagged with , ,

Persisting managed objects with scalar attributes

without comments

Core Data natively supports attributes that are of type NSString, NSNumber, or NSData. You can however use other types with a bit of extra work. If you have an attribute that is a scalar value such as BOOL, you can have your managed object persist it by first converting it to a NSNumber. For example, CheckBox is a NSManagedObject with an attribute called checked that is of type BOOL. BOOL in Objective-C can easily be converted to and from a NSNumber.

The header file contains the BOOL attribute for CheckBox.

// CheckBox.h
#import 

@interface CheckBox : NSManagedObject {
}
@property(nonatomic) BOOL checked;

@end

The implementation file contains a PrimitiveAccessors category for the underlying primitiveChecked value, which stores the checked value as a NSNumber. We then override the accessors and mutators for the checked attribute to convert the BOOL value to and from a NSNumber.

// CheckBox.m
#import "CheckBox.h"

@interface CheckBox (PrimitiveAccessors)
@property (nonatomic, retain) NSNumber *primitiveChecked;
@end

@implementation CheckBox

- (BOOL)checked {
    [self willAccessValueForKey:@"checked"];
    BOOL isChecked = [[self primitiveChecked] boolValue];
    [self didAccessValueForKey:@"checked"];
    return isChecked;
}

- (void)setChecked:(BOOL)isChecked {
    [self willChangeValueForKey:@"checked"];
    [self setPrimitiveChecked:[NSNumber numberWithBool:isChecked]];
    [self didChangeValueForKey:@"checked"];
}

@end

Written by Nick

October 30th, 2010 at 9:54 pm

Posted in Programming

Tagged with ,

Gradle Android Plugin

with one comment

I have recently joined a newly formed team developing Android applications at a large telco, and I am pleased to announce that we are using Gradle for our builds. We are using Gradle with the Android plugin, and instantly we managed to build a simple application, run tests, and have it installed on a device. Our build script simply looks like the following, which is all that is necessary to use the Android plugin.

buildscript {
  repositories {
    mavenRepo(urls: 'http://jvoegele.com/maven2/')
  }
  dependencies {
    classpath 'com.jvoegele.gradle.plugins:android-plugin:0.8'
  }
}
usePlugin com.jvoegele.gradle.plugins.android.AndroidPlugin

Of course this is a rather simplistic script, but it does everything I need it to do right out of the box. The Android plugin provides a number of tasks that allow you to build, test, package and sign your application. You can even install the packaged application on a device or emulator by running gradle androidInstall. Make sure to set the property “adb.device.arg” to “-e” for a running emulator or “-d” for a connected device.

There is also support in Hudson to trigger a Gradle script. Hudson has a Gradle plugin that can be installed from the Admin console, and allows you to directly trigger a Gradle script in your project. Otherwise you can create a simple shell script to call the Gradle tool from the command line.

It is also worth noting that both IntelliJ and Eclipse provide support for Gradle and the Groovy syntax. That is if you don’t like using the command line to trigger your builds.

Gradle has allowed us to spend less time setting up our build and continuous integration environment, and more time on actual Android development. Our team has benefited greatly from this boost in productivity.

Written by Nick

April 26th, 2010 at 5:30 pm

Posted in Programming

Tagged with ,

Illuminate

without comments

My latest iPhone app called Illuminate is now available at Apple’s App store: http://bit.ly/bByrgy.

Illuminate is a free application that turns your iPhone’s screen into a light source. I generally use it when trying to read a menu at a dimly lit restaurant. Hopefully you will find it useful too!

Illuminate screenshot

Written by Nick

March 25th, 2010 at 3:41 pm

Posted in Programming

Tagged with ,

Putting spammers to work

without comments

I am just getting way too many spam comments on my blog lately. Akismet isn’t doing a good job of identifying these comments as spam as they generally appear to be genuine comments. Except that the author and website are for a specific product or company looking to increase their Google Page Rank. I don’t really want to disable the link to a legitimate author’s website or blog, so I have decided to make the spammers do some work. I have installed the reCAPTCHA plugin which will make all comment authors type in a couple of words located on a reCAPTCHA image. This not only limits spam, but Google uses reCAPTCHA to help in their effort to digitise books.

Written by Nick

March 18th, 2010 at 2:29 pm

Posted in Random

One click deployment with Maven and Bamboo

without comments

A while back I wrote about achieving continuous deployment with one-click deployments. I didn’t provide an example for that post as I mostly wrote about why you need to achieve continuous deployment. Here I will follow up with a simple example of how you can achieve continuous deployment.

Continuous deployment is quite easy to setup if you are using a typical Maven project structure and Bamboo as your continuous integration tool. Also I am assuming that you want to deploy your application to a tomcat server.

In your pom.xml file add the following configuration so that you use the Tomcat plugin for deploying your application to http://hostname.com/app. Change the path, url, and server configurations to suit your needs.


    


                org.codehaus.mojo
                tomcat-maven-plugin
                
/app
                    http://hostname.com/manager
                    deployment.server
                
            
        
    

Also make sure that your .m2/settings.xml file contains the following for authenticating with the Tomcat manager.


  
    
      deployment.server
      tomcat
password
    
  

In Bamboo create a new pan for your project. I tend to give this plan the name “Promote to Production”. Configure the Builder goal for Maven to run clean tomcat:redeploy. I also only allow a specific user to trigger this plan so that not everyone has permission to deploy into production. Finally, configure the build strategy to run manually, so an authorised person can click on the Build plan button in Bamboo to deploy the application.

Once set up the above instructions will allow an authorised person in Bamboo to click on a single button to deploy into production. Leveraging your continuous integration tool for deployment allows you to archive deployment artifacts such as your WAR files in the case where you have to revert to a previous version.

Written by Nick

February 26th, 2010 at 1:00 pm

Posted in Programming

Tagged with

Deploying Maven modules

without comments

My most recent consulting gig brought me back into contact again with Maven. I have this love-hate relationship with Maven. I love using Maven for simple projects, that generally have only a development environment, and I hate using Maven for more complex projects where you have to create profiles for multiple testing environments. Maven is just too restrictive for the latter case.

If you have your own internal Maven repository setup and you want to deploy reusable modules to it then follow these instructions. It took me a while to figure them out as there is something wrong with Wagon’s internal ssh implementation. Using an external scp tool will save you a lot of grief.

1. Setup your local .m2/settings.xml as follows:


  
    
      internal.maven.repos
      maven
location of your ssh private key
  
  

You’ll need to create an ssh key. And provide a reference to your private key using the element. This is simple to do in OS X, or linux, and can be done by running ssh-keygen. If you use Windoze then you’ll have to use Putty.

2. Log into your server hosting your maven repository and add the contents of your public key (id_rsa.pub) at the bottom of the authorized_keys2 file. You should create a generic maven user that everyone on your team can log into, this is because when you deploy your module it will be written to the filesystem with read/write permissions only for that user. Exit your server.

3. Go to your project and add the following to your project’s pom.



        
            internal.maven.repos
            Internal Maven Repository
            scpexe://maven@hostname.com/home/maven/.m2/repository
        
    
...
  
        
            
                org.apache.maven.wagon
                wagon-ssh-external
                1.0-beta-2
            
        
    

4. Run mvn deploy.

5. You should now see your project deployed to the maven repository on your server.

Written by Nick

February 26th, 2010 at 12:36 pm

Posted in Programming

Tagged with

Cloning a Java object

without comments

Here is a simple and effective approach to cloning objects in Java using XStream. The process uses XStream to serialize your object to XML, and then using the XML to create a new Java object that is a deep copy of the original.

Sheep dolly = new Sheep("Dolly");
XStream xstream = new XStream();
String xml = xstream.toXML(dolly);
Sheep newDolly = (Sheep)xstream.fromXML(xml);

Written by Nick

January 15th, 2010 at 12:09 pm

Posted in Programming

Tagged with ,