Archive for Mac OS X

How to quickly import/export MySQL database scripts

# Export MySQL Database Script

mysqldump -uroot -p db_name_1 > dump_name.sql

# Import MySQL Database Script

mysql -uroot -p db_name_2 < dump_name.sql

Importing a MySQL database script (.sql) will potentially overwrite data!  (That’s what it’s supposed to do.)  Make sure you know that what you’re doing is safe!-)

Done!

How to install RESTful Authentication on a Ruby on Rails 2.0 application

It’s time to upgrade your Rails 2.0 application with user authentication, and we hear that RESTful Authentication is the way to go, but all the instructions out there (even on the plugin repository sites) are out of date or don’t completely work or only work on Rails 1.2.x.  In this tutorial, however, we’ll go step-by-step to install a complete RESTful authentication suite with all the trimmings your advanced Rails 2.0 application requires.  Best of all, we’ll maintain complete source control of our user administration code.

Please note that the code in this tutorial is borrowed from a railsforum.com post by a very smart user named “activefx”.  activefx has miraculously put together his research on Rick Olson’s brilliant restful_authentication plugin to create a pretty robust user authentication process.  This post is just a bit more tailored for my Rails MVC+ architectural approach, which is to 1) install my plugins (if any), 2) use the Rails generators to generate the resources I think I’ll need, 3) generate my database migrations, add 4) my models (and library modules, if any), then 5) my controllers, and finally 6) my views.  This tutorial has also been reorganized and optimized for quick availability to copy and paste into new Ruby on Rails projects.

Read the rest of this entry »

What are the Unix shell commands for handling user administration?

Here’s a quick cheat-sheet for Unix user administration from the command line terminal. Make sure you are logged in as “root” user for these, or enter “sudo -i” for root user access.

Read the rest of this entry »

How to verify an MD5 checksum on Mac OS X

MessageDigest5 (MD5) checksums provide a way for you to confirm the integrity of files you download or copy. The MD5 algorithm takes a file as input and outputs a highly unique fingerprint message digest.  To confirm file integrity, use an MD5 utility on your computer to calculate your own MD5 message digest for files downloaded from a web site or copied from a directory on a computer.  If your calculated MD5 checksum matches the original, you can be assured your file is intact and probably not “corrupt”.  MD5 utilities are available for Windows and Linux and Mac. Most Linux installations provide an md5sum command for calculating MD5 message digests.  Here are the simple steps on a Mac system:

  1. Open a Terminal window (navigate to /Applications/Utilities/Terminal.app)
  2. Type: “md5 ” (md5 followed by a space).
  3. Drag the downloaded file you want to check from the Finder into the Terminal window.
  4. Click in the Terminal window and press the Return key to run the command.
  5. Compare this locally-generated checksum to the source checksum.  If it’s a match, the files are a match!