Saturday, August 17, 2013
How to install 'brew' packages manually.
The error messages are something like this:
==> Upgrading 1 outdated package, with result:
macvim 7.4-70
==> Upgrading macvim
==> Downloading https://github.com/b4winckler/macvim/archive/snapshot-70.tar.gz
#################################### 50.0%
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
==> Trying a full download
## 3.7%
curl: (56) SSL read: error:00000000:lib(0):func(0):reason(0), errno 54
Error: Download failed: https://github.com/b4winckler/macvim/archive/snapshot-70.tar.gz
I don't know why but it seems that 'curl' just can't download the packages from github.
So I want to install the package manually:
1) Download 'https://github.com/b4winckler/macvim/archive/snapshot-70.tar.gz' manually. So now I have '~/Download/macvim-snapshot-70.tar.gz'.
2) Verify it is the right one (this step is optional, but highly recommended):
- Open '/usr/local/Library/Formula/macvim.rb' and we can see that the files's sha1 checksum should be '66432ae0fe81b2787b23343b6c99ef81f6b52c3e'
- Use 'shasum' (a command line tool comes with the system) to check the downloaded file, it should output the same checksum.
3) Now open 'usr/local/Library/Homebrew/download_strategy.rb', add a line:
(it should start at line 62)
# Private method, can be overridden if needed.
def _fetch
ohai "download to #{@temporary_path}"
curl @url, '-C', downloaded_size, '-o', @temporary_path
end
4) Run 'brew upgrade' again. It will fail, but it will also print more information we need:
==> Upgrading 1 outdated package, with result:
macvim 7.4-70
==> Upgrading macvim
==> Downloading https://github.com/b4winckler/macvim/archive/snapshot-70.tar.gz
==> download to /Library/Caches/Homebrew/macvim-7.4-70.tar.gz.incomplete
## 3.6%
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
==> Trying a full download
==> download to /Library/Caches/Homebrew/macvim-7.4-70.tar.gz.incomplete
#### 6.2%
curl: (56) SSL read: error:00000000:lib(0):func(0):reason(0), errno 54
Error: Download failed: https://github.com/b4winckler/macvim/archive/snapshot-70.tar.gz
Note the red line, now we know the file name should be 'macvim-7.4-70.tar.gz.incomplete'. So we just copy the file here.
5) cp ~/Download/macvim-snapshot-70.tar.gz /Library/Caches/Homebrew/macvim-7.4-70.tar.gz.incomplete
6) edit 'usr/local/Library/Homebrew/download_strategy.rb' again, comment the line after when added:
# Private method, can be overridden if needed.
def _fetch
ohai "download to #{@temporary_path}"
# curl @url, '-C', downloaded_size, '-o', @temporary_path
end
7) Run 'brew upgrade' again. Succeed!
==> Upgrading 1 outdated package, with result:
macvim 7.4-70
==> Upgrading macvim
==> Downloading https://github.com/b4winckler/macvim/archive/snapshot-70.tar.gz
==> download to /Library/Caches/Homebrew/macvim-7.4-70.tar.gz.incomplete
==> ./configure --with-features=huge --enable-multibyte --with-macarchs=x86_64 --enable-perlinterp --enable-rub
==> make
==> Caveats
MacVim.app installed to:
/usr/local/Cellar/macvim/7.4-70
To link the application to a normal Mac OS X location:
brew linkapps
or:
ln -s /usr/local/Cellar/macvim/7.4-70/MacVim.app /Applications
==> Summary
🍺 /usr/local/Cellar/macvim/7.4-70: 1796 files, 28M, built in 74 seconds
Thursday, July 11, 2013
How to free the memory 'finder' use.
Fortunately, you can 'relaunch' the finder to make it free the memory. Here is how to:
- hold the option key (alt)
- right click on the finder icon (on the dock)
- click 'relaunch'
The finder will remember how many windows it has, and their position and restore them after the relaunch.
Very usefuly :)
Monday, August 27, 2012
rm -R with wildcard
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?
- 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:
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, inidl = 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$
