Install RMagick gem (older version) on CentOS box

Posted in Ruby on Rails with tags on March 20, 2013 by harryche2008

If you ever run into problems installing RMagick gem (version 1.15.x etc.), try the following after you have tried everything else:

  • Create /etc/ld.so.conf.d/local.conf
  • add the following lines:/usr/lib
    /usr/local/lib
  • run ldconfig Or /sbin/ldconfig

A note on ldconfig:

/etc/ld.so.conf is the library where you set up the list of libraries to be included in the dynamic link libraries. But /etc/ld.so.conf is not the list that the kernel actually uses for a dynamic link library list. The kernel uses /etc/ld.so.cache. ldconfig is the program which takes /etc/ld.so.conf and builds /etc/ld.so.cache.

How-To create a MySQL database and set privileges to a user

Posted in Uncategorized on June 3, 2011 by harryche2008

On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:

$ mysql -u root

If a password is required, use the extra switch -p:

$ mysql -u root -p
Enter password:

Now that you are logged in, we create a database:

mysql> create database amarokdb;
Query OK, 1 row affected (0.00 sec)

We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:

mysql> grant usage on *.* to amarokuser@localhost identified by ‘amarokpasswd’;
Query OK, 0 rows affected (0.00 sec)

And finally we grant all privileges on the amarok database to this user:

mysql> grant all privileges on amarokdb.* to amarokuser@localhost ;
Query OK, 0 rows affected (0.00 sec)

And that’s it. You can now check that you can connect to the MySQL server using this command:

$ mysql -u amarokuser -p’amarokpasswd’ amarokdb
Your MySQL connection id is 12
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

How setup WordPress blog under Rails’s /public directory

Posted in wordpress on March 5, 2011 by harryche2008

1. Add a rewrite rule to both httpd.conf and /public/.htaccess file:


RewriteCond %{REQUEST_URI} ^/blog.*
RewriteRule .* - [L]

2. Switch blog url from WordPress admin and add this to /public/.htaccess:

RewriteEngine OnRewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

If you deployed your rails app using Passenger(mod_rails), you need to add this to make /blog url work:


<Location /blog>
PassengerEnabled off
</Location>

How to remove “Antivirus System Pro” spyware

Posted in Uncategorized with tags on November 15, 2009 by harryche2008

Just this morning when I browsed some sites, my computer got infected by this software program called “Antivirus System Pro”. Spent a little time and finally got rid of it. There is how:

1. Restart Windows XP in safe mode

2. Remove files named “letqsysguard.exe”, and its parent directory “nxbrrd”, or whatever it happens to end up under.

3. Launch regedit, and search for “nsarkinfo”, or just “letqsysguard.exe”, and remove any registry entries that match it.

4. Goto /Windows/system32, and remove a dll called “iehelper.dll”, which hijacks your IE browser whenever you go to a site.

5. Reboot and everything should be back to normal, hopefully.

After throught: perhaps it makes sense to disable Java engine from ever running in your browser, as that seems to be where many spywares get to your system through a web page.

Strange error in running Phusion Passenger

Posted in Ruby on Rails on November 10, 2009 by harryche2008

If you have trouble starting passenger for your Rails application, check your httpd log file, usually at /var/log/httpd/error_log for something looks like this:

*** Passenger ERROR (ext/common/ApplicationPoolServer.h:643):
Cannot execute /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/ext/apache2/ApplicationPoolServerExecutable: Permission denied (13)

The solution is to run:

setenforce Permissive

or

/usr/sbin/setenforce Permissive

You may learn more about this at http://aproxacs.blog.qrobo.com/tag/selinux/

Problem with installing Passenger (mod_rails)?

Posted in Ruby on Rails on September 3, 2009 by harryche2008

A common problem you may find when installing passenger is it can’t find the APR development headers. A quick fix worked for me is to run:

export APXS2=/usr/local/apache2/bin/apxs

then everything works just fine.

Free resources, techniques, and tips for goal setting

Posted in Uncategorized on June 21, 2009 by harryche2008

Free resources, techniques, and tips for goal setting to help you achieve all you want in life.
Visit http://www.Goal-Setting-Resources.com

How to use Permalinks on WordPress blog

Posted in wordpress on March 18, 2009 by harryche2008

Permalinks are useful for SEO purposes. To enable it:

1. In your /wp-admin page, go to Settings -> Permalinks to choose the format you want.

2. Create a .htaccess file in your wordpress root directory, and update its content with whatever wordpress instructed when you change Permalinks options.

Ruby code to convert country name to 2-letter code

Posted in Ruby on Rails on February 17, 2009 by harryche2008

You probably need this if you use Rails country_select helper for your country dropdown list. Many API requires a 2-letter country code instead of country names. Here is a piece of code can do just that:


# convert country name to country code
COUNTRY_CODES = {
'AF'=>'Afghanistan',
'AL'=>'Albania',
'DZ'=>'Algeria',
'AS'=>'American Samoa',
'AD'=>'Andorra',
'AO'=>'Angola',
'AI'=>'Anguilla',
'AQ'=>'Antarctica',
'AG'=>'Antigua And Barbuda',
'AR'=>'Argentina',
'AM'=>'Armenia',
'AW'=>'Aruba',
'AU'=>'Australia',
'AT'=>'Austria',
'AZ'=>'Azerbaijan',
'BS'=>'Bahamas',
'BH'=>'Bahrain',
'BD'=>'Bangladesh',
'BB'=>'Barbados',
'BY'=>'Belarus',
'BE'=>'Belgium',
'BZ'=>'Belize',
'BJ'=>'Benin',
'BM'=>'Bermuda',
'BT'=>'Bhutan',
'BO'=>'Bolivia',
'BA'=>'Bosnia And Herzegovina',
'BW'=>'Botswana',
'BV'=>'Bouvet Island',
'BR'=>'Brazil',
'IO'=>'British Indian Ocean Territory',
'BN'=>'Brunei',
'BG'=>'Bulgaria',
'BF'=>'Burkina Faso',
'BI'=>'Burundi',
'KH'=>'Cambodia',
'CM'=>'Cameroon',
'CA'=>'Canada',
'CV'=>'Cape Verde',
'KY'=>'Cayman Islands',
'CF'=>'Central African Republic',
'TD'=>'Chad',
'CL'=>'Chile',
'CN'=>'China',
'CX'=>'Christmas Island',
'CC'=>'Cocos (Keeling) Islands',
'CO'=>'Columbia',
'KM'=>'Comoros',
'CG'=>'Congo',
'CK'=>'Cook Islands',
'CR'=>'Costa Rica',
'CI'=>'Cote D\'Ivorie (Ivory Coast)',
'HR'=>'Croatia (Hrvatska)',
'CU'=>'Cuba',
'CY'=>'Cyprus',
'CZ'=>'Czech Republic',
'CD'=>'Democratic Republic Of Congo (Zaire)',
'DK'=>'Denmark',
'DJ'=>'Djibouti',
'DM'=>'Dominica',
'DO'=>'Dominican Republic',
'TP'=>'East Timor',
'EC'=>'Ecuador',
'EG'=>'Egypt',
'SV'=>'El Salvador',
'GQ'=>'Equatorial Guinea',
'ER'=>'Eritrea',
'EE'=>'Estonia',
'ET'=>'Ethiopia',
'FK'=>'Falkland Islands (Malvinas)',
'FO'=>'Faroe Islands',
'FJ'=>'Fiji',
'FI'=>'Finland',
'FR'=>'France',
'FX'=>'France, Metropolitan',
'GF'=>'French Guinea',
'PF'=>'French Polynesia',
'TF'=>'French Southern Territories',
'GA'=>'Gabon',
'GM'=>'Gambia',
'GE'=>'Georgia',
'DE'=>'Germany',
'GH'=>'Ghana',
'GI'=>'Gibraltar',
'GR'=>'Greece',
'GL'=>'Greenland',
'GD'=>'Grenada',
'GP'=>'Guadeloupe',
'GU'=>'Guam',
'GT'=>'Guatemala',
'GN'=>'Guinea',
'GW'=>'Guinea-Bissau',
'GY'=>'Guyana',
'HT'=>'Haiti',
'HM'=>'Heard And McDonald Islands',
'HN'=>'Honduras',
'HK'=>'Hong Kong',
'HU'=>'Hungary',
'IS'=>'Iceland',
'IN'=>'India',
'ID'=>'Indonesia',
'IR'=>'Iran',
'IQ'=>'Iraq',
'IE'=>'Ireland',
'IL'=>'Israel',
'IT'=>'Italy',
'JM'=>'Jamaica',
'JP'=>'Japan',
'JO'=>'Jordan',
'KZ'=>'Kazakhstan',
'KE'=>'Kenya',
'KI'=>'Kiribati',
'KW'=>'Kuwait',
'KG'=>'Kyrgyzstan',
'LA'=>'Laos',
'LV'=>'Latvia',
'LB'=>'Lebanon',
'LS'=>'Lesotho',
'LR'=>'Liberia',
'LY'=>'Libya',
'LI'=>'Liechtenstein',
'LT'=>'Lithuania',
'LU'=>'Luxembourg',
'MO'=>'Macau',
'MK'=>'Macedonia',
'MG'=>'Madagascar',
'MW'=>'Malawi',
'MY'=>'Malaysia',
'MV'=>'Maldives',
'ML'=>'Mali',
'MT'=>'Malta',
'MH'=>'Marshall Islands',
'MQ'=>'Martinique',
'MR'=>'Mauritania',
'MU'=>'Mauritius',
'YT'=>'Mayotte',
'MX'=>'Mexico',
'FM'=>'Micronesia',
'MD'=>'Moldova',
'MC'=>'Monaco',
'MN'=>'Mongolia',
'MS'=>'Montserrat',
'MA'=>'Morocco',
'MZ'=>'Mozambique',
'MM'=>'Myanmar (Burma)',
'NA'=>'Namibia',
'NR'=>'Nauru',
'NP'=>'Nepal',
'NL'=>'Netherlands',
'AN'=>'Netherlands Antilles',
'NC'=>'New Caledonia',
'NZ'=>'New Zealand',
'NI'=>'Nicaragua',
'NE'=>'Niger',
'NG'=>'Nigeria',
'NU'=>'Niue',
'NF'=>'Norfolk Island',
'KP'=>'North Korea',
'MP'=>'Northern Mariana Islands',
'NO'=>'Norway',
'OM'=>'Oman',
'PK'=>'Pakistan',
'PW'=>'Palau',
'PA'=>'Panama',
'PG'=>'Papua New Guinea',
'PY'=>'Paraguay',
'PE'=>'Peru',
'PH'=>'Philippines',
'PN'=>'Pitcairn',
'PL'=>'Poland',
'PT'=>'Portugal',
'PR'=>'Puerto Rico',
'QA'=>'Qatar',
'RE'=>'Reunion',
'RO'=>'Romania',
'RU'=>'Russia',
'RW'=>'Rwanda',
'SH'=>'Saint Helena',
'KN'=>'Saint Kitts And Nevis',
'LC'=>'Saint Lucia',
'PM'=>'Saint Pierre And Miquelon',
'VC'=>'Saint Vincent And The Grenadines',
'SM'=>'San Marino',
'ST'=>'Sao Tome And Principe',
'SA'=>'Saudi Arabia',
'SN'=>'Senegal',
'SC'=>'Seychelles',
'SL'=>'Sierra Leone',
'SG'=>'Singapore',
'SK'=>'Slovak Republic',
'SI'=>'Slovenia',
'SB'=>'Solomon Islands',
'SO'=>'Somalia',
'ZA'=>'South Africa',
'GS'=>'South Georgia And South Sandwich Islands',
'KR'=>'South Korea',
'ES'=>'Spain',
'LK'=>'Sri Lanka',
'SD'=>'Sudan',
'SR'=>'Suriname',
'SJ'=>'Svalbard And Jan Mayen',
'SZ'=>'Swaziland',
'SE'=>'Sweden',
'CH'=>'Switzerland',
'SY'=>'Syria',
'TW'=>'Taiwan',
'TJ'=>'Tajikistan',
'TZ'=>'Tanzania',
'TH'=>'Thailand',
'TG'=>'Togo',
'TK'=>'Tokelau',
'TO'=>'Tonga',
'TT'=>'Trinidad And Tobago',
'TN'=>'Tunisia',
'TR'=>'Turkey',
'TM'=>'Turkmenistan',
'TC'=>'Turks And Caicos Islands',
'TV'=>'Tuvalu',
'UG'=>'Uganda',
'UA'=>'Ukraine',
'AE'=>'United Arab Emirates',
'UK'=>'United Kingdom',
'US'=>'United States',
'UM'=>'United States Minor Outlying Islands',
'UY'=>'Uruguay',
'UZ'=>'Uzbekistan',
'VU'=>'Vanuatu',
'VA'=>'Vatican City (Holy See)',
'VE'=>'Venezuela',
'VN'=>'Vietnam',
'VG'=>'Virgin Islands (British)',
'VI'=>'Virgin Islands (US)',
'WF'=>'Wallis And Futuna Islands',
'EH'=>'Western Sahara',
'WS'=>'Western Samoa',
'YE'=>'Yemen',
'YU'=>'Yugoslavia',
'ZM'=>'Zambia',
'ZW'=>'Zimbabwe'
}

class String
  def to_country_code
    COUNTRY_CODES.index(self)
  end

end

 

WordPress fix for “Error establishing a database connection”

Posted in Uncategorized with tags on January 27, 2009 by harryche2008

If you have googled everywhere and tried everything, still not working, try this:

change “localhost” to “127.0.0.1”.

It worked for me.