Friday, December 24, 2010

R.drawable cannot be resolved

I'm jumping into Android head first and wanted to make a button that when I press it, it trigger's a notification on the notification bar at the top of the screen.  I was browsing through the documentation and ran into this error.

If you look at the Android Notification Documentation example, you'll notice this line in step 2: int icon = R.drawable.notification_icon;. If you use their example in a tutorial you'll find that this icon doesn't exist and you can't compile your app.  The reason for this is that there is no notification_icon image that exists within /res/drawable-*/.  By default, icon.png exists within these directories.  If you change the notification_icon to icon it will work fine.

Friday, December 10, 2010

PHPMyAdmin error: Unable to change master

I experienced this error while trying to utilize PHPMyAdmin to setup a replication process where an Amazon RDS instance was the slave and my master was my dedicated server.  The issue here is that the connection was made successfully but that I do not have permission to adjust the slave/master status of the RDS instance.  Amazon has confirmed that this is the case.  That's unfortunate, I was hoping it would ease our transition to Amazon's services.

The error that PHPMyAdmin returned was "Unable to change master"

How to remotely manage an Amazon RDS instance with PHPMyAdmin

The biggest thing I was considering with Amazon Relational Database Service was how to manage it. A command line interface is NOT efficient for database management so I needed to be sure that I would be able to utilize software on my computer to manage my data.  PHPMyAdmin was my software of choice.  It supports multiple servers and has pretty much everything I need.

So what does it take to get everything up and running? First, signup for Amazon RDS and get your instance up and running.  Amazon's RDS Getting Started Guide is a great resource and I'd highly recommend it.  The one thing I had trouble with was the DB Security Group setup.  When you go to add access for an CIDR/IP it provides a recommended value.  It took some messing around to determine that this default value isn't actually what needed to be there.  If you're not able to connect to your instance when it's all said and done, be sure to double check this value.  The IP they provided did not match the IP address that was provided to us by our ISP.  Once you've created your DB Instance and setup the security group you're good to go.

I'm going to assume you've already got PHPMyAdmin up and running.  What you need to do is modify to recognize the new server.  Your config file should look something like this:

/* Configure according to dbconfig-common if enabled */
if (!empty($dbname)) {
    /* Authentication type */
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'changeme';
    $cfg['Servers'][$i]['hide_db'] = '(mysql|information_schema|phpmyadmin)';
    /* Server parameters */
    if (empty($dbserver)) $dbserver = 'localhost';
    $cfg['Servers'][$i]['host'] = $dbserver;

    if (!empty($dbport)) {
        $cfg['Servers'][$i]['connect_type'] = 'tcp';
        $cfg['Servers'][$i]['port'] = $dbport;
    //$cfg['Servers'][$i]['compress'] = false;
    /* Select mysqli if your server has it */
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    /* Optional: User for advanced features */
    //$cfg['Servers'][$i]['controluser'] = $dbuser;
    //$cfg['Servers'][$i]['controlpass'] = $dbpass;
    /* Optional: Advanced phpMyAdmin features */
    $cfg['Servers'][$i]['pmadb'] = $dbname;
    $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
    $cfg['Servers'][$i]['relation'] = 'pma_relation';
    $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
    $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
    $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
    $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
    $cfg['Servers'][$i]['history'] = 'pma_history';
    $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

    /* Uncomment the following to enable logging in to passwordless accounts,
     * after taking note of the associated security risks. */
    // $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

    /* Advance to next server for rest of config */

PHPMyAdmin uses $cfg['Servers'][$i] so that it can support multiple servers on one installation.  Having more than 1 server will give you the option to select a server when you login.  After that last } you'll want to add the following code, but of course with your own Amazon RDS instance URL.

$cfg['Servers'][$i]['auth_type'] = 'HTTP';
    $cfg['Servers'][$i]['hide_db'] = '(mysql|information_schema|phpmyadmin)';
    /* Server parameters */
    $cfg['Servers'][$i]['host'] = '';

You're ready to go, simply refresh your PHPMyAdmin page if you're already logged in and you'll see the new server.

Remember, if you have trouble connecting, your IP/Permissions must be wrong!

Monday, July 12, 2010

Free EIN / Tax ID Search

I was looking online for a free EIN / Tax ID search and kept coming up with paid results.  There are 2 problems with paid results.

  1. It's not free
  2. It's not the government's web site, so it's likely not accurate for newer businesses
The solution is to get it directly from here:

Another great benefit here is that you can link directly to a search via the search results URL:

Simply replace the EIN1 and EIN2 variables in the URL from 1's to whatever the Tax ID is that you're looking up.

Thursday, March 25, 2010

Setting up a local virtual server in Linux

If you're like me, then you design web sites on your local server before pushing the update out to the site.  I tend to take and make my local server http://domain/.  This allows me to fully test and run the site just as it runs on the server, but without the lag/extra steps with working on the server itself, not to mention my changes don't effect the visitor's experience until I push the update.

To do this, go to:


It will look like this:       localhost

You need to update this file so your browser knows to look locally for the domain.  Add a line for your domain name...       domain
OR       domain2.loc

Next you need to tell apache about your new domain. Go to /etc/apache2/sites-available/ and create a file for your new domain. Since my new domain is literally "domain" that's what I will call my file, with no file extension. Within that file I'll put this....

NameVirtualHost domain:80

<VirtualHost domain:80>
ServerName domain
DocumentRoot /var/www/domain/

Once you've got this setup you're good to go. All you need to do is restart apache...

/etc/init.d/apache2 restart

Now I can access this local domain by simply typing http://domain/ and it won't effect the users browsing my site.

Wednesday, March 24, 2010

Internet Explorer (IE) and image/pjpeg, what's that all about?

I had a user report to me today that jpg image uploads were not functioning. I had him send me the images so that I could try uploading them to my site. They worked just fine. So what's the problem? Some genius over at Microsoft decided that instead of using image/jpeg as the mime type for JPG's they would use image/pjpeg.

If you're checking mime types for your image uploads, be sure to include image/pjpeg in the list or you'll find yourself dealing with bug reports.

Tuesday, March 16, 2010

Server Load Average and what to do about it

To take a look at your load average, to your server's command line and type "top" and it'll show you the top processes your server is running.

I was going to write up some descriptions on this as my research continued, but I found the perfect source. So rather than rewrite it the guide and try to explain things I don't have an expert's opinion on, I'm going to forward to a real source, that knows what they're talking about.

Understanding Linux CPU Load - when should you be worried?

Wednesday, March 10, 2010

Determine if PHP file is being access via Cron

I ran into an issue where I needed to determine which config settings to load in my API. It picks up automatically whether I'm working locally or on the server. It kept loading the local configuration based on my code. So I asked some smarter people for some assistance and was given the right answer. This will determine whether it's being loaded via command line.

if (php_sapi_name() == 'cli') {
    return true;
} else {
    return false;