Katipo
Search  
Site Blog
  About  
  Home
About Portfolio Solutions Client Area Contact Us
: : About Us
Awards
Jobs
Our People
What Is A ... ?
Working From Home
News
Photo Gallery
Katipo Blog


Archive for September, 2008

Collecting a list of current MySQL index in a database

Thursday, September 11th, 2008

In MySQL, there is an easy way to get all index of a particular table.

SHOW INDEX FROM table_name;

But what if you want to list all index’s from all tables in a database so you can find out what you have and where you’re missing some? If you have 20 or more tables it’ll get tiring after a while running the SHOW INDEX command on each.

Thankfully, the information is stored in another table MySQL uses called information_schema. You can get a list of all the index’s, along with the table name and field names, by running the following (change “your_database”).

SELECT table_name, column_name, index_name FROM information_schema.statistics WHERE index_name != ‘primary’ and table_schema = ‘your_database’;

That’s it. A list of what table, what field, and the name that each index applied to. Happy indexing.

“and” and “or” use versus “&&” and “||” in ruby

Tuesday, September 9th, 2008

A natural inclination when one starts programming in Ruby is to use “and” and “or” instead of the “&&” and “||” to increase readability. However, “and” is not a drop in syntactic synonym with “&&” and the same goes for “or”.

James pointed out a good blog post that explains the issues around order of precedence with these operators:

http://blog.jayfields.com/2007/08/ruby-operator-precedence-of-and-which.html

It’s worth reading the comments.

It should also be noted that the Ruby on Rails source style guide has a preference for “&&” and “||”:
http://rails.lighthouseapp.com/projects/8994/source-style

Merging in single commits with Git

Monday, September 1st, 2008

Sometimes it’s useful to merge in a single commit from another branch. For instance, you may want to merge a single, important bug fix from your Git master branch into a stable release branch.

You can do this using Git’s cherry-pick command.

# Merge in a single commit.
#The -n option tells Git to not commit when it’s finished the merge.
# This allows us to review and commit the changes with our own message later.
# The default commit message is very ambiguous.
$ git cherry-pick -n [The commit's SHA-1 Hash]

# Review the changes
$ git diff –cached

# Commit the changes after reviewed them
# ..with a nice, human written commit message that makes sense.
$ git commit -a -m “Your commit message (some SHA-1 Hash as a reference)”

All done! You can then push your changes to your remote repository.


Katipo
Rachel Snowboarding