Posts

Showing posts from 2011

UIView: Notification for view loaded

Depending on what kind of actions you need to perform, there are several techniques: -(id)initWithFrame:(CGRect)frame - UIView's designated initializer; always sent to a UIView to initialize it, unless the view is loaded from a nib;-(id)initWithCoder:(NSCoder *)coder - always sent to initialize a UIView whenever the view is loaded from a nib;-(void)awakeFromNib - sent after all the objects in the nib are initialized and connected; applicable only if you load the object from a nib; you must call super;-(void)willMoveToSuperview:(UIView *)newSuperview - sent immediately before the view is added as a subview to another view; newSuperview may be nil when you remove the view from its superview;-(void)willMoveToWindow:(UIWindow *)newWindow - sent immediately before the view (or its superview) is added to a window; newWindow may be nil when you remove the view from a window;

iOS anti-piracy

NSBundle *bundle = [NSBundle mainBundle]; NSDictionary *info = [bundle infoDictionary]; if ([info objectForKey: @"SignerIdentity"] != nil) { /* do something */ }

Add Font to iOS

http://tetontech.wordpress.com/2010/09/03/using-custom-fonts-in-your-ios-application/


1) Add the .TTF or .OTF font file/s you wish to use as a resource

2) Open your info.plist and create a new key called UIAppFonts or "Fonts provided by application"
, set the key to be an array type.

3) For each font you want to use in your app, add it as a new object in the array with its full name and extension and save the info.plist when finished

4) Now in your code you can simply call

[UIFont fontWithName:@"Insert font name here" size:18]

iOS Icons

Universal apps icon requirements. Image Size (px) File Name Used For Required Status 512x512 iTunesArtwork Ad Hoc iTunes Optional but recommended 114x114 Icon@2x.png Home screen for iPhone 4 High Resolution
Optional but recommended 72x72
Icon-72.png
Home screen for iPad compatibilityOptional but recommended 58x58 Icon-Small@2x.png

VIM Guide

Design Secrets for engineers

mysqld will not start-problem with /tmp/mysql.sock

My solution to the [ERROR] Can't start server : Bind on unix socket: Permission denied
problem was to change ownership of the directories:
/usr/local/var/run/mysqld
/usr/local/var/db/mysql

sudo chown -R _mysql /usr/local/var/run/mysqld

via:http://bugs.mysql.com/bug.php?id=11380

SSH tips

python 2.6 on debian lenny

Source: http://mindref.blogspot.com/2010/04/python-26-on-debian.html

Debian 5.0 comes with Python 2.5 since there is no newer version available in stable repository yet. So the question becomes how you can install a newer Python on your box. Usual way is to update from sid repository and install python version you need... but it doesn't work that way, unfortunately. You will see the following error:
pycentral rtinstall: installed runtime python2.6 not foundThe only way to get rid of this error is by removing older version of python (please note that updating python 2.5 to latest version will not work).
apt-get remove python2.5-minimal python2.5rm -Rf /usr/bin/python /usr/bin/python2.5 /usr/lib/python2.4 /usr/lib/python2.5 /etc/python2.5add sid repository, e.g. deb http://ftp.us.debian.org/debian/ sid main, to/etc/apt/sources.listapt-get -y updateapt-get -y install python python-setuptools python-virtualenvcomment out sid repository in /etc/apt/sources.listapt-get -y updateln -s /usr…

Setting up Python, Pip, Virtual Env, Xcode on Mac

http://jessenoller.com/2009/03/16/so-you-want-to-use-python-on-the-mac/

Python with Xcode:

I figured it out! The steps look lengthy but it's not that bad at all. Open Xcode 4.In the menu bar, click "File" -> "New" -> "New Project…".Select "Other" under "Mac OS X".Select "External Build System" and click "Next".Enter the product name.For the "Build Tool" field, type in "/usr/local/bin/python3" for Python 3 or "/usr/bin/python" for Python 2 without the quotes and then click "Next".Choose where to save it and click "Create".In the menu bar, click "File" -> "New" -> "New File…".Select "Other" under "Mac OS X".Select "Empty" and click "Next".Navigate to the project folder (it will not work, otherwise), enter the name of the Python file (include the ".py" extension), and click &qu…

Adding block callbacks to the Facebook iOS SDK

Adhoc build with Xcode 4

Tools for Server End apps

UILabel size depending on the amount of text

-(float)getHeightByWidth:(NSString*)myString:(UIFont*)mySize

UIColor Macros

http://iphonedevelopertips.com/cocoa/uicolor-macros.html


 #define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
 #define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

// Code without the macro msgLabel.textColor =[UIColor colorWithRed:255/255.0 green:251/255.0 blue:204/255.0 alpha:1];   // Or like this... msgLabel.textColor =[UIColor colorWithRed:1.0 green:.98 blue:.8 alpha:1];   // Code with macro msgLabel.textColor = RGB(255, 251, 204);