Disable arc in Xcode

  1. Select your project configuration
  2. Go to the "Build Settings" tab
  3. Search for "automatic"
  4. Click the "Objective-C Automatic Reference Counting" line and choose "No"
  5. Done
Tagged ,

Change hostname in Mac OSX

sudo scutil --set HostName yourHostname.local
Tagged ,

Uninstall XCode and OSX Developer Tools

Open the Terminal.app and execute the following command:

sudo /Developer/Library/uninstall-devtools –mode=all
Tagged , ,

Disable standby mode in iOS

To prevent the iPhone to enter the sleep mode after a certain time, just add the following line:

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Tagged ,

UIViewController initialization

UIViewController is loaded from NIB:

- (id)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];    
    if (self) {
        <YOUR INSTRUCTIONS>
    }
    return self;
}

- (void)awakeFromNib {
    <ADDITIONAL INSTRUCTIONS AFTER NIB IS LOADED>
}

UIViewController is created programmatically:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        <YOUR INSTRUCTIONS>
    }
    return self;
}
Tagged ,

SVN merge without mergeinfo

If you are about to merge a branch back into trunk and experience the following error, you are using svn 1.4 or your admin forgot to update your repository.

svn merge --reintegrate http://svn/calc/branches/my-calc-branch

Querying mergeinfo requires version 3 of the FSFS filesystem schema;

In this case you could use:

svn merge http://svn/calc/trunk@X http://svn/calc/branches/my-calc-branch

or

svn merge -r X:HEAD http://svn/calc/branches/my-calc-branch

where X is either the revision you created your branch from or the revision you last merged into your branch.

Tagged

Prevent reload of android webview on orientation change

Just add this attribute to your activity:

<activity android:configChanges="keyboardHidden|orientation"...
Tagged ,

Enable MySQL query log on Mac OSX

  1. Create my.cnf:

    $ sudo vim /etc/my.cnf
    
  2. Add this to my.cnf:

    [server]
    log=/private/var/log/mysql_query.log
    
  3. Create log file:

    $ sudo touch /var/log/mysql-query.log
    $ sudo chown _mysql /var/log/mysql-query.log
    
  4. Restart MySQL through MySQL Preference Pane.

Tagged ,

Django with bpython shell on Mac OSX/Linux

  1. Add this line to your .profile:

    export PYTHONSTARTUP=~/.pythonrc.py
    
  2. Download .pythonrc.py and copy it to your home directory:

    #.pythonrc
    try:
        from django.core.management import setup_environ
        import settings
        setup_environ(settings)
    
        from django.db.models.loading import get_models, get_apps
    
        for app in get_apps():
            app_models = get_models(app)
            if not app_models:
                continue
            model_labels = ", ".join([model.__name__ for model in app_models])        
            try:
                exec("from %s import *" % app.__name__)
                print "From '%s' autoload: %s" % (app.__name__.split('.')[-2], model_labels)
            except:
                print "Not imported for '%s'" % app.__name__.split('.')[-2]
    except:
        pass
    
  3. Close current terminal and open a new one.

  4. Change to your django project directory an start bpython. If everthing went fine you should see a list of your imported models:

    ...
    From 'auth' autoload: Permission, Group, User, Message
    From 'contenttypes' autoload: ContentType
    From 'sessions' autoload: Session
    From 'sites' autoload: Site
    ...
    
Tagged , ,