Pages

6 Jun 2013

My Vim configuration

Recently, I got used to Vim, and it's really cooooooooool and it looks way so professional :D
I think I will keep it as my favorite text editors ;)

Anyway, I would like to save and share my Vim configuration here and it will be updated as  soon as I found something new ;)


Copy following configuration into your ~/.vimrc or ~/.exrc (well, I'm really not sure which one will be loaded by Vim :D)

"[Basic]
syntax on                               "turn syntax on
set number                              "show line number
set autoindent                          "turn auto indent on
set tabstop=4                           "set tab = 4 spaces
set shiftwidth=4                        "set tab when use > or < = 4 spaces
set colorcolumn=81                      "show margin line
set cursorline                          "hightlight current line

"[OmniCompletion]
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType perl set omnifunc=perlcomplete#Complete
"change ^x^o to ^space
inoremap   pumvisible() \|\| &omnifunc == '' ?
\ "\C-n>" :
\ "\C-x>\C-o>=pumvisible() ?" .
\ "\"\\c-n>\\c-p>\\c-n>\" :" .
\ "\" \\bs>\\C-n>\"\"
imap  

17 Apr 2013

Some useful GIT commands

View unpushed commits
git log --branches --not --remotes

Make git command line colorful
git config --global --add color.ui true 

28 Feb 2013

Create simple infinite carousel in Android with ViewPager

At first I thought it's easy, someone must have implemented it already, but after searching for it on Google, I got no luck, nobody has done and shared it on the Net, so I decided to make it myself.

I read some posts like:

So I implemented it as you can see in below video:

 


The main idea is:
  • Use ViewPager as the main view with pages are Fragment, then use ViewPager.setPageMargin(int) to set margin as a negative number, so the next and previous pages of the selected page will be showed up.
  • Override the layout which is the root view of Fragments to create scale animation.
  • Make a little hack in FragmentPagerAdapter so we can fling infinitely to both directions of the ViewPager.

For more information, you guys can get the source code here: https://github.com/mrleolink/SimpleInfiniteCarousel. I tried to comment as much as possible in source code, so I hope you understand my idea.

By the way, I don't think it's the best solution to implement the carousel pattern, so if you have any idea or there's something you don't understand about what I code, just drop me a line :)

24 Feb 2013

[SmartSVN] How to host files on Google Code (javascript, css, html, ...) and get a permanent, non-redirecting and bandwidth-generous hotlink

Hell yeah, finally I've found a "safe" place to put my stuffs for my site (like html, javascript, css... files), it's Google Code :D

Well, first of all, I just want to let you know I got the know-how from this site: http://www.ubuntudz.com/2010/10/how-to-host-files-on-google-javascript.html, and I recommend you to read it before start with this post.

Currently, I'm using Windows 8 and already have SmartSVN installed, that means I don't have SVN command. It took me a while to figure out how to change mime-type before commit by SmartSVN, so I would like to note it here just in case I forget how to do it :D
OK, let's go :)


Step1: Add your file to stage



Step 2: Right click on the file -> Properties -> Edit Properties...


Step3: Choose existed property (svn:eol-style) -> click Edit -> Edit like the following screenshot (remember to change "Curren Value" to: text/css for ".css" file, text/html for ".htm" and ".html" files, text/javascript for ".js" files...


Step4: OK -> OK -> Commit file.

21 Dec 2012

[Windows 8] Input method still remains after removing it?

Well, I've upgraded to Windows 8 recently, I tried to install Vietnamese input language method, but then I didn't feel like familiar to it, so I decided to remove it, well, everything was okay at that point.
After that, when I was working, I noticed that there's still Vietnamese input language method when I click on "ENG" button on task bar, that's weird, right? Afterwards, I searched and tried many ways (I even asked on a big forum: http://superuser.com/questions/522696/how-can-i-remove-an-input-method-completely-in-windows-8) to remove it but couldn't help... until this post:

http://answers.microsoft.com/en-us/windows/forum/windows_8-desktop/language-setting-question-display-lang-input-lang/4a057ad5-2965-4257-bc0f-5e1ab1411a63


Summary:
- Just add Vietnamese (or the language which you want to remove), then remove it again!

Hope it can help you out :)


 ---------------------
[UPDATE -20130612]
 ---------------------
 
Oh yeah, as I commented below, the above solution doesn't work, but today, finally, I got rid of it.
Actually, I almost surrendered and I have been having to stand it until today. I was starting learning Japanese, so I added Japanese Input Method to Language Bar and I got 3 entries English, Vietnamese, Japanese. The problem is using Windows+Space to switch between those 3 entries is really annoying, so I had to work my ass off on this problem once more time. And lucky me, I found this thread:

http://answers.microsoft.com/en-us/windows/forum/windows_8-desktop/remove-english-us-keyboard/16f81314-8c4f-4315-baf0-c6518449d8ae

After reading it, I took a look at my startup programs and did some "trial and error", logging in/out several times. Finally, I found out that "Unikey"  (a Vietnamese Input Method software that I was using) is the root cause of the problem, whenever it's started, it adds a Vietnamese entry to Language Bar - that sucks!

Well, I had been using Unikey for years, but at that time, I had to give it up! But then fortunately, after googling, I found another app which can do the same awesome job but DOES'T add anything to Language Bar, and it's:

http://www.trankynam.com/gotv/

I had been using that app on my Android phone, but didn't know it's also available on many other platforms, of course, includes Windows.

So... finally, after a very long time, my problem is solved completely xD

And one more thing, just a thought... that guy, TranKyNam is awesome indeed, he has a few other apps than gotv that I haven't had chances to try, but they looks cool also. I will definitely remember his name xD

20 Nov 2012

Use adb wifi without rooting for Android phones

Well, if your phone is rooted already, it's very easy to use adb without USB cables. Just go to Google Play then search for "adb wifi", you'll see several apps which can help you with your rooted phone.
But if for some reasons, you don't want or mustn't root your phone (because of the warranty or the phone is not yours...), and you hate debugging your app with the cable plugged in your phone, well, there's still a workaround for you (but it still requires to use the USB cable once or twice)

Steps:
  • Connect your Android phone with your  computer by the USB cable, and make sure you have adb and required drivers for you phone installed on your computer. Then type (this command tells adb daemon to listen over Wifi - port 5555):
  • adb tcpip 5555
  • Okay, now you can plug out your USB cable and throw it away (just kidding, you'll might need it in case you restart your phone or you pull out the battery...). Now you have to find your phone IP, go to Setting -> Wi-Fi -> Select the Wi-Fi network your phone is using, then you'll see the IP address. Now on your computer, you have to connect adb to your phone, for example, IP address of my phone is 192.168.0.101, I'll do it by this command:
  • adb connect 192.168.0.101:5555
  • Then you'll see message "connected to 192.168.0.101:5555", now your phone is connected to adb wirelessly. If you want to use adb over USB again, connect your phone to your computer then type in cmd or Terminal:
  • adb usb

That's all, good luck!

17 Nov 2012

A note about .gitignore

First of all, take a look at this page: http://gitready.com/beginner/2009/01/19/ignoring-files.html
And I'm not copying its content lol, well, this is just a note about what I've done successfully with .gitignore to ignore some folders in my project.

Steps:
  • Enter to root directory of your project, then "vi .gitignore" and enter something like:(I suppose you haven't had .gitignore in your project):
  • bin/ # ignore all folders which are named "bin"
    .settings/ # ignore all folders which are named ".settings" 

  • If there's nothing in your "bin" folders as well as ".settings" folders, your job here is done, everything you will put in those folders will not be tracked by Git. But if there's something in those folders which means Git are tracking it already, so you have to let Git know that you don't want to tracking it by these commands:
  • git rm --cached -r Your_Path/bin/
    git rm --cached -r Your_Path/.settings/
    git commit -m "Ignore folder bin and .settings"
    git push origin your_branch
    

P/S: You may doubt about removing cache then commit & push, and yeah, I did, but don't worry. Doing so just removes cache not actual files in your folders (actually I have no idea about where is cache too, but I guess it's cache of git lol), and committing & pushing just delete those folders on remote server, not on your local repository.
In short, making a ".gitignore" just tells your Git program on your computer knows that don't list changes of files in those folders when you type "git status",  and removing cache & committing & pushing just delete those folders on remote repository.