- Learn Unix command-line tools
- Setup Java & Android dev. tools
- Learn Git repository
- Jump-start Desktop Java project
- Jump-start Android Java project
- Reverse com.facebook.katana.apk
iterm2, menu meters, fraise, better touch tool, adium, iStat, textmate, StartUpSound.PrefPane, little snitch, sequel.pro, oracle.sql.developer, Day-O.
- Unix file system & commands
- Unix command crash course
- 50 Most Frequently Used UNIX / Linux commands
- 10 Awesome Examples for Viewing Huge Log Files in Unix
- 15 Practical Grep Commands
Set up github.com and assembla.com accounts
ssh-keygen -t rsa
# generates a key pair for password-less SSH logins.cat ~/.ssh/id_rsa.pub
# should password-less-login to Git repositories.- http://www.github.com → Account Settings → SSH Public Keys → Add another public key
- http://www.assembla.com → Edit Profile → Manage SSH Keys → Add key
sudo mkdir /workspace/
sudo chown $USER /workspace/
mkdir /workspace/gits/ # home for git repositories
git clone [email protected]:henry4j/-.git /workspace/gits/henry4j
cp /workspace/gits/henry4j/bin/.profile ~ # `source ~/.profile`, or open a new shell
cp /workspace/gits/henry4j/bin/.vimrc ~
cp -R /workspace/gits/henry4j/bin/.vim ~
cp /workspace/gits/henry4j/bin/.git-aliases ~
sudo mdutil -a -i off # (optional) disables spotlight.
sudo port install wget
sudo port install unzip
sudo port install unrar
sudo port install maven3
sudo port install colordiff
wget -P /tmp/ https://github.com/downloads/b4winckler/macvim/macvim-snapshot-62.tbz
pushd /tmp/; tar xvf /tmp/macvim-snapshot-62.tbz; popd
mv /tmp/MacVim-snapshot-62/MacVim.app /Applications/
alias vim='/Applications/MacVim.app/Contents/MacOS/Vim'
- Uninstall Xcode 4.2 by
sudo /Developer/Library/uninstall-devtools –mode=all
in case of build errors. - Install Xcode 4.1 according to
rvm requirements
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # loads rvm into shell, or .profile.
rvm # in a new shell
rvm install 1.9.2-head
rvm use 1.9.2-head
ruby -v
rvm --default use 1.9.2-head
echo '1+1' | irb
gem install bundler
# gem install rails
Install VIM markdown preview
rvm system
sudo gem install redcarpet
sudo gem install github-markup
git clone git://github.com/robgleeson/hammer.vim.git /tmp/hammer.vim
rm -rf ~/.vim/plugin/*
cp -R /tmp/hammer.vim/plugin/* ~/.vim/plugin/
^-^;;;;; -- install JDK 6, JDK 7, or both in order to debug-step into JDK sources.
wget -P /tmp/ http://dl.google.com/android/android-sdk_r15-macosx.zip
unzip -o /tmp/android-sdk_r15-macosx.zip -d /workspace/
cd /workspace/
mv android-sdk-macosx android-sdk-r15
ln -s android-sdk-r15 android-sdk
android update sdk --no-ui --no-https # takes forever on sluggish network connections!!!
wget -P /tmp/ http://dl.dropbox.com/u/47820156/fastboot-mac.zip
unzip -o /tmp/fastboot-mac.zip -d /tmp/
sudo mv /tmp/fastboot-mac /opt/local/bin/fastboot
# see if .profile already has these by `grep 'HOME\|PATH' ~/.profile`
cat <<EOF >> ~/.profile
export ANDROID_HOME=/workspace/android-sdk
export M3_HOME=/usr/share/maven
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
EOF
echo | android create avd -f -n 5 -t 5 # android 2.3.3 (5)
emulator -avd 5
git clone git://git.springsource.org/spring-mobile/samples.git /workspace/gits/spring-mobile-samples
cd /workspace/gits/spring-mobile-samples/spring-android-showcase/client
mvn clean install
mvn android:emulator-start
mvn android:deploy
wget -P ~/Downloads/ http://ftp.osuosl.org/pub/eclipse/technology/epp/downloads/release/indigo/SR1/eclipse-jee-indigo-SR1-macosx-cocoa-x86_64.tar.gz
pushd /Applications/; tar xvf ~/Downloads/eclipse-jee-indigo-SR1-macosx-cocoa-x86_64.tar.gz; popd
open /Applications/eclipse/Eclipse.app # and then keep this in dock
- Eclipse | Help | Install New Software... | Add...
- Enter
ADT Plugin
andhttps://dl-ssl.google.com/android/eclipse/
into Add Repository | OK - Select All | Next | Next | Accept EULA | Finish | Restart Now
- Repeat 1 - 3 for
m2e
andhttp://download.eclipse.org/technology/m2e/releases/
- (Optional) Repeat it for Maven Integration for Android Development Tools.
- See Also Getting started with Maven Integration for Android Development Tools http://code.google.com/a/eclipselabs.org/p/m2eclipse-android-integration/wiki/GettingStarted
- See Also Blog posts about Maven Integration for Android Development Tools http://code.google.com/p/maven-android-plugin/wiki/LinksBlogsAndMore
- More Eclipse plugins: MouseFeed at
http://update.mousefeed.com/
, JAutoDoc athttp://jautodoc.sourceforge.net/update/
- Preferences... | Android | SDK Location:
/workspace/android-sdk
- Optionally to build platform applications & services
wget -P /workspace/ http://dl.dropbox.com/u/47820156/platform.jks
- Android | Build | Custom debug keystore:
/workspace/platform.jks
git config --global user.name "Henry Lee" # your name instead
git config --global user.email [email protected] # your email address instead
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
, or cp /workspace/gits/henry4j/bin/.gitconfig ~
wget -P /tmp/ https://github.com/henry4j/-/raw/master/bin/p4merge
wget -P /tmp/ https://github.com/henry4j/-/raw/master/bin/p4diff
wget -P /tmp/ http://dl.dropbox.com/u/47820156/p4merge-mac-osx-july-2011.zip
unzip -o /tmp/p4merge-mac-osx-july-2011.zip -d /Applications/
sudo mv /tmp/p4merge /opt/local/bin/
sudo mv /tmp/p4diff /opt/local/bin/
sudo chmod +x /opt/local/bin/p4merge
sudo chmod +x /opt/local/bin/p4diff
cat <<EOF > ~/.gitignore
*.class
*.md.html
*.mkd.html
.DS_Store
.p4config
.settings/
bin/
gen/
target/
project.properties
EOF
Git Reference, Screencast, and Guide
^-^;;;;;
mkdir notes
cd notes
git init
touch readme.mkd
git add readme.mkd
git commit -m 'git init'
git remote add origin [email protected]:henry4j/notes.git
git push -u origin master
- Install Eclipse EGit under Collaboration at http://download.eclipse.org/releases/indigo/
- Usage
- Team → Share Project... → Git → Next → Use or create Repository in parent folder → Finish
- Team → Pull
- Team → Remote → Push...
- Team → Show in History to inspect history
Build Oxygen AOSP custom ROM on Mac OSX Lion
export USE_CCACHE=1 # sets up the C/C++ compiler cache in .profile
POSIXLY_CORRECT=1 sudo port install libsdl git-core gnupg
make --version # 3.81 is required, while 3.82 has an issue
python --version # 2.4 - 2.7 is required, while 3.x has an issue
ulimit -S -n 1024 # sets up the file descriptor limit to 1024 in .profile
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > /tmp/repo
sudo mv /tmp/repo /opt/local/bin/repo
sudo chmod a+x /opt/local/bin/repo
mkdir /workspace/gits/oxygen-gingerbread
pushd /workspace/gits/oxygen-gingerbread
repo init -u git://github.com/oxygen-rom/android_manifest.git -b gingerbread
# let's sync once the repo got initialized in /workspace/gits/oxygen-gingerbread
repo sync -j16
sudo port install gsed findutils
sudo ln -s /opt/local/bin/gsed /opt/local/bin/sed
sudo ln -s /opt/local/libexec/gnubin/find /opt/local/bin/find
sudo ln -s /Developer/SDKs/MacOSX10.6.sdk /Developer/SDKs/MacOSX10.5.sdk
sudo sed -i '.bak' -e 's:^size_t strnlen:// size_t strnlen:g' /usr/include/string.h
sed -i '.bak' -e 's:^:# :g' /workspace/gits/oxygen-gingerbread/external/qemu/Android.mk
source build/envsetup.sh
lunch oxygen_crespo-eng # or, lunch cyanogen_crespo-eng
pushd device/samsung/crespo; ./extract-files.sh; popd # extract device specific files
make -j8
source build/envsetup.sh
sed -i '' -e 's:(!pkg.applicationInfo.sourceDir.startsWith(E:(!pkg.packageName.contains("experimental") \&\& \
!pkg.applicationInfo.sourceDir.startsWith(E:1' \
frameworks/base/services/java/com/android/server/PackageManagerService.java
repo status frameworks/base # lists services/java/com/android/server/PackageManagerService.java
repo diff frameworks/base
mmm frameworks/base/services/java
adb shell mount -o remount,rw /system
adb shell cp /system/framework/services.jar /system/framework/services.jar.bak
adb push out/target/product/crespo/system/framework/services.jar /system/framework/services.jar
adb shell reboot
wget -P /tmp/ http://dl.dropbox.com/u/47820156/crespo-system-framework-services.jar
# or wget -P /tmp/ http://dl.dropbox.com/u/47820156/generic-system-framework-services.jar
adb shell mount -o remount,rw /system
adb shell cp /system/framework/services.jar /system/framework/services.jar.bak
adb push /tmp/crespo-system-framework-services.jar /system/framework/services.jar
# or adb push /tmp/generic-system-framework-services.jar /system/framework/services.jar
adb shell reboot
pushd /workspace/gits/henry4j/projs./places;
mvn eclipse:eclipse -DdownloadSources=true
# spawns an eclipse project w/ sources- File → Import... → General → Existing Projects into Workspace
- Enter
/workspace/gits/henry4j/projs./places
for root directory - Refresh → Finish
- Eclipse → Preferences → Java → Build Path → Classpath Variables → New... → M2_REPO and
/Users/henry/.m2/repository
- File → Import... → General → Existing Projects into Workspace
- Enter
/workspace/gits/henry4j/projs./yamba
for root directory - Refresh → Finish
Install apktool to reverse APK resources
wget -P /tmp/ http://android-apktool.googlecode.com/files/apktool1.4.1.tar.bz2
wget -P /tmp/ http://android-apktool.googlecode.com/files/apktool-install-macosx-r04-brut1.tar.bz2
pushd /opt/local/bin/
sudo tar xvf /tmp/apktool1.4.1.tar.bz2
sudo tar xvf /tmp/apktool-install-macosx-r04-brut1.tar.bz2
popd
Install dex2jar to reverse Dalvik bytecode
wget -P /tmp/ http://dex2jar.googlecode.com/files/dex2jar-0.0.9.2-SNAPSHOT.zip
sudo unzip -o /tmp/dex2jar-0.0.9.2-SNAPSHOT.zip -d /opt/local/share/
sudo ln -s /opt/local/share/dex-translator-0.0.9.2-SNAPSHOT /opt/local/share/dex2jar
sudo chmod +x /opt/local/share/dex2jar/dex2jar.sh
sudo ln -s /opt/local/share/dex2jar/dex2jar.sh /opt/local/bin/dex2jar
Install fernflower to reverse Java bytecode
wget -P /tmp/ https://github.com/henry4j/-/raw/master/bin/fernflower.jar
wget -P /tmp/ https://github.com/henry4j/-/raw/master/bin/fernflower
sudo mv /tmp/fernflower.jar /opt/local/bin/
sudo mv /tmp/fernflower /opt/local/bin/
sudo chmod +x /opt/local/bin/fernflower
wget -P /tmp/ https://raw.github.com/henry4j/-/master/bin/apk2eclipse
sudo mv /tmp/apk2eclipse /opt/local/bin/
sudo chmod +x /opt/local/bin/apk2eclipse
Install Jad-Clipse and Jad
wget -P /tmp/ http://www.varaneckas.com/sites/default/files/jad/jad158g.mac.intel.zip
sudo unzip -o /tmp/jad158g.mac.intel.zip -d /usr/bin/
wget -P /tmp/ http://dl.dropbox.com/u/47820156/jadretro-1_6-jre.tar
pushd /tmp/; tar xvf jadretro-1_6-jre.tar; popd;
cat <<EOF > /tmp/jadretro/jadretro
#!/bin/bash
java -jar \`dirname \$0\`/jadretro.jar \$@
EOF
sudo mv /tmp/jadretro/jadretro.jar /usr/bin/
sudo mv /tmp/jadretro/jadretro /usr/bin/
sudo chmod +x /usr/bin/jadretro
- Help | Install New Software ... | Add ... to open the Add Repository dialog
- Type
http://jadclipse.sourceforge.net/update/
to location | OK - Check
Java Decompiler Eclipse Plug-in
|Next
twice - Choose to accept the license and then
Finish
- Type
- Preferences | General | Editors | File Associations
- Make default editor
Decompiled Class File Viewer
for*.class
.
- Make default editor
- Preferences | Java | Decompilers | Jad
- Debug → Check
Output original line numbers as comments
- Formatting → Check
Don't insert a newline before opening brace
- Debug → Check
CMD + Shift + T
to open a type that gets decompiled instantly by Jad-Clipse, e.g. FacebookService type.CMD + Shift + R
to open a source file that is already decompiled by Fernflower, e.g. FacebookService.java.
Outside Eclipse, we will use JD-GUI
- File | Open ... | "*.jar" (any Java Archive that we want to decompile)
- File | Save All Sources to save the decompiled sources into a zip file
JD-Eclipse -- no longer in our uses.
- Help | Install New Software ... | Add ... to open the Add Repository dialog
- Type
http://java.decompiler.free.fr/jd-eclipse/update
to location | OK - Check
Java Decompiler Eclipse Plug-in
|Next
twice - Choose to accept the license and then
Finish
JD-Eclipse w/ realignment at sourceforge -- no longer in our use.
wget -P /Applications/eclipse/plugins http://iweb.dl.sourceforge.net/project/realignmentjd/realignment.jd.ide.eclipse_1.0.2.jar
- Preferences → General → Editors → File Associations and select "*.class" file type and to choose "Realignment for JD Class File Editor" for Associated editors.
Decompile facebook.apk and deep-dive into ...
adb shell sqlite3 /data/data/com.android.vending/databases/market_assets.db .dump | grep facebook
adb shell 'pm path com.facebook.katana' # tells /data/app/com.facebook.katana-1.apk for facebook 1.7.2
adb pull /data/app/com.facebook.katana-1.apk
mv com.facebook.katana-1.apk com.facebook.katana-1.7.2.apk
apk2eclipse com.facebook.katana-1.7.2.apk
adb shell 'pm list packages -f com.google.android.gsf'
adb shell 'pm path com.google.android.gsf'
adb pull /system/app/GoogleServicesFramework.apk
mv GoogleServicesFramework.apk com.google.android.gsf-2.3.apk
apk2eclipse com.google.android.gsf-2.3.apk
wget -P /tmp/ http://dl.dropbox.com/u/47820156/AndroidMod.zip
unzip -o /tmp/AndroidMod.zip -d /tmp/
cat <<EOF > /tmp/SignApk/signapk
#!/bin/bash
java -jar \`dirname \$0\`/signapk.jar \$@
EOF
sudo mv /tmp/SignApk/signapk.jar /usr/bin/
sudo mv /tmp/SignApk/signapk /usr/bin/
sudo chmod +x /usr/bin/signapk
wget -P /tmp/ http://busybox.net/downloads/binaries/latest/busybox-armv4tl
adb shell mount -o remount,rw /system
adb push /tmp/busybox-armv4tl /system/bin/busybox
adb shell chmod 755 /system/bin/busybox
wget -P /tmp/ http://downloads.androidsu.com/superuser/Superuser-3.0.6-efgh-signed.zip
unzip -o /tmp/Superuser-3.0.6-efgh-signed.zip -d /tmp/
adb push /tmp/system/app/Superuser.apk /system/app
adb push /tmp/system/bin/su /system/bin
adb shell chmod 664 /system/app/Superuser.apk
adb shell chmod 4755 /system/bin/su
mkdir -p /workspace/gits/commons; cd /workspace/gits/commons
git clone https://code.google.com/p/guava-libraries/ google-guava
svn checkout http://svn.apache.org/repos/asf/commons/proper/beanutils/trunk/ commons-beanutils
svn checkout http://svn.apache.org/repos/asf/commons/proper/cli/trunk/ commons-cli
svn checkout http://svn.apache.org/repos/asf/commons/proper/collections/trunk commons-collections
svn checkout http://svn.apache.org/repos/asf/commons/proper/functor/trunk/ commons-functor
svn checkout http://svn.apache.org/repos/asf/commons/proper/io/trunk commons-io
svn checkout http://svn.apache.org/repos/asf/commons/proper/lang/trunk commons-lang3
svn checkout http://svn.apache.org/repos/asf/commons/proper/primitives/trunk commons-primitives
wget -P /tmp/ http://apache.mirrors.redwire.net//httpcomponents/httpclient/source/httpcomponents-client-4.1.2-src.tar.gz
tar xvf /tmp/httpcomponents-client-4.1.2-src.tar
svn checkout http://svn.apache.org/repos/asf/lucene/dev/trunk lucene-trunk
export GREP_OPTIONS='--color=auto'
find . | grep -v 'git\|svn\|Test' | xargs grep -n -A1 -B1 'public .*[eE]xists' # to see usages of exists
diff -rq samsung-SGH-I727-Email samsung-SGH-I717-KJ5-Email # to see the diffs between Celox and Quincy
cat <<EOF >> ~/bin/delete-edb
adb shell rm /data/system/accounts.db
adb shell rm -r /data/data/com.htc.android.mail/databases/*
adb shell rm -r /data/data/com.htc.android.mail/shared_prefs/*
adb shell rm -r /data/data/com.android.email/databases/*
adb shell rm -r /data/data/com.android.email/shared_prefs/*
adb shell busybox killall com.htc.android.mail
adb shell busybox killall com.android.email
adb shell busybox killall com.google.android.gm
adb shell busybox killall com.google.process.gapps
# adb shell reboot
EOF
cat <<EOF > ~/bin/list-mdb
adb shell sqlite3 /data/data/com.android.vending/databases/market_assets.db .dump
EOF
chmod +x ~/bin/list-mdb
cat <<EOF > ~/bin/add-to-mdb
adb shell sqlite3 /data/data/com.android.vending/databases/market_assets.db "INSERT OR REPLACE INTO asset_versions VALUES('v2:com.joulespersecond.seattlebusbot:1:21','content://downloads/my_downloads/6','DOWNLOAD_PENDING',1320161445169,1320161447243,1320161453103,0,447135,'com.joulespersecond.seattlebusbot','false','KP1Z29pn70_zfKRDHQCHWCpEFJU',0,21,'details?doc=com.joulespersecond.seattlebusbot',NULL,-1,'','',-1,4,-1,'','',-1,4)"
adb shell sqlite3 /data/data/com.android.vending/databases/market_assets.db "INSERT OR REPLACE INTO assets VALUES('com.joulespersecond.seattlebusbot','DEFAULT','[email protected]')"
adb shell busybox killall com.android.vending
EOF
chmod +x ~/bin/add-to-mdb
mkdir ~/opt/; pushd ~/opt/;
wget http://redis.googlecode.com/files/redis-2.4.2.tar.gz;
tar xvf redis-2.4.2.tar.gz;
ln -s redis-2.4.2 redis; pushd redis;
sed -e 's/port 6379/port 6389/g' redis.conf > redis-6389;
src/redis-server redis-6389.conf; # in one terminal
src/redis-server; # in another terminal
mkdir ~/opt/; pushd ~/opt/;
wget http://nodejs.org/dist/node-v0.4.12.tar.gz
tar xvf node-v0.4.12.tar.gz
ln -s node-v0.4.12 node; pushd node
# to build according to README.md
./configure
make
sudo make install
# to test an example node
cat <<EOF >> /tmp/example.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
EOF
node /tmp/example.js & # plays a server.
curl http://127.0.0.1:1337/ # plays a client.