Sunday, December 2, 2012

How to disable 'developer mode' for xcode?

It is simple, just type:

DevToolsSecurity -disable

in a terminal window

it is from: here

Monday, August 27, 2012

rm -R with wildcard

Unfortunately, it seems the shell of Mac OSX doesn't support wildcard in 'rm -R' command. So if you want to delete, for example, some "*.swp" files which locates on many sub-directories, it will be very difficult.

However, there is a workaround by using the command "xargs". Here is the method:

$ find . | grep *.swp | xargs rm

What's the meaning?

First, "find ." will list all the files / directories in the current directory (.).
Then, the "|" will send the results to "grep", and grep will filter all the files/directories which don't meet "*.swp", that is, all the *.swp will be listed by "grep".
At last,  "xargs" will use the results returned by "grep" as argument for "rm", so that the file will be removed.




Sunday, July 1, 2012

How to change the default App for a file?

I just find that I can change the default App for a file by:

- Right click the file, for example, a jpg image, then click "Get Info"
- On the file Info dialog, you will be able to see an "Open with:".
- Select any App you want to open the file by default.
- Click "Change All..." to make it take effect for every file with ".jpg".

As the screenshot:


Sunday, March 25, 2012

Update ctags with brew

Update ctags with brew

The "ctags" coming with Mac OS is really a very old one (1993). We can update it with brew, and I think this Article is very useful.

The point is:

  • Install latest ctags with brew: brew install ctags. This should be OK
  • Replace "ctags" with:
    1. alias ctags="`brew --prefix`/bin/ctags"
    2. alias ctags >> ~/.bash_profile
    3. Please note that the original post uses ~/.bashrc but it won't work in Mac OS. So use ~/.bash_profile instead

`brew --prefix` will display the install path of brew, and append it with /bin/ctags will get the new ctags pathname. Please note that "`" is the character with the key "~" on your keyboard.

Friday, March 23, 2012

xpidl.py runs error on Mac OS

xpidl.py runs error on Mac OS X

I write firefox extension so I want to write it under Mac OS. However, I have trouble in generating the .xpt file from a .idl.

I use typelib.py which included in Gecko SDK to generate the xpt file, when I specify the command looks like this:

../../xulrunner-sdk/sdk/bin/typelib.py --cachedir=./ -I ../../xulrunner-sdk/idl ./components/xxx.idl -o ./components/xxx.xpt

I get error looks like this:

Traceback (most recent call last):
  File "../../xulrunner-sdk/sdk/bin/typelib.py", line 317, in 
    idl = p.parse(text, filename=file)
  File "/Users/xx/xulrunner-sdk/sdk/bin/xpidl.py", line 1475, in parse
    idl = self.parser.parse(lexer=self)
  File "/Users/xx/xulrunner-sdk/sdk/bin/ply/yacc.py", line 265, in parse
    return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
  File "/Users/xx/xulrunner-sdk/sdk/bin/ply/yacc.py", line 921, in parseopt_notrack
    lookahead = get_token()     # Get the next token
  File "/Users/xx/xulrunner-sdk/sdk/bin/xpidl.py", line 1464, in token
    t = self.lexer.token()
  File "/Users/xx/xulrunner-sdk/sdk/bin/ply/lex.py", line 384, in token
    newtok = self.lexerrorf(tok)
  File "/Users/xx/xulrunner-sdk/sdk/bin/xpidl.py", line 1150, in t_ANY_error
    lexpos=self.lexer.lexpos))
xpidl.IDLError: error: unrecognized input, ./components/xxx.idl line 1:26
#include "nsISupports.idl"
                          ^

I searched the web but can't get any hint, so I research it myself, and found out that it is caused the "newline" on Mac is "\r" but the python code used to parse the idl file is using "\n".

So it will be easy to fix this problem:

  # xulrunner-sdk/sdk/sdk/bin/xpidl.py
  # line: 1475
  data = data.replace('\r', '\n') # add this line
  self.lexer.input(data)

So the problem is solved :)

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