Latest Updates: ruby RSS

  • Articles

    DZone Refcardz for software developers

    Stii 3:50 pm on June 22, 2009 | Comments: 2 Permalink | Reply
    Tags: , , , , refcardz, references, ruby

    DZone is a social bookmarking service specifically focused on technology and software development. It is a fantastic resource. Recently they released a fantastic new service called Refcardz which is like shortcut reference documents for various programming languages or technologies. Best of all, it is FREE!

    DZone Refcardz

    From languages like PHP, Ruby, Groovy and Java all the way through to Apache and High Scalability explained. All that is required is that you must be a registered DZone member and you can download the documents for free. There is over 50 reference documents, so it is well worth the effort.

    Welcome back! You should subscribe to my RSS feed here.
    You should follow me on Twitter here
    You should follow me on Gatorpeeps here.

    Save Cape Town City Ballet
     
  • Articles

    Java is Groovy and Groovy is Java

    Stii 10:02 pm on May 21, 2009 | Comments: 11 Permalink | Reply
    Tags: , , , ruby

    groovy_transparentgroovy |ˈgroōvē|
    adjective ( groovier , grooviest ) informal dated or humorous
    fashionable and exciting : sporting a groovy new haircut.
    enjoyable and excellent : he played all the remarkably groovy guitar parts himself.

    That is as defined in my beloved and trusted Mac Dictionary. I have to do a little Java project soon. Not because I want to, because I HAVE to for Afrigator. Don’t get me wrong, I think Java is great and powerful. I have a healthy dose of respect for it. Problem is, I’ve never done anything remotely formal in Java. The only experience I have with it was when I checked it out about 6 years ago. Safe to say, I’m a n00b.

    The problem is that I’m quite busy these days. Time and energy is not much for attempting learning a mammoth like Java.

    Hello, Groovy! Groovy is a dynamic language specifically for the Java platform. Groovy is built for the JVM, making it easy for Java to integrate with Groovy vice versa. In Netbeans, they went a far as not even having an option to create a Groovy project. You create a normal Java project and then add Groovy classes to it. That is how tightly it seems integrated, which is good news for a n00b like me :)

    The syntax itself seems very close to that of Ruby. Lets look at these examples (from the excellent article by Gerald Bauer – Groooooovy Babe: Jazzing Up Plain Old Java)

    Here is some Java code

    import java.util.*;
    
    public class HelloWorld
    {
      public static void main( String args[] )
      {
         List country = new ArrayList();
         country.add( "Canada" );
         country.add( "Austria" );
         country.add( "Brazil" );
    
         Collections.sort( country );
    
         for( Iterator it = country.iterator(); it.hasNext() )
            System.out.println( "Hello " + it.next() );
      }
    }
    

    The same in Groovy ( note the code reduction compared to Java :) )

    country = [ 'Canada', 'Austria', 'Brazil' ]
    country.sort
    country.each { println "Hello ${it}" }
    

    And in Ruby

    country = [ 'Canada', 'Austria', 'Brazil' ]
    country.sort
    country.each { |country| puts "Hello #{country}" }
    

    To top it all off, they even have their own Rails-like web framework called Grails (Groovy on Rails). I’ll check that out in due time.

    All in all, Groovy feels much more comfortable and familiar to me. I’m looking forward to this little challenge and will probably write about it as I go along. Aslam Khan assured me that it is solid and he even have some Groovy code out there in the wild in production which is comforting! That and knowing someone who is an expert to ask for advice when the going gets rough, since I’m fairly sure it will get rough due to n00bn3ss!

    Save Cape Town City Ballet
     
  • Articles

    Fabric, Capistrano in Python

    Stii 4:27 pm on November 24, 2008 | Comments: 1 Permalink | Reply
    Tags: , , , ruby

    FabricIf you still use FTP or SCP or sFTP to deploy projects, you’re missing out big time on the ease of either Ruby’s Capistrano or Python’s Fabric. Capistrano is almost synonymous with Ruby on Rails, though it is simple to setup with any project. We at Afrigator uses Capistrano to deploy changes to the staging server and to the live servers. It is specially handy if you have to deploy to a cluster of servers. In short, it allows you to execute commands on a remote server(s). For example, you can set it up so that it backs up your files before the deployment or do something and simple and trivial as a directory listing.

    Capistrano

    Today I came across Fabric, which is a Python version of Capistrano. Now, for the record, my use of Capistrano has been limited. I use it for what I need it. Nothing more. What I’m trying to say is I didn’t go into a very advanced setup of Capistrano, so I’m not really qualified to say which is better. On the Fabric page it says:

    It is a bit like a dumbed down Capistrano, except it’s in Python

    I like it. Its simple and it is easier than Capistrano IMHO. In the end, it comes down to which tool suits you best! Capistrano does support commits and rollbacks which, by the looks of it, Fabric don’t.

    Setting up Capistrano was painless. All I had to do was

    sudo gem install capistrano
    

    Fabric had a few dependency issues, which I had to meet first before I could

    sudo easy_install Fabric
    

    It was looking for pycrypto which I had to install before I could setup Fabric.

    Once installed, using it is as straight forward as Capistrano. All you need to do is to create a fabfile which is a simple python file which holds all the config options and commands to execute remotely. The syntax is plain and simple and clean. Here is a simple example executing a directory listing on a remote server:

    def listing():
        "Outputs a directory listing on the remote server."
        set(fab_user = 'stii')
        set(fab_hosts = ['stii.co.za'])
        run('ls -l /usr/bin')
    

    Simple. Apart from the run command to execute remote queries, there are also a sudo (execute remote commands as a privileged user), local (execute commands on your local machine) and put (upload files to the remote servers) which is very handy.

    I’m going to use it a bit more and would give you more feedback in a while. If you want, you can check it out!

    Update: Here is an example of how to upgrade WordPress using Python Fabric

    Save Cape Town City Ballet
     

About Me

Software developer at Afrigator.com Love Python, do PHP.
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
esc
cancel