40% off your First Order with GoDaddy.com!

Dec 30, 2009

MySQL: MySQL Password Reset


Are you looking at this page because you cannot access the mysql server installed on your pc/server when you were trying to see if it works well? Or do you receive error messages like the following?
ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)

To resolve this problem ,a fast and always working way is the "Password Resetting".


Following this procedure, you will disable access control on the MySQL server. All connexions will have a root access. It is a good thing to unplug your server from the network or at least disable remote access.

To reset your mysqld password just follow these instructions :

Stop the mysql demon process using this command:
sudo /etc/init.d/mysql stop

Start the mysqld demon process using the --skip-grant-tables option with this command:
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &

start the mysql client process using this command:
mysql -u root

from the mysql prompt execute this command to reset/update your password:
SET PASSWORD FOR root@'localhost' = PASSWORD('password');

Dec 27, 2009

Linux: "dstat" Tool of the day

What is dstat? dstat is a versatile replacement for vmstat, iostat and ifstat.

Dstat allows you to view all of your system resources instantly. Eg, You can compare disk usage in combination with interrupts from your HDD controller, or compare the network bandwidth numbers directly with the disk throughput (in the same interval).

No blog post pimping a cool tool would be complete without the obligatory screen shot.

Customers for Life

Never Worry About Money Again
What is the purpose of a business? Every time I ask this question during a business seminar, the immediate answer that I get back is, "To make a profit."

The Real Purpose of A Business
But this answer is wrong. The purpose of a business is to create and keep a customer. If a business successfully creates and keeps customers in a cost-effective way, it will make a profit while continuing to survive and thrive. If, for any reason, a business fails to attract or sustain a sufficient number of customers, it will experience losses. Too many losses will lead to the demise of the enterprise.

Why Businesses Fail
According to Dun and Bradstreet, the single, most important reason for the failure of businesses in America is lack of sales. And, of course, this refers to resales as well as initial sales.

So your company's job is to create and keep a customer, and your job is exactly the same. Remember, no matter what your official title is, you are a salesperson for yourself and your company. And the best way to increase your value as a salesperson is to build your customer base.

Why Businesses Succeed
The two most important words to keep in mind in developing a successful customer base are Positioning and Differentiation.

Positioning refers to the way your customers think and talk about you and your company when you are not there. The position that you hold in the customer's mind determines all of his reactions and interactions with you. Your position determines whether or not your customer buys, whether he buys again and whether he refers others to you. Everything that you do with regard to your customer affects the way your customer thinks about you.

The Key to Competitive Advantage
Differentiation refers to your ability to separate yourself and your product or service from that of your competitors. And it is the key to building and maintaining a competitive advantage. This is the advantage that you and your company have over your competitors in the same marketplace - the unique and special benefits that no one else can give your customer.

Select Your Customers Carefully
When you begin to think about acquiring and keeping customers for life, you need to think about the particular types of customers for whom your competitive advantage is so important that they would be poorly served by using anyone else's product. You need to then emphasize again and again that the special features and benefits you offer are so important that they should not even think of going somewhere else. If, for any reason, you fail to do this, you may lose the customer and all the work you've done in building that relationship in the first place.

Dec 21, 2009

SEO: Tips is about Metatags understanding

Build a website or blog is not just posting article and leave it, in fact you need some help from search engine to make it famous and being rank well.

Today, most webmaster and blog owner is trying to learn as much as they can about SEO (Search engine optimization). It's difficult do deal with seo?

According to the new SEO blog that focus on learn SEO for beginner, explain that optimizing a website is about meta tags or html code structure.

The objective is manage the site to get index in major search engine lick yahoo, google and msn. beside meta tags we need to play around keyword and the most important is content for sure.

Dec 20, 2009

Unix: Filesystem hierarchy in Unix/Linux/OS X

Although it is one of the first chapters one read when starting with Linux/Unix, it is always confusing where should we put what when it comes to installing stuff on Linux/OS X computers.

I found a detailed reference Filesystem Hierarchy standard website.

Rails: Clearing Out Old Sessions

I got into the habit a while ago of setting up my websites to use ActiveRecord as a session store, this means that the session information for all the visitors to my website is placed in a table in my database. This may or may not be the best way to store sessions but it’s certainly faster than the filesystem and my VPS doesn’t really have the memory capacity for an ‘in memory’ store.

Anyway, one day I decided to perform some DB maintenance, check tables where okay etc, upon logging into the DB however I noticed that my sessions table had grown quite large as was coming up to 125,000 records, little did I realize that the sessions are persisted forever in the DB.

I didn’t think it was the best idea to keep all the session data so wrote the following script and put it in 'lib/tasks/session.rake':

This gave me a ‘session:prune’ rake task. The task removes all sessions older than 1 day from the sessions table. I then added a CRON job for in the following format:
  • 0 0 * * * cd /home/user/railsapp && rake RAILS_ENV=production session:prune > /dev/null 2>&1

The job above basically calls the ‘session:prune’ rake task at midnight every night.

The code in the task in MySQL specific but without a model representing the session table I couldn’t (or at least couldn’t think of a way) to make the code any more ruby-fied. In the event that you do have, or decide to create a session model the following code may work in your task (warning: untested);
Session.destroy_all("created_at" < (Time.now - 1.day))

Hope the above snippet solves at least one of your ActiveRecord session woes.

Pump Up Your Profits

There is a truism that 50 percent of advertising is wasted, but no one ever knows for sure which 50 percent it is. As a result, advertising budgets always seem higher than necessary. This problem persists in many areas of business today. Money is being wasted, but no one is exactly sure where and how it is happening.

Low Profits or No Profits
Many companies today are earning low profits or no profits because their costs of doing business are not coordinated with their sales. Many products and services are priced by people who are completely unaware of the real costs involved in bringing these products or services to the market. These mistakes in pricing are then buried in the overall operations and general revenues of the business.

Conduct a Profit Analysis on Every Product
One of the most important parts of the Turbostrategy process is for you to conduct a complete profit analysis on each product or service you sell. Very few companies have ever done this. But when you begin applying profit analysis in your company, you can often increase your profits dramatically.

High-Volume vs. High Profit Customers
As you examine these numbers, you will find that, in many cases, your biggest customers are not your most profitable customers, and your biggest selling products or services are not your most profitable ones either. You may find that your costs of doing business with some customers and with some products are so high that it is hardly worth the investment of people are resources. This can only be determined by taking a hard look at the numbers.

Focus on Cash Flow
You need to be your own turnaround specialist all the time, and most especially when business slows for any reason. To pump up your profits, you do a complete profit analysis on your business and move immediately to focus the energies of the company on those areas that represent the very best sources of net cash. This process requires that you continually analyze your business so that you know exactly the profitability of every product or service you sell in comparison with every other product or service you sell, right down to the penny.

From Most to Least Profitable
The fact is that with a little effort, every single product or service can be organized on a scale from the most profitable to the least profitable, both on a per item or per hour basis, and in net dollar amounts. There is always one that is more profitable than any other.

Determine Profitability
You begin your profit analysis by determining the exact gross sales revenues that you receive from a product or service after all subtractions for defects, returns, breakage, loss, wastage, and bad debts. Take every single deduction so that your gross dollar amount is completely accurate, and you are crystal-clear about the exact amount you are netting from sales.

Face the Bitter Truth
You will probably find that fully half of your product and service offerings are generating very little profit or even causing you to lose money with every sale. A turnaround specialist would immediately either raise the prices of the low-profit items or discontinue them altogether. You must do the same.

Dec 19, 2009

Cocktail: Strawberry Margarita

The Strawberry Margarita is possibly the most popular of the flavored Margarita varieties. This is understandable because it is delicious frozen cocktail. Given that it is blended, many people choose to go with frozen strawberries. While they do make a fine drink, a far superior cocktail can be find by starting with fresh strawberries, especially when they are in the prime season. Plus when you go with fresh you have leftovers for a quick and tasty garnish.

  • 1 1/2 oz tequila
  • 1 oz triple sec
  • 1 oz lime juice
  • 1/2 cup strawberries
  • 1 cup ice
  • fresh strawberry for garnish

  • Pour the ingredients into a blender.
  • Blend until smooth.
  • Pour the contents into a chilled margarita glass.
  • Garnish with a strawberry.

MySQL: Check If Table Exists

How to check if a table exists in the current MySQL database, through running a simple query.

Python: Check Credit Card "checksum"

The CardChecksum function returns 1 for valid cards and 0 for invalid cards, after performing a check using the Luhn algorithm which validates all major credit cards.

Python: Find the Greatest Common Divisor

Implement the Euclidean algorithm into a Python function in order to calculate the largest common divisor of two numbers.

Dec 18, 2009

Ubuntu: Install Thunderbird 3.0 on Ubuntu 9.10 (Karmic)

Mozilla’s email client Thunderbird 3 was released just a few days back. In the release page, however only the .tar file was available for Linux. In this post we will show you how to install Thunderbird 3 in Ubuntu 9.10 from the Mozilla PPA.

Add the Mozilla PPA in your source list using:
sudo add-apt-repository ppa:ubuntu-mozilla-daily/ppa

Update source list using:
sudo apt-get update

Install Thunderbird 3 using:
sudo apt-get install thunderbird-3.0

Dec 16, 2009

Ruby: Write A PDF File Using Ruby

Using the open source PDF::Writer library for Ruby to create PDF documents on the fly and save them on the server.

Ubuntu: Install Openshot on Ubuntu 9.10 (Karmic)

Openshot is a video editor for linux, is one of the best ones existing actually for linux. The news is that now has a PPA this mean easy install for Ubuntu users, but the big news is that the new version come with 30 new effects.

Add the OpenShot PPA in your source list using:
sudo add-apt-repository ppa:openshot.devellopers/ppa

Update source list using:
sudo apt-get update

Install OpenShot using:
sudo apt-get install openshot

Dec 15, 2009

Rails: Passenger versus safe_erb

Today I had some fun tracking down a weird problem with safe_erb. While everything worked fine running Mongrel in development mode, safe_erb complained about outputting tainted strings for every link generated by Rails’ link_to and URL helpers running on mod_rails in production mode.

Some digging around led me to the root of the problem - in production my app needs to live inside a subdirectory and so I used Passengers RailsBaseURI directive to tell it so. The value configured this way ends up tainted in AbstractRequest’s relative_url_root for some reason, which in turn makes every URL generated by Rails tainted.


This untaints the relative_url_root value if it matches the regexp. Place into application.rb or some file that is required during application startup to fix the problem. I’m still not sure whether this is a bug and if so, whose bug it is - should (if possible at all) mod_rails untaint this value in the first place, or is it a bug with Rails not escaping something somewhere?

The fact that URLs used with Rails’ form helpers didn’t yield safe_erb errors, but those supplied to link_to did makes me think that there’s at least some inconsistency in the way URLs are treated by Rails’ helpers.

Dec 13, 2009

Review Your Flight Options

Once you have become clear about who you are, what you want, and what your true goals are in each area of your life, you can begin to evaluate all the different routes by which you can reach your destination. Now you can determine the strategies and tactics that you can use to achieve your goals and arrive at your destination on schedule.

Develop Options Continually
One of the most important rules that I have ever learned is this: You are only as free as your well-developed options. Before you can plan your time and your life, you must be absolutely clear about both the hourly rate that you are earning today and the hourly rate that you want to earn in the future. Every hour that you spend on a low-value or no-value activity is costing you $25, $50, or more.

Determine the Highest and Best Use of Your Time
Whatever job you choose to take, company you choose to make with your money, or time you choose to spend on a particular activity, think it through carefully in advance and be certain that you are making the highest and best use of your time and resources.

Refuse to Settle
Abraham Maslow once wrote, "The story of the human race is the story of men and women selling themselves short." Many people, because of fear and timidity, settle for far less than they are truly capable of achieving. They stay in jobs they don't like. They stay in relationships that don't make them happy. They invest their money in things they don't understand and leave their money there long after they realize they've made a mistake. If you are not satisfied with any part of your life, with your current seat selection, remember that you can always pay a price to be free.

Ask for What You Want
In business and in your personal life, remember that every term or condition that you are ever offered has been decided by someone and can be changed by someone else. Whether this involves the pay and conditions of a job, the terms of a contract, the costs of products or services, rental or lease rates of offices or equipment, or bank terms for loans of credit, if you are not happy for any reason, don't be reluctant to ask for something different.

Cast a Wide Net
The rule with ideas is this: Quality is a function of quantity. This means that the more ways you achieve your goal that you consider before you embark on your journey, the better will be the quality of the choice you make. Cast a wide net. Don't fall in love with the first idea that occurs to you. You must continually remind yourself that emotions distort evaluations. This means that the more emotional you become about a course of action at the beginning, the less able you will be to make the best decisions and determine the best way to reach your destination.

Cocktail: Tequila Fuego

Traditional Mexican flavors highlight your favorite premium tequila in this spicy shot. Serves one.

  • 1 1/2 oz premium tequila
  • 1 teaspoon hot chile sauce
  • 1 teaspoon lime juice
  • 1 dash onion powder
  • 1 lime wedge
  • kosher salt
  • 1 jalapeno ring

Use lime wedge to moisten 1/2 the brim of the shooter glass. Dip the moistened brim in salt. In a shaker or a glass, mix the lime juice, tequila, onion powder and hot chile sauce. Blend well. Pour the mixture into the shot glass and garnish the edge with a jalapeno ring.

Follow the shot with the lime wedge.

Dec 9, 2009

Ruby: Extended Euclidean Algorithm Function

A function for finding the modular multiplicative inverse, based on an extended version of the Euclidean algorithm.

Dec 7, 2009

Mounting an ISO Image as a Filesystem

This is great, if you don’t have the DVD hardware, but need to get the data.
The following show an example of mounting the Fedora core 7 DVD as a file.

# mkdir /iso
# mount -o loop -t iso9660 /FC7-i386-DVD.iso /iso

Or to mount automatically at boot, add the following to “/etc/fstab”

/FC7-i386-DVD.iso /iso iso9660 ro,loop 0 0

Dec 6, 2009

Become Everything You Are Capable of Becoming

The turning point in my life came when I discovered the law of cause and effect, the great law of the universe, and human destiny. I learned that everything happens for a reason. I discovered that success is not an accident. Failure is not an accident, either. I also discovered that people who are successful in any area usually are those who have learned the cause-and-effect relationship between what they want and how to get it.

Determine Your Personal Growth and Development Values
To realize your full potential for personal and professional growth and development, begin with your values as they apply to your own abilities. As you know, your values are expressed in your words and actions.

You can tell what your values are by looking at what you do and how you respond to the world around you. Your values are the root causes of your motivations and your behaviors.

Clarify Your Personal Growth and Development Vision
Create a long-term vision for yourself in the area of personal growth. Project forward five or ten years and imagine that you are developed fully in every important part of your life. Idealize and see yourself as outstanding in every respect. Refuse to compromise on your personal dreams.

Set Goals for Your Personal Growth and Development
Now take your vision and crystallize it into specific goals. Here is a good way to start. Take out a piece of paper and write down ten goals that you would like to achieve in the area of personal and professional development in the months and years ahead. Write in the present tense, exactly as if you were already the person you intend to be.

Determine exactly what you want to be able to do. Decide who you want to become. Describe exactly what you will look like when you become truly excellent in your field and in your personal life.

Upgrade Your Personal Knowledge and Skills
Set specific measures for each of your goals. If your goal is to excel in your field, determine how you will know when you have achieved it. Decide how you can measure your progress and evaluate your success.

Perhaps you can use as a measure the number of hours you study in your field each week. Perhaps you can measure the number of books you read or the number of audio programs you listen to. Perhaps you could measure your progress by the number of sales you make as the result of your growing skills.

Develop Winning Personal Growth and Development Habits
Select the specific habits and behaviors you will need to practice every day to become the person you want to become. These could be the habits of clarity, planning, thoroughness, studiousness, hard work, determination, and persistence.

Cocktail: Refreshing Lime Margaritas

Perfect on a hot summer day or an evening with friends. You’ll make this recipe over and over again!

  • 1 oz tequila
  • 1/2 oz Triple Sec
  • 1 oz lime juice, fresh squeezed
  • 1/2 teaspoon Sugar
  • kosher Salt (optional)
  • lime wedge (optional)
  • crushed ice or ice cubes

If you’re going to salt the glass, take your lime wedge or a bit of triple sec and rub around edge of glass. Turn upside down and press rim into salt.

For the drink- Shake the tequila, triple sec, lime juice and sugar in a shaker (or stir vigorously with a spoon) and pour over ice. Or you can blend it in a blender if you prefer it. Garnish with lime wedge and enjoy!

Dec 2, 2009

Ruby: Strip HTML tags using Ruby

The StripHtml function strips all the HTML tags in the passed string but preserves the ones specified in the PreserveTags array.