Free resources, techniques, and tips for goal setting to help you achieve all you want in life.
Visit http://www.Goal-Setting-Resources.com
Free resources, techniques, and tips for goal setting
Posted in Uncategorized on June 21, 2009 by harryche2008How to use Permalinks on WordPress blog
Posted in wordpress on March 18, 2009 by harryche2008Permalinks 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 harryche2008You 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 wordpress on January 27, 2009 by harryche2008If you have googled everywhere and tried everything, still not working, try this:
change “localhost” to “127.0.0.1″.
It worked for me.
Attachment fu’s “Size is not in the list” problem
Posted in Uncategorized on December 23, 2008 by harryche2008The fix is to specify :min_size config for has_attachment call:
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 10.megabytes,
:min_size => 0.kilobytes,
:resize_to => ‘320×320>’,
:thumbnails => { :thumb => ‘126×126>’ }
How to make absolute positioning work correctly
Posted in CSS and Ajax on December 13, 2008 by harryche2008Absolute position is a very convenient way to align and postion elements within a div section, such as navigation tabs in a header, etc. However, one must remember to specify the containing block’s position property to make it really work.
For example, this is the code for my navigation menus inside a header div, my intention was to put nav tabs at the bottom right of the header box:
<div id="header">
<ul id="nav-tabs">
<li><a href="/">Home</a></li>
<li><a href="/">Page1</a></li>
<li><a href="/">Page2</a></li>
</ul>
</div>
And now my css looks like this:
div#header {
margin: 0 auto
width: 900px;
height: 120px;
background: url(/images/header-background.gif) repeat-x;
}
ul#nav-tabs {
position: absolute;
bottom: 2px; right: 0px;
height: 41px;
}
Notice I used “position: absolute” for the nav tabs <ul> tag, but it didn’t work, for it showed up at the bottom right of the whole screen, not within just the header.
The fix is to add “position: relative” to the div#header style, then it all works just as expected.
Hope that helps if you have the same problem with absolute positioning.
Never insert comments in ERB code
Posted in Ruby on Rails on October 31, 2008 by harryche2008Never insert comments in ERB code in one line, such as:
<% if somecode # my comment… %>
If you have more stuff after this line, it will be all ignored by rails, causing many problems.
How to Add an IP address for Non-SUSE Linux
Posted in System Admin with tags IP address on October 9, 2008 by harryche2008These are the steps to add the second IP address to your existing network adapter under non-SUSE distributions of Linux.
- Become root on your system, either by logging into that account or using the su command.
- Change your current directory to the /etc/sysconfig/network-scripts directory with the command:
cd /etc/sysconfig/network-scripts - Check for existing network adapters with the command:
ls ifcfg-*In most instances, you will see the files ifcfg-eth0 and ifcfg-lo. If you see other files with any other names and are unfamiliar with configuring TCP/IP, you may want to consult with your system administrator before proceeding or contact support@oclc.org.
- Edit /etc/hosts and add a line for your new address and name such as:
24.249.162.195 ezproxy.yourlib.org - To create the new interface, you will copy ifcfg-eth0 to ifcfg-eth0:0 with the command:
cp ifcfg-eth0 ifcfg-eth0:0Next, edit icfg-eth0:0 and change the DEVICE line to be similar to:
DEVICE=eth0:0and change the IPADDR line to be similiar to:
IPADDR=24.249.162.195 - To activate the new IP address, issue a command similar to:
./ifup eth0:0
How to add initial files of RSpec for a new project
Posted in Ruby on Rails with tags rspec on September 10, 2008 by harryche2008Follow these steps and you will have a basic skeleton of rspec workspace:
rails stuff
cd stuff
ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec
ruby script/plugin install svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails
script/generate rspec
script/generate rspec_scaffold Thing name:string
How to fix “no file to load …” errors when installing Substruct shopping cart code
Posted in Uncategorized on August 26, 2008 by harryche2008If you’re using substruct, and installing the code following the installation directions given on its website, you may run into problems like “no file to load xxx” errors when trying to initialize the databases by running:
rake substruct:db:bootstrap
The problem is that some of the files that come along with the source have wrong file extention names, like ../extract_options.rb0000644, which really should be ../extract_options.rb, without those weird numbers. I don’t know how it got in there. But once you corrected those file names, then everything should be fine.