Pages

Tuesday, June 11, 2013

Monitize

I decided to try another way of monetizing this blog as well as a few other projects I have going. I signed up as an amazon affiliate and enrolled to use their product search API. I have some experience with the API already because my employer uses it. I have been fortunate enough to be given permission to use that code as a base to move forward. When I run into interesting problems, and find interesting solutions, I'll try to blog about them. In the meantime, watch for me to mention amazon products in my posts.


Thursday, March 14, 2013

Recursive Function to find substrings in a possibly multidimentional array

I needed this, and was happy enough with the results to share it.

This is like PHP in_array, but it searches for a substring.
for a one-dimensional array, it returns the key of the first match.
For a multi-dimensional array, it returns a csv list of keys to the first match.

<?php
function substr_in_array ($array, $term, $case=true )
{
//optional third argument set to false will cause case insensitive test.
// return false if the provide $array is not actually an array.
if(!is_array($array))
  {
    //echo 'Not Array';
    return false;
  }
// if $case has been set to false, make the term and each value lower case.
if(!$case)
  {
   $term=strtolower($term);
  }
    foreach ( $array as $key => $value )
    {
      if(is_array($value))
        {
           $inner=substr_in_array($value,$term,$case);
           if ($inner!==false){return $key.','.$inner;}
        }
      else
        {
        if(!$case)
          {
         $value=strtolower($value);
       }
     echo 'Actually doing the text  comparison now: is '.$term.' in '.$value.'?
'."\n";
     // if the term is found in the value, return the $key.
        if (strpos($value, $term ) !== false )
          {
            return $key;
          }
        }
    }
    return false;
}
?>

Sunday, January 27, 2013

Netbeans

I installed Netbeans on the Ubuntu laptop I mentioned in my last Blog entry.

The Ubuntu install is 12.04 so when I used the Software Center, It installed 7.0.1.

The install went well and after some adjustments to my apache settings and figuring out all the right paths, I could test a php file and it would open in my browser and the code was parsed.

I noticed an error during install that I didn't think was a big deal. Something about parsing HTML5.

Well, I was having trouble where I'd press , nothing would happen. Being new, I thought maybe I needed key combo like or something, but hadn't figured it out yet.

Then, a tutorial I was following suggested I use the palette for easy HTML creation. I dragged in a form, gave it a name and an action, clicked and nothing happend. Well, the form creation dialog box closed, but no code was added to my file.

I asked a PHP coder I know who uses NetBeans and he was not aware of any issue with the palette. Finally, I noticed an error icon at the bottom of the application. It said "java.lang.IllegalStateException: Cannot find an HtmlParser implementation for HTML5"

I let netbeans send an error report. It gave me a report ID and linked to a page full of similar reports. Some people had actually put in some comments that were similar to the problems I had. I went back to my software center and noticed that the Ubuntu netbeans install was FULL of negative reviews.
  • Unfit for distribution in its current state - Precise / 7.0.1
  • Go Download from netbeans site
  • Useless and broken
  • The Ubuntu build of netbeans is almost completley unseable. (sic)
So, I removed it, visited netbeans.org and downloaded 7.2.1
I installed it. When I ran it the first time, it recognized the settings left over from the previous install. Saved me a LOT of time setting up the application.

It now seems to work fine.

Conclusion:
If you're on Ubuntu 12.04 and want to use Netbeans, be sure to download and install the most recent version from netbeans.org

Friday, January 18, 2013

Ubuntu 12.04

I bought and old (2006) laptop from a friend for less than $100.00 and installed Ubuntu 12.04 LTS on it tonight.

I'll be testing it out and adding stuff to it. It will give me something to blog about for sure.

Just typing this made me consider that I haven't even tried to access my webserver with it yet.

Hopefully I'll have some interesting learning experiences to share here in the near future.

Monday, January 7, 2013

Site Migration

My employer has always allowed me to host my website on the company server, but because I want to continue to develop my skills not only as a coder, but as an administrator, I have decided to move it to my home server. It (tecbrat.com) now shares a box with selahsanctuary.org and it's related sites.

The only thing on the site at the moment is a single page with a paragraph about my future plans for the site. (php, mysql, web development...) and one Adsense unit that so far isn't very relevant. Guess I need more content for it to get it right.

If you're interested, check out TecBrat

I notice I got several page views on this post, and I'm afraid it might be lacking for those who find it for "site migration", so I'll try to be a little helpful here:

If you are hosted on a server running CPanel/WHM, site migration is actually pretty easy, if you're moving to another CPanel/WHM server. In CPanel, you make a full site backup. This will store all your files, databases, and even email accounts and messages. You give this file to your new host and let them take care of it. (If you have shell access, you can do it on your own, but I don't remember the exact paths and commands at the moment. Google it and it's not that difficult.)

If you don't have CPanel, then you need to maually back up at least your webroot. (www or public_html or whatever it's called in your hosting environment.) Backup any databases you have. (If you have access to phpMyadmin, it's really easy to export a database. Again, Google it and you'll find it pretty easy.)

If it's a large profitable business site, seek professional assistance.
BACKUP EVERYTHING!

With proper backups, you could fail miserably, and simply try again. Without proper backups, you could fail miserably and just be miserable.