Tuesday, March 13, 2012

ADB (Android Debugging Bridge)


Installing and uninstalling apk
adb install <apk file>
adb uninstall <package name>

Example:
adb install /Users/Documents/Android/MyApk.apk
adb uninstall lt.rj.name

Monday, March 12, 2012

Useful git commands


Rollback/remove commits

If we have log like shown below. And we want to remove commit with name <commit_sha1>.
git log 
commit <commit_sha1>
 ... 
commit <commit_sha2>
 ... 

Then we could execute this lines:
git rebase -i HEAD^^ 

or

git rebase -i <commit_sha2>



Rollback file

You can quickly review the changes made to a file using the diff command:
git difftool <commit_sha> <file_name> -y
git diff <commit_sha> <file_name>


Then to revert a specific file to that commit use the reset command:
git reset <commit_sha> <file_name>

Then commit the change:
git commit

Then checkout latest version for the file:
git checkout <file_name>



git: undo a merge? 

After executing this command our master branch will look identical to origin/master:
git reset --hard origin/master

With git log we can check which commit is one prior the merge. Then you we can reset it using:
git reset --hard commit_sha 

Go back by 5 commits:
git reset --hard HEAD~5 


File not ignored when it is added to .gitignore 
Problem can be that this file is still in the git cache. To slow this problem needs to reset git cache.

Running command:
git rm -r --cached . 

This removes everything from the index, then just run:
git add . 

Commit it:
git commit -m ".gitignore was fixed."

Monday, March 5, 2012

File encoding in OSX


Encoding Type For File
Using the -I (that's a capital i) option on the file command seems to show the file encoding.
file -I {filename}

Encoding Conversions For File
Convert from one file type to another using the following command:

iconv -f original_charset -t new_charset originalfile > newfile
e.g.
iconv -f utf-16le -t utf-8 file1.txt > file2.txt