Monday, September 16, 2013

pry - Good stuff for debugging

pry

Good stuff for debugging
https://github.com/pry/pry

install :  

gem install pry

usage:

       1. put "require pry" in front of the code.
       2. put "binding.pry" just before the line of code that needed to debug.
       3. excute the code.
       4. pry will stop at the line where you put "binding pry".
       5. try to get the value of objects, variables and methods.
       6. Ctrl-D to continue.

Saturday, September 14, 2013

The Ruby Style Guide


Ruby is fun to write.  You can write in many different forms of codes for just doing one thing. There is no rule to follow unless you find one.  The one below is a good one to follow.  I am pretty sure your life will be easier if you go for it.


Beside the guide, there is a style checker for checking codes.   It's quite easy to use, but quite naggy.

Do you use Sublime text 2?  There is a plugin for it.  Have fun.

The Ruby Style Guide


This Ruby style guide recommends best practices so that real-world Ruby programmers can write code that can be maintained by other real-world Ruby programmers. A style guide that reflects real-world usage gets used, and a style guide that holds to an ideal that has been rejected by the people it is supposed to help risks not getting used at all – no matter how good it is.RuboCop

https://github.com/bbatsov/ruby-style-guide

RuboCop


RuboCop is a Ruby code style checker based on the Ruby Style Guide.
https://github.com/bbatsov/rubocop

Sublime RuboCop

A Sublime Text plugin that runs a RuboCop check on the current file or the current project. By default it uses RVM to run RuboCop, but you can switch to rbenv or provide your own command line in the settings.
https://github.com/pderichs/sublime_rubocop

Tuesday, September 3, 2013

Initial commit

Git operations


This is the very first article of my blog about coding. It's mainly for the learning purpose of Ruby on Rails, git and github, Python and others.  I found that coding is fun, but there are many little tricks needed to be remembered. Therefore, a blog is quite suitable for this kind of thing.

Anyway, a little notes about git is as follows:

 git init                                               # initialize a git repository

 git add <filename>                  # add a file
( git add . )                        # add everything in this directory
 git commit -m "Initial Commit!"        # commit the change

 git status                                             # show status


 git rm filename                                   # remove file

git remote add origin https://github.com/username/repo's_name.git                                                                                                                   # add a remote repository at Github

git push -u origin master                    # push file to remote site                                                                                                                            # origin : remote site
                                                                     # master: local site
 SSH login:

ssh -T git@github.com                            # login using SSH key