Bit of Random

If you can Imagine It You can Build It

0 notes

Wow groupon stepping up their game to acquire new users. Is it worth it for me to create new accounts and refer myself?? Very tempting 

Wow groupon stepping up their game to acquire new users. Is it worth it for me to create new accounts and refer myself?? Very tempting 

0 notes

I am switching to VIM

For my Rails development, I have been using TextMate to code. TextMate is a lightweight IDE and has some powerful commands, although I am not taking full advantage of all the snippets.  One thing I realized about TextMate is that I end up using the mouse a lot which can be somewhat distracting when I am in the zone, so I have been wanting to switch to an editor that uses the mouse less like emac or vi. 

Today I randomly came across an old post from Yehuda Katz Everyone Who Tried to Convince Me to use Vim was Wrong. The article made me want to give vim another chance. Vi is not the problem because I used it back in the IBM intern days when I had to work on AIX and Solaris machines (ie no mouse), so I know the vi commands well, but the problem is I don’t know how to manage projects through vim. After reading the article, I learned that to make vim useful, I need to install plugins like NERDTree and Command-T. These plugins will transform vim into a useful project manager. 

Then this evening I met Steve at Ruby Hackfest who uses vim to code. I asked him for tips using vim and he told me that I should fork his project to get all his vim config files. What a lifesaver this is, cloning his project and then running ./setup automatically installed all the useful vim plugins. I recommend anyone who is transitioning or beginning to use vim to make use of this setup. This will save you a lot of time looking for the right plugins and setting up the environment. 

Update: My friend Jacques just told me about https://github.com/carlhuda/janus seems very promising. I am going to give that a shot. 

I am excited that I can now code without making use of the mouse, this is going to be fun. 

Additional References:

1. http://www.catonmat.net/blog/vim-plugins-nerdtree-vim  #Good to have plugins

2. http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html #Vim graphical cheatsheet

3. http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know #100 useful command

8 notes

Mobile Authentication with xAuth & Rails 3

We are creating a mobile application for our site and one question I have is, how do I tie in the current web authentication with the mobile app. We also want the ability to remember the user on the device after they have successfully logged in. I spent time researching on the issue and I saw multiple implementations approach, but a handful of them stored the plaintext username/password on the phone itself. 

                           

I didn’t like the idea of storing a user’s plaintext password on the phone. If someone wants to remain logged in on the website, we use a session cookie to remember it, so what can we do for an app? The answer is xAuth.

Read more …

Filed under rails xauth code

0 notes

Company lunch hour. At CityPockets, we only go to places that has a voucher.

Company lunch hour. At CityPockets, we only go to places that has a voucher.

16 notes

Making will_paginate Ajaxable in Rails 3

will_paginate is a handy rails plugin to manage pagination in a Rails application. I had a request to make pagination be ajaxable, that means that when a user clicks on one of the page links, instead of refreshing the entire screen, only the results section will be refreshed.

With the introduction of unobtrusive javascript in Rails 3, ajax can be achieved by inserting the attribute data-remote = “true” on the form or link element. Remember to also add the proper code in the controller to handle the xhr request.  A good introduction on Rails 3 & Ajax can be found here or here

To make will_paginate ajaxable, we need to modify the code that generates the page links. There’s an article on Seb’s weblog that shows what needs to be done, but somehow after following it, it still didn’t make the page links ajaxable.

Instead, I created my own RemoteLinkRender class with the following code

 

So now calling will_paginate in the view 

generates the following html markup

where the links are all ajaxable. 

Filed under rails html ajax