hit counter

Timeline

My development logbook

Prepare a Maverick Usb

Get a USB flash drive that is at least 8 GBs.

Use Disk Utility to prepare the flash drive:

  • Click on the Erase tab in the DU main window.
  • Set the format type to Mac OS Extended (Journaled.)
  • Click on the Erase button.

You can leave the name of the flash drive at the system default, “Untitled.” Open the Terminal in the Utilities folder. Run this command line after the prompt in the Terminal’s window:

sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia \
--volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction

No need of any third party software

Urlencode Unicode

Work in python 3

1
2
3
4
5
6
7
$ python3
Python 3.3.4 (default, Feb 23 2014, 06:47:55)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.parse
>>> urllib.parse.urlencode({'a':chr(400)})
'a=%C6%90'

Does not work in python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ python
Python 2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> urllib.urlencode({'a':chr(400)})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: chr() arg not in range(256)
>>> urllib.urlencode({'a':u"\u0400"})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/antkong/anaconda/lib/python2.7/urllib.py", line 1329, in urlencode
    v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0400' in position 0: ordinal not in range(128)

CAGradientLayer

1
2
3
4
    CAGradientLayer *gradient = [CAGradientLayer layer];
    gradient.frame = self.view.bounds;
    gradient.colors = @[ [colorOne CGColor], [colorTwo CGColor] ];
    return gradient;

The above code will cause this compiler error:

/path/to/MyViewController.m:31:26: Collection element of type 'CGColorRef' (aka 'struct CGColor *') is not an Objective-C object

It can be fixed by casting to id

1
2
3
4
    CAGradientLayer *gradient = [CAGradientLayer layer];
    gradient.frame = self.view.bounds;
    gradient.colors = @[ (id)[colorOne CGColor], (id) [colorTwo CGColor] ];
    return gradient;

It is a new behavior due to the use of ARC

Some Objective-c Note-to-self

To find the number of items in a NSArray use

[array count];

It is not size (python) or length (java)