May 24, 2012

Singleton Pattern in Objective-C (iOS) and release method (oneway) issue

Posted May 24, 2012
Apple gives a good sample on how to create a singleton class; I've modified it a bit for iOS programming:

static MyGizmoClass *sharedInstance = nil;

+ (MyGizmoClass*) sharedInstance
{
    if (sharedInstance == nil) {
        sharedInstance = [[super allocWithZone:NULL] init];
    }
    return sharedInstance;
}

+ (id)allocWithZone:(NSZone *)zone
{
    return [[self sharedInstance] retain];
}

- (id)copyWithZone:(NSZone *)zone
{
    return self;
}

- (id)retain
{
    return self;
}

- (NSUInteger)retainCount
{
    return NSUIntegerMax;  //denotes an object that cannot be released
}

- (oneway void)release
{
    //do nothing
}

- (id)autorelease
{
    return self;
}


Modifications:
  1. Used "sharedInstance" method and variable name to make it easier to copy paste.
  2. - (void) release to - (oneway void) release
    The singleton sample produces a warning in the release method because NSObject uses the "oneway" return type modifier. It's basically an indication that the method is used for asynchronous messages. For more details on what oneway does, toodarkpark.net offers a good explanation.

May 15, 2012

Grails Session Timeout

Posted May 15, 2012
To increase or decrease the default session time-out in grails:

In your project folder, first execute (if you haven't execute this yet):
grails install-templates

After this, you'll be able to see your web.xml in [project folder]/src/templates/war/

Add / modify the code in web.xml

<session-config>
   <session-timeout>60</session-timeout>
</session-config>

I place the snippet above after my servlet-mapping. The value "60" is in minutes.

Tested on Grails version 2.03. Enjoy!

May 8, 2012

Sublime Text 2 and Command Line Integration

Posted May 8, 2012
A little background: Sublime Text 2 is the ultimate programmer's notepad (Thanks to Lan for introducing me this tool). I've been using it since last year especially when editing Grails applications and so far I'm loving it.

One thing that's lacking out of the box is the shell integration; a way to launch the command line and pass your project's folder path for convenience. Fortunately, there's a package for it. It's called Shell Turtlestein.

  • You can install Shell Turtlestein using Package Control. If you don't have Package Control yet, I highly suggest you install it.
  • When you have the Package Control, access it through Preferences menu > Package Control.
  • Select "Install Package" and search for Shell Turtlestein and select it.
  • After the package is installed, you can use ctrl + alt + shift + C (in Windows) to launch the command line.
  • You can also use ctrl + shift + C to prompt for a shell command.

--
Search Terms:
  • sublime text 2 command line

Apr 19, 2012

Slow CATiledLayer on New iPad 3 Retina display

Posted Apr 19, 2012
Noticed the poor performance of PDF rendering using CATiledLayer on the iPad 3. You can see the tiles loading one by one; it's terrible.

We tried increasing the tile size, we also tried the workaround found in Stackoverflow of setting the contentScaleFactor to no avail. Hope Apple release an update to address this issue. 

Apr 11, 2012

Desktop Clients for Alfresco: Fred vs FlexSpaces

Posted Apr 11, 2012
Why do we need a desktop client when we already have the browser application? Convenience, speed and added productivity.

So far I've seen two mention-worthy desktop clients for Alfresco:
  1. Fred by XeniT (Commercial)



    I've tried it and was extremely pleased with the interface; it's very clean and highly functional. It just works. Sure you can use IMAP, CIFS and Alfresco Office Extension / Addon to get the same features but I especially like the idea of putting those essential features conveniently into one user-friendly application.

    The only downside of this is it's a paid subscription, but for large organizations I believe this is worth it.
  2. FlexSpaces (Free, Open Source)



    What's great about FlexSpaces is that it's a cross-platform software. It can run on Windows, Mac, Linux and even on mobile devices: iPad, Android devices, and BB Playbook. It's free and the license is LGPL.

    A bit of a letdown is the interface, it's not yet polished. Functionality is excellent, but it can get quite confusing at times.

Apr 10, 2012

Switching from Development to Production mode STS + Grails + CloudFoundry

Posted Apr 10, 2012
STS (as of version 2.8), by default, uses development environment when deploying a Grails application to server. Usually you would want to deploy your application in production mode instead to get the best performance.

To do this in STS, go to your project properties and navigate to Grails > Run On Server. Change the value from "dev" to "prod".



Hope this helps. My website has been deployed in Cloud Foundry for more more than a year and only now I've discovered that it's running in development mode!


Source:
http://forum.springsource.org/showthread.php?108405-Deploy-To-Cloud-Foundary-As-Prod&highlight=

Nov 24, 2011

Cloud Foundry and Custom Domain

Posted Nov 24, 2011
Currently, Cloud Foundry (CF) doesn't support mapping of external URL's (See discussion).  The workaround is to use a reverse proxy. For this job, I hosted it Google App Engine (GAE) and used BS2 GAE Reverse Proxy. Credits to yufeiwu for the free reverse proxy app.

Prerequisite:
- Also, please read the Python Tutorial for the development environment and pushing your app to Google server.

Steps:
  1. Download the reverse proxy library (license: LGPL) in http://code.google.com/p/bs2grproxy/
  2. Modify bs2grpconfig.py
    • set TARGET_HOST to your cloud foundry url
      e.g. TARGET_HOST = "mvergel.cloudfoundry.com"
  3. Modify app.yaml
    • set your registered application id
  4. Push the app and make it live

I will continue to use this approach for my website until CF have a proper DNS support.

[UPDATE] Many are encountering a problem with the session using this method. There is a patch that fixes this issue. Thank you Marius Anton for the information.