iPhone Debugging

June 23, 2009 – 3:46 am

As not to forget.. its “obj_exception_throw” from debugger -> breakpoints. Very helpful indeed. Note you can click on the image below to get a fullscreen view on my extended Samsung SW2333.. hehe


iphone_debugger.png

Other references.. Download “Lecture 13
(13. Debugging Tips, Searching, Notifications, KVC_KVO (May 13, 2009)) from Stanford University CS193 Class in iTunes.

Two Oracle Homes in one Machine

June 11, 2009 – 9:29 am

I’ve been toggling back and forth two different oracle homes by editing the environment variables from the Control Panel in Windows which is a pain in the ***. What I did was, to create two different command prompt shells with different oracle home environments. I got this idea after a glimpse from FWTools.

1. Create a Command Prompt Shortcut and drag it to your oracle directory, i.e, E:\oracle\Oracle Shell Local

2. Edit the target as:


C:\WINDOWS\system32\cmd.exe /K "E:\oracle\setlocal.bat"
 

3. Create “setlocal.bat”


@echo off
SET ORACLE_HOME=E:\oracle\product\10.2.0\db_2
set PATH=E:\oracle\product\10.2.0\db_2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
 

Do the same for your remote oracle but with a different bat file.
1. Repeat steps 1 and 2 but name it “Oracle Shell Remote” and “E:\oracle\setremote.bat”

2. Create “setremote.bat”


@echo off
SET ORACLE_HOME=E:\oracle\product\10.2.0\client_1
set PATH=E:\oracle\product\10.2.0\client_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
 

Note: This assumes that you have installed an Oracle Client on E:\oracle\product\10.2.0\client_1

Ok, now let’s test. I know that I have different record count for a table in my local and remote
1. Fire up “Oracle Shell Local”. Run sqlplus
>sqlplus username/password@instance_name_defined_in_local_tnsnames.ora

Note: E:\oracle\product\10.2.0\db_2\NETWORK\ADMIN\tnsnames.ora

2. Fire u p “Oracle Shell Remote”. Run sqlplus
>sqlplus username/password@instance_name_defined_in_remote_tnsnames.ora

Note: E:\oracle\product\10.2.0\client_1\NETWORK\ADMIN\tnsnames.ora

So what? Well its very useful when doing export and imports. Say I want to export a table from my local and import it to my remote oracle. I’ll just fire up two shells, issue an export in my “Oracle Shell Local” and run an import command in my “Oracle Shell Remote”

iPhone Interface Elements

May 20, 2009 – 4:50 pm

My notes from the iPhone Human Interface Guidelines.

Toolbars

62EDFD6D-585D-4EFC-A501-B936104236FD.jpg

  • actions users can take in the current context
  • provides functionality within the context of a task
  • hit-region of a user interface element is recommended to be 44 x 44 pixels

Tab Bars

9507CA52-75CC-4103-82C3-8119042CB714.jpg

  • A tab bar gives users the ability to switch among different modes or views in an application, and users should be able to access these modes from everywhere in the application
  • Displays 5 or fewer tabs. More Tab is display on 6+
  • When an application has more than five tabs, users can select their favorite tabs to display in the tab bar

Alerts

Picture 1.png

  • Alerts give users important information that affects their use of the application (or the device). Alerts are usually unexpected, because they generally tell users about a problem or a change in the current situation that might require users to take action.
  • An alert that contains three or more buttons is significantly more complex than a two-button alert, and should be avoided if possible. In fact, if you find that you need to offer users more than two choices, you should consider using an action sheet instead

Action Sheets

Picture 3.png

  • Displays a collection of alternatives that are associated with a task users initiate by tapping a button in an application’s toolbar
  • Get confirmation before completing a potentially dangerous task.
  • If you need to provide a button that performs a potentially destructive action, such as deleting all the items in a user’s shopping list, you should use the red button color.

Modal Views

Picture 2.png

  • A modal view slides up from the bottom edge of the screen and always covers the entire application screen
  • A good example of a modal view is the compose view in Mail. When users tap the Compose button, a modal view appears that contains text areas for the addresses and message, a keyboard for input, a Cancel, and a Send button.
  • In a modal view, you can use whichever controls are required to accomplish the task. For example, you can include text fields, buttons, and table views.

Table Views

Picture 4.png

  • Left - Simple List in a Regular Style Table View
  • Left - The disclosure indicator element is necessary if you’re using the table to present hierarchical information. This is because users know that this element means “show the next page of information.” It should appear to the right of every list item that contains a sublist of items.
  • Middle - Indexed list in a Regular Style Table View
  • If you want to display a list of items divided into sections, you can configure a regular table view to display section headers, with each header describing a section and providing visual distinction from the other sections.
  • Right - Grouped List in a Grouped Style Table View

Text Views

  • A region that displays multiple lines of text.
  • Inherits from a scroll view, which means that the text view supports scrolling when the content is too large to fit inside its bounds.
  • Support user editing. If you make a text view editable, a keyboard appears when the user taps inside the text view.

Web Views

  • Region that can display rich, HTML content in your application screen.

Activity Indicator

Picture 5.png

  • The “spinning gear” appearance of the activity indicator shows users that processing is occurring, but does not suggest when it will finish.
  • By default, an activity indicator is white.

Normal Picker

Picture 8.png

  • Display any set of values
  • Values in a wheel are hidden from the user when the wheel is stationary

Date and Time Pickers

Picture 6.png

  • Can have up to four independent spinning wheels

Info Buttons

Picture 7.png

  • Provides a way to reveal configuration details about an application, often on the back side of the screen.
  • Suited to utility applications

Page Indicators

  • Displays a dot for each currently open view in an application (See weather app image above)

Progress Views

Picture 9.png

  • Shows the progress of a task or process that has a known duration

Search Bars

Picture 10.png

  • When the user taps a search bar, a keyboard appears; when the user is finished typing search terms, the input is handled in an application-specific way.
  • Placeholder text.
  • The Bookmarks button.
  • The Clear button.
  • A descriptive title

Segmented Controls

Picture 11.png

  • A linear set of segments, each of which functions as a button that can display a different view

Sliders

Picture 12.png

  • Allow users to have fine-grained control over the values they choose

Switch Controls

  • See auto brightness switch control image above
  • Presents to the user two mutually exclusive choices or states, such as yes/no or on/off.

Text Field

Picture 13.png

  • When the user taps a text field a keyboard appears; when the user taps Return in the keyboard, the text field handles the input in an application-specific way.

System Generated Controls

Launch Images

Picture 15.png

  • Measures 320 x 480 pixels.
  • Name your launch image file Default.png and place it at the top level of your application bundle.

Application Icon

  • Measures 57 x 57 pixels.
  • Does not have any shine or gloss.
  • Name your icon file Icon.png and place it at the top level of your application bundle.

Custom Icons

  • For toolbar and navigation bar icons, create an icon that measures about 20 x 20 pixels.
  • For tab bar icons, create an icon that measures about 30 x 30 pixels.
  • Use the PNG format.
  • Use white with appropriate alpha and no shadow.
  • Use anti-aliasing.

iPhone Development Getting Started

May 18, 2009 – 9:19 pm

After moving from Beijing to Manila to Perth to Melbourne, now Im making most of my time in iPhone Development. Last week, I just applied for the iPhone Standard Developer Program and was able to test on an actual iPhone 3G device running on iPhone 2.2.1. Note that I haven’t downloaded the iPhone 3.0 OS Beta yet as I am still figuring things out but will do so in the next two weeks. My carrier sucks and I’ve used 14GB out of my 20GB allowance so Im delaying the download of the iPhone 3.0 SDK. Crap.

iPhone Mind Map.png

Learning curve..

1. First and foremost, you need a Mac and an iPhone.

2. Familiarize yourself with iPhone Developer Central

3. Meet Objective-C.

4. Introduction to Objective-C 2.0 Programming Language

5. Learn Objective C from cocoadevcentral

6. Leopard Guides: Cocoa Objective-C Language

7. Haven’t tried XCode before? Get a brief introduction from BecomeAnXcoder

8. CS193 from Stanford University. I believe it is essential to go through a few documents and tutorials listed above before being lazy and watching the videos.

I strongly recommend going through the Assignments as well.

hello poly.png

9. iPhone Application Programming Guide

10. Read Quartz 2D Programming Guide if you are into graphics.

It’s my practice to learn a language from the Documentation itself before reading through books. But Programming in Objective-C from Stephen Kochan is worth a look. I haven’t read iPhone SDK Development from the Pragmatic Bookshelf but since Bill Dudney is one of the core developers for ObjC, my guess it would be good.

Half of the innovators for Nokia Summit 2009 will use LBS

April 28, 2009 – 6:15 am

Nokia will again be hosting its Nokia Developer Summit 2009. This time, the hackathon has ten (10) handpicked ideas out of 1400 submitted worldwide by consumers. Half of these are location based centric and one third has social networking focus!

CellCity - location based public transport
EarthComber - location based siteseeing and events
Mo’Blast - social-location widget
Plusmo - sports-focused social-location widget
Yalla Ya! - social-location widget

Firefox crashes on my Mac caused by Java Applet VM

December 17, 2008 – 11:59 am

After manually updating to Java MacOSX10.5 Update 2 two months ago, I noticed something weird with my Firefox. At first, I ignored it, “heh must be a screwed-up page Im trying to open…” But lately, I noticed that most of the pages I am opening with Java applets crashes consistently. So here is the culprit, try to delete java caches if there are any…

Trying to figure out which version of the java applet being used by FF
Picture 1.png

Picture 2.png

Deleting the cache.. Go to
/Application/Utilities/Java/ and launch Java Preferences.app or you could seach for “java preferences” in spotlight.

Picture 3.png

If the problem still persist, I bet we can trim down which java versions to use…

Picture 4.png

RubyonRails + Oracle on Linux (i386 / x64)

December 11, 2008 – 11:53 am

In summary, install Oracle Instant Client and try to run sqlplus. If sqlplus connects to the oracle sid then go ahead and install the rails adapters for oracle. What is important to note here, is to install the oracle-instantclient for the architecture of your machine.. I have tested this on Debian Lenny (i386) and CentOS5 (x64)

1. Download from http://www.oracle.com/technology/software/tech/oci/instantclient/

a. oracle-instantclient-basic-10.2.0.4-1.i386
b. oracle-instantclient-devel-10.2.0.4-1.i386
c. oracle-instantclient-sqlplus-10.2.0.4-1.i386

2. Unzip everything to /opt/oracle/instantclient . You should have something like the ff:


[root@csapp1 instantclient]# ls -la
total 102704
drwxr-xr-x 3 root root     4096 Dec 10 21:54 .
drwxr-xr-x 3 root root     4096 Dec 10 22:03 ..
-rw-r–r– 1 root root      228 Dec 10 21:52 BASIC_README
-r–r–r– 1 root root  1609607 Dec 10 21:52 classes12.jar
-rwxr-xr-x 1 root root    67542 Dec 10 21:52 genezi
-r–r–r– 1 root root     1525 Dec 10 21:52 glogin.sql
lrwxrwxrwx 1 root root       17 Dec 10 21:54 libclntsh.so -> libclntsh.so.10.1
-rwxr-xr-x 1 root root 21038613 Dec 10 21:52 libclntsh.so.10.1
-r-xr-xr-x 1 root root  3796601 Dec 10 21:52 libnnz10.so
-rwxr-xr-x 1 root root  1664116 Dec 10 21:52 libocci.so.10.1
-rwxr-xr-x 1 root root 72674185 Dec 10 21:52 libociei.so
-r-xr-xr-x 1 root root   138033 Dec 10 21:52 libocijdbc10.so
-r-xr-xr-x 1 root root  1435561 Dec 10 21:52 libsqlplusic.so
-r-xr-xr-x 1 root root   997409 Dec 10 21:52 libsqlplus.so
-r–r–r– 1 root root  1555682 Dec 10 21:52 ojdbc14.jar
drwxr-xr-x 4 root root     4096 Dec 10 21:52 sdk
-r-xr-xr-x 1 root root     7773 Dec 10 21:52 sqlplus
-rw-r–r– 1 root root      232 Dec 10 21:52 SQLPLUS_README
-rw-r–r– 1 root root      516 Dec 10 21:53 tnsnames.ora
[root@csapp1 instantclient]#
 

3. Make a symbolic link for libclntsh.so.10.1 as shown above.

4. Create the Oracle Environment variables


export ORACLE_HOME=/opt/oracle/instantclient
export TNS_ADMIN=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME
 

5. At this point, you should have oracle-instantclient properly installed. You can test by running sqlplus.


[root@csapp1 instantclient]# sqlplus

SQL*Plus: Release 10.2.0.4.0 - Production on Thu Dec 11 11:47:40 2008

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
 

NOTE: Sometimes you will get a SEGMENTATION FAULT. If so, try to open a new shell with the environment variables loaded and do an sqlplus in a directory which is not /opt/oracle/instantclient.

6. Install the oracle adapter for rails

7. gem install ruby-oci8

8. gem install oracle_enhanced-adapter –source=”http://gems.rubyonrails.org/”

activerecord-oracle-adapter (1.0.0.9250)
activerecord-oracle_enhanced-adapter (1.1.8)

NOTE: Try to look for the latest gems, the source above is at the time of this writing so it might change.

9. Test using irb


[root@csapp1 instantclient]# irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'oci8'
=> true
irb(main):003:0>
 

Ruby on Rails + Oracle on Intel Mac

December 5, 2008 – 6:52 pm

1. Read http://www.foliosus.com/2008/05/05/connecting-ruby-on-rails-to-oracle-on-an-intel-mac-in-leopard-take-2/

2. Install Oracle Instant Client on Mac.

a. Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
- instantclient-basic-macosx-10.2.0.4.0.zip (34,020,719 bytes)

b. *Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
instantclient-sdk-macosx-10.2.0.4.0.zip (603,493 bytes)

OR download the whole bundle (10.2.0.4.zip) with sqlplus installed from my installers.

3. Put this on your sudo vim ~/.bash_profile.


export ORACLE_HOME=/Library/Oracle/instantclient/10.2.0.4
export TNS_ADMIN=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME
 

4. Make a symbolic link


cd /Library/Oracle/instantclient/10.2.0.4
ln -s libclntsh.dylib.10.1 libclntsh.dylib
 

5. Go to /Library/Oracle/instantclient/10.2.0.4 and edit tnsnames.ora. Point the Oracle SID to the IP where you installed Oracle.


ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.155)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

ORCL_2_11 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.11)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
 

6. Install the oracle-adapter for rails


sudo gem install activerecord-oracle-adapter --source http://gems.rubyonrails.org
 

7. In your database.yml file


development:
  adapter: oracle
  database: orcl
  username: youzhu_mobile_dev
  password: your_password
 

or browse the contents of a sample rails project youzhumobile.tar.gz

8. If you ever encounter an encoding problem, then we need to set the NLS_LANG environment variable before running script/server.


# export NLS_LANG=American_America.UTF8
# script/server
 

or I prefer setting it in the environment.rb


Rails::Initializer.run do |config|
  ENV['NLS_LANG']='American_America.UTF8'
  # Settings in config/environments/* take precedence over those specified here.
 

Note: If you don’t know your database encoding, then read this post.

How to present your nokia screen to your computer?

December 3, 2008 – 3:49 pm

I’ve found this tool which could display my Symbian phone in my Mac using WLAN. It supports BT, WLAN, and USB. So far, WLAN works for me so I sticked with it.

1. Download the software from http://www.digia.com/

2. Install the sis to your Nokia phone. Mine is an E61 so I paired it using BT on my mac.

3. Once installed, fill up the options on your phone… then try to ‘CONNECT’

Connection: TCP/IP
Access Point: Ofc (or Define an access point)
TCP/IP Host: 192.168.1.150 (IP address of my mac)

Picture 1.png

Fig 1 Trial mode lets you use it for the next two minutes with a big ‘TRIAL’ display on screen.

Picture 2.png
Fig 2. Sample USSD Message

LBS: OpenCellID

November 30, 2008 – 11:20 am

Picture 1.png
Figure 1. CellIDs for Manila taken from opencellID.org

http://mobiforge.com/developing/story/adding-location-a-non-gps-phone-introducing-opencellid

Interesting to see there was an opensource initiative to map cellIDs. Don’t know if Google made the same process for Google Maps MyLocation but I guess its very similar. Would it be possible to integrate such technology for SMS/USSD Development? Meaning when a mobile request to a back end system, the cellID would be included in the header before being passed to the application. I am fully aware this process is possible, however, I’m wondering if it is possible without installing any application (most likely j2me) on the mobile?