Sunday, February 12, 2012

Use JavaScript in command line

Get from this link, there is a executable "jsc" in /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/. However, which is not in your path by default, so you need to create a link in your /bin:

sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc /bin/jsc

Then you can just type "jsc" in any command line to execute javascript statements. You can use "quit();" to exit.

ddh$ jsc
> [] + []

> [] + {}
[object Object]
> {} + []
0
> {} + {}
NaN
> quit();
ddh$ 

Monday, January 9, 2012

.gitignore for xcode project

Copy from this link
*.DS_Store

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
*.pbxuser
*.perspective
project.xcworkspace/
xcuserdata/

# Generated files
*.o
*.pyc


#Python modules
MANIFEST
dist/
build/

# Backup files
*~.nib

# vim
*.swp
*~ 
 
-- update Oct 29 2012 --
I think the official gitignore (github) should be better :) 
link: https://github.com/GitHub/gitignore

Thursday, January 5, 2012

How to let iTunes manage data of your app?

I just read this Q&A from Apple: link.

Starting with iOS 3.2, applications can choose to allow users to add files to their app documents directory by adding the key UIFileSharingEnabled to their Info.plist. When that key is set, the contents of the directory <Application Home>/Documents will be accessible in iTunes where the user can add or remove files at will.

However, since I'm a newbie for developing iOS apps, and I don't have been a paid member of Apple, so I haven't tested this method yet :p

Sunday, December 25, 2011

NSNotification

It seems every NSNotification has a method named "object" returns the real UI element fires this notification. For example, in table view, when user click one item in the table view, a "NSTableViewSelectionDidChangeNotification" is fired, and the delegate will receive it. Then the delegate can use [aNotification object] to get the real table view. So it won't need to save a outlet of the table view.

Monday, December 5, 2011

How to import Xcode project into bitbucket

BitBucket supports private repository for free users, so it is very suitable for hosting our Xcode projects :)

When you signup your free account, and create a new project for yourself, the problem is coming, how to import your xcode project into the bitbucket?

1. Create your SSH key

First, you need to update your SSH key(s) into bitbucket, as we're OS X users, so it is very :)

1.1 Check your SSH key

In console, type:

$ls ~/.ssh<enter>

If there are id_rsa and id_rsa.pub exist, you've already got your SSH keys, so skip the next step.

1.2 Create your SSH key

In console, type:

$ssh_keygen<enter>

The program will ask you for a passphrase, you can just take it as a "password". And when the program finishes, there will be two files in your ~/.ssh

  • id_rsa - which is your private key, you need to protect this file, don't be touched by others.
  • id_ras.pub - which is the pub key, you can upload / send this file to others, such as bitbucket.

So we have our SSH key, then we upload it to bitbucket

2. Update your SSH key to bitbucket

Go to Bitbucket settings, click the "choose key", and browser to your id_rsa.pub (you may need to copy it to some directory that the finder can locate it, for example, in console, use: cp ~/.ssh/id_rsa.pub ~/ ), then click the same button, it should be "update key", after that, you public is uploaded successfully.

3. Upload your repository

I refer to this link, you need to:

  1. Create a repository in bitbucket
  2. Note the URL you should use is: git@bitbucket.org:youruser/yourepo.git
  3. in console, go to your locale repository: $cd /path/to/my/repo
  4. git push --mirror git@bitbucket.org:youruser/progbuenos.git

Then the local code will be uploaded to bitbucket, you can use git clone to fetch it back

Tuesday, November 22, 2011

How to update xcode via app store?

I just update xcode from 4.2 to 4.2.1 via App Store. However, after downloaded the latest version of xcode, there is nothing happens!
I searched the internet, and finally found that I must run /Applications/install xcode.app.... it means App Store only download the install package, and place it into /Applications, but doesn't run it for you.

You can click "install xcode" from launchpad, and follow the instructions.

Wednesday, November 16, 2011

For windows users, we all know that we can edit c:\windows\system32\drivers\etc\hosts to specify an IP address to a host name. But where is the "hosts" in Mac?

I searched the internet, and find out that this file is on: /private/etc/ so the file is:

/private/etc/hosts

And the format is the same as other systems.