Mittwoch, 28. November 2012

Github is a cool cat

I assume you are comitted to the coolness of GIT. Installing GIT on a Debian based Linux is easy:
$ sudo apt-get -y install git-core
There are 2 options to host the code: On your own system or on Github.
I recommend the second choice. The infrastructure is already existing and Github furthermore includes simple ticketing to assist your development process. In the end it is free (Github is THE spot for social coding).
Github is a real cool cat.
So go on by setting the default name for GIT to use when you commit:
$ git config --global user.name "Your Name Here"
Set the default email for GIT to use when you commit:
$ git config --global user.email "your_email@youremail.com"
... your email address for Git should be the same one associated with your GitHub account. The last option we need to set will tell git that you don't want to type your username and password every time you talk to a remote server. To use this option, you need to turn on the credential helper so that git will save your password in memory for some time:
$ git config --global credential.helper cache
By default git will cache your password for 15 minutes. You can change this if you like. You can set the cache to timeout after 1 hour (setting is in seconds):
$ git config --global credential.helper 'cache --timeout=3600'
That's all. Now call on Github and launch your repository.

If you need further information go to: https://help.github.com/articles/set-up-git
or sign up your Github account directly: https://github.com/signup/free

Dienstag, 27. November 2012

Simple cyclic remote link using jQuery

Create a link in the view template you want to trigger a cyclic request:
<%= link_to 'Refresh', root_path, :remote => true, 
  :class => 'auto_remote' %>
I chose the root url as destination, but it should be the route you want to call. Then add a javascript snippet in your application.js (or the js file you use in the view):
$(document).ready(function(){
    jQuery.each($('a.auto_remote'), function(){
     setInterval(function(remote_link) {
        $.ajax({ url: $(remote_link).attr('href') });
      }, 10000, this);
    });
});
In my example the request is triggered every 10th second. Supported by Ruby on Rails 3.2.8 and JQuery 1.8.3