Salient Digital Techno Blog

Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • Facebook Facial Recognition Fail

    Posted on June 15th, 2011 phpguru No comments

    Facebook recently upgraded it’s image upload feature to include facial recognition.

    The idea is, when you upload pictures that contain your friends, Facebook can help you tag the photos by identifying facial features.

    I recently uploaded a gallery of flower photos I shot when my wife and I visited Kula Botanical Gardens in Maui, Hawaii. I laughed when I got this screen and I thought you might enjoy seeing why.

  • Kohana 3.x in 10 Minutes

    Posted on June 11th, 2011 phpguru No comments

    Prerequisites:

    This guide assumes you have already completed:

    So you have a LAMP/MAMP/XAMPP stack? Great!

    Now we’re ready to create our first Kohana project.

    1. Download the source from www.KohanaFramework.org
    2. Extract the zip file and move the directory it to your  web directory
      1. On Mac OS X: ~/Sites/* (subsequent references will use Mac notation)
      2. On Windows (wamp): C:/wamp/www/*
      3. On Linux (varies): /var/www/*
    3. Rename the directory to kohanasite.dev
      1. Remember the full path to this now
      2. something like /Users/yourname/Sites/kohanasite.dev
    4. Create an htdocs directory inside this directory
      1. Your hdtocs will be at the same level as Kohana folders application, modules and system.
      2. Remember the full path to this now
      3. something like /Users/yourname/Sites/kohanasite.dev/htdocs
    5. Drag index.php into the htdocs directory
    6. Edit 3 lines of index.php
      1. where it says $application = ‘application’; change it to $application = ‘../application’;
      2. where it says $modules = ‘modules’; change it to $modules = ‘../modules’;
      3. where it says $system = ‘system’; change it to $system = ‘../system’;
      4. save and close
    7. chmod or chown application/cache and application/logs to be writable by Apache
      1. open terminal, and cd to your application directory
        cd /Users/your-name/Sites/kohanasite.dev/htdocs
      2. chmod the two directories
        chmod 0777 cache && chmod 0777 cache
      3. or chown it to apache, wheel, www-data or whoever owns httpd process (ps aux | grep httpd)
    8. Create a VirtualHost entry in your Apache config.
      1. Depending on your install, this might be in httpd.conf or…
      2. on my Mac it’s at /private/etc/apache2/extra/httpd-vhosts.conf
      3. E.g.
        sudo vi /private/etc/apache2/extra/httpd-vhosts.conf
        NameVirtualHost *:80
        <VirtualHost *:80>
        ServerName kohanasite.dev
        DocumentRoot "/Users/your-username-here/Sites/kohanasite.dev/htdocs"
        </VirtualHost>
      4. save and quit (type :wq and hit enter)
    9. Edit your hosts file to point to this site locally
      1. E.g.
        sudo vi /etc/hosts
        127.0.0.1   kohanasite.dev
      2. save and quit (:wq)
    10. Restart Apache
      1. sudo apachectl restart
    11. Move example.htaccess to htdocs and rename it to .htaccess
      1. Note, because it’s a “dot file” it will disappear on a Mac, so use terminal:
        mv ../example.htaccess .htaccess
    12. Now test your site at http://kohanasite.dev
      1. It should say Hello World!

    Congratulations! You now have Kohana 3.1 running locally.

    Finishing up…

    Let’s enable some of the modules that come with Kohana 3.x

    1. Open up application/bootstrap.php
    2. Scroll down to the modules section
    3. Enable the following modules by removing the double slash in front of the module name:
      1. auth
      2. cache
      3. codebench
      4. database
      5. orm
      6. userguide
    4. Save the bootstrap file and refresh your browser to make sure you still get hello world

     

    Next up… How to build a simple CMS using Kohana.

  • Apache, PHP and MySQL in 10 Minutes

    Posted on June 11th, 2011 phpguru No comments

    Whether you want to start developing web applications for the first time, you’re wanting to make better use of your local computer or a virtual machine to streamline development, create a development or staging server, or just checking back as a reference for a new platform, welcome to…

    Apache, PHP and MySQL in 10 Minutes

    In this guide you will find the resources needed to build a web development environment on the platform of your choice

    1. Choose Your Platform – Mac, Windows or Linux.
      1. Mac OS X Instructions
        1. Easy - Using MAMP
        2. Intermediate - Using built-in Apple Apache
      2. Windows Instructions
        1. Install WampServer
        2. Install XAMPP
      3. Linux Instructions
        1. Install LAMP stack on CentOS/RHEL
        2. Install LAMP stack on Debian/Ubuntu
        3. Install LAMP stack on Fedora
        4. Install LAMP stack on OpenSUSE
        5. Install LAMP stack on ArchLinux
      4. CPanel
        1. CPanel comes with Apache & PHP already installed, so here’s how to customize your install
        2. Note – make sure your config comes with WHM (Web Host Manager)
        3. Many ISPs call this a Reseller account
        4. How to use the EasyApache script
      5. Plesk
        1. Plesk comes with Apache & PHP already installed, so here’s how to customize your configuration
        2. Parallels Plesk Apache Configuration Guide
    2. Install any PHP Extensions you might need
      1. The one PHP extension that Kohana requires you that doesn’t come by default (See Kohana 3.1 in 5 minutes) is mcrypt:
      1. Pluging mcrypt into OS X
      2. Enabling mcrypt under WampServer
      3. Install mcrypt for php under Linux
      4. Install mcrypt under CPanel
    3. How to create a VirtualHost
      1. Find your Apache Config file
      2. Find your Apache VirtualHost config file
      3. Sample VirtualHost container
      4. <VirtualHost *:80>
        ServerName website.dev
        DocumentRoot "/Users/username/Sites/website.com"
        </VirtualHost>
      5. More from the Apache VirtualHost documentation
    4. How to edit your hosts file
      1. hosts file information
    5. Start Apache
      1. Start Apache
        1. Mac OS X:
          1. Terminal
            1. sudo apachectl start
          2. or start Web Sharing in System Preferences
        2. Windows
          1. WampServer – start all services using the taskbar tray icon
        3. Linux
          1. Debian/Ubuntu
            1. sudo /etc/init.d/apache2 [start | stop | restart ]
          2. Fedora
            1. service httpd [start | stop | restart]
          3. ArchLinux
            1. /etc/rc.d/httpd restart
          4. OpenSUSE
            1. apachectl [start | stop | restart]
    6. Test your install
      1. Go to http://localhost in your browser
      2. Are you seeing the Apache start page?
      3. If so, you are done. Congratulations! You just installed a web server.
    7. Install MySQL
      1. Mac OS X
        1. Installing MySQL on OS X
      2. Windows
        1. Installing MySQL on Windows
      3. Linux
        1. Installing from a binary
        2. Build MySQL 5.5 from source

     

    Now that you have a development environment, why not install a fantastic web development framework, such as Kohana.

    Ready for round two? Kohana 3.1 in 10 Minutes

  • Git Resources for Subversion Users

    Posted on June 11th, 2011 phpguru No comments

    I’ve been using Subversion for years, but lately I’ve been thinking it’s time to get into Git more. Plus, A lot of new GUI tools are out there and some of the older ones are still there, too, so maybe Git has matured enough for production use.

    Why would I want to use Git?
    Flavio sums it up quite nicely:

    What’re the advantages?
    Since Git is a distributed revision control system (while svn is a centralized one) you can perform commits, branches, merges… on your local working directory without being connected to internet. Next time you’ll be online, you will be able to “push” your changes back to the central svn server.

    In a tech video from Facebook, one of the things they mention is that their developers us Git on local workstations for managing changes, and Facebook overall uses Subversion for managing the source tree centrally. I thought it was interesting that Facebook, one of the most advanced, largest and high-powered software applications on the planet, uses both Git and Subversion. Here’s an article about Using Git and Subversion Together.

    I’ll be posting links to the resources I find here.

    Three Part Intro to Git Series

    1-2 hours • First, take the Git Crash Course.

    2-4 hours • Next, read Git for Subversion Users, Part I and Git for Subversion Users, Part 2. These two articles at IBM.com give you a really good overview of the main differences between Subversion and Git.

    4-6 hours • Finally, you should read Pro Git. This is an awesome free online book about Git.

    After you complete these you should be a total Git.

  • Laser Projection Keyboard for iPad, Mobile Devices a Cruel Hoax?

    Posted on May 10th, 2011 phpguru 2 comments

    If you’re looking for a projection keyboard that uses a laser to project an image of a keyboard onto any flat surface, I was too, so I did some digging. Below are my (disappointing) findings.

    Here’s a YouTube video from CES.

    One of the comments on the YouTube page for this video says, in part,

    This is yet an unproven technology. It has no corrective Artificial Intelligence to correct your mistakes as you type. Try the Cellulon keyboard and you will find it frustrating to type, unusable and seriously flawed. You will end up writting garble after garble. They seriously need to work on a fix. Don’t buy this overpriced fail of keyboard.

    Dang it! What a cool concept. Maybe it was too good to be true. These devices appear to be mysteriously unavailable. In fact, most of the information is from 2008-2010. Why is it that nobody appears to be selling the coolest thing ever? Maybe it’s a bunch of hype or they went back to the drawing board to get the concept working better.

    Think Geek says

    $149.99
    Out of stock ( no ETA available )

    This random site looks too cheesy to buy from.

    The Celluon Laserkey CL800BT on Amazon says

    Currently unavailable.
    We don’t know when or if this item will be back in stock.

    Google has a few stores listed, but at $2,500+? Hmm, now this is just strange.

    Does anyone have one of these devices?

    Are these cruel hoaxes from some April 1 news release or are newer, better models coming out soon to an Android, iPhone, iPad or your favorite 4G Tablet coming out any time soon?

    I think someone needs to get to the bottom of this.

  • How to install Memcached Memcache PHP on OS X

    Posted on May 9th, 2011 phpguru No comments

    This Guide is the best resource I’ve found yet. I had to also look up how to fix pear installation errors.

     

  • Infinite Starlight: A Thought Experiment

    Posted on May 5th, 2011 phpguru 2 comments

    Albert Einstein, a patent clerk in Bern, performed what are now called “Thought Experiments”. He was born in 1879 and received the Nobel Price in Physics in 1922. So, he was just 42. What makes Einstein’s story so unique is that he wasn’t classically trained in physics.

    Like Einstein, I’m also not an astrophysicist, but the topic of stars, space and astronomy has always intrigued me. I’ve always thought it would be interesting to come up with my own thought experiment, and I think I finally have one.

    When I look around at the world around me, I find the level of detail in the cosmos utterly mind boggling. The farther you zoom in, the more and more detail you see. It’s almost infinite.

    Most of us with even a basic science or astronomy class know what a star is: a gigantic ball of burning hydrogen in the void of space. Carl Sagan described the universe most simply and profoundly: 100 billion galaxies each with 100 billion stars. That’s an incredibly large number of stars to be sure, but it’s not infinite, I think we could all agree on that.

    My theory is that the amount of energy a star has is infinite, and it gives off an infinite amount of energy at all times. I know that sounds crazy. Impossible. There must be a limit, although very large. But nothing is truly infinite, right? So this brings about a paradox then, and I would love to understand it fully.

    For this thought experiment, though, let’s talk about just one star, any star. Look up in the night sky and pick a star, and gaze at it. Which star you pick is irrelevant.

    How about Betelgeuse, a red supergiant, Orian’s shoulder in the constellation of Orion. You see that bright star, one of the brightest in the heavens? Good. Walk around your back yard (be careful in the dark) and pause and look up again. Still see the Orion’s shoulder? Yep. Go down the street a ways. Yep, you can still see Betelgeuse. No matter where you walk, and look up, you can still see that star. Go to the other side of the world (stick to the same hemisphere, consult a star map, etc.) — somewhere and sometime that Orion is visible. Arizona in the spring, for example.

    The point is, no matter where you look, there’s Orion and Betelgeuse. No matter where you go, light from that star is hitting your retina. If the moon ever goes in front of Orion, the light that would’ve hit your retina is instead going to hit the dark side of the moon. Technically, Betelgeuse casts a shadow on earth when the moon passes in front of it (when the moon casts a shadow on earth from our own star, it’s an eclipse.) Still, had the moon not been in the way, you could’ve seen the light that was destined for your retina.

    Theoretically, you could travel to another star in a different constellation, and assuming you could keep track of where you are in relation to Betelgeuse, you could land on an earth-like planet orbiting around a different star, and look up, and see Betelgeuse from that vantage point, too.

    The point of all of this is to visualize more clearly the way that light expands outward from a star.

    Time divides infitely. How many moments are in between the start of the big bang and now? How many nanoseconds are inside of a second? We use the term nanosecond today because that’s the thinnest sliver of time we can measure with modern technology. But any mathematical scholar will tell you that you can always take half of something, or a quarter, or an eighth or sixteenth – we can increase the denominator all the way to ∞. So how many 1/∞ths of a second are in a minute? ∞. How many 1/∞ths of a nanosecond are in a billion years? ∞ of them.

    Angles divide infinitely, too. How many angles are in between 0° and 90°? For example, an arcsecond is 1/3600th of a degree. But how many photons fit into an arcsecond? The farther away you go from the origin of the angle, the easier that is to measure, right, because the angle is getting wider. But how can it work that way? If you think about it for a moment, you’ll have to realize that there are ∞ angles which are each 1/∞th of one degree in size, in between any two other vectors that converge at a point.

    We can describe this expansion of light from a star as an ever-enlarging spherical volume. You can think of a sun as a huge beachball factory releasing an ∞ number of beachballs every 1/∞th of a moment. The edge of each beachball is a photon ready to hit any eyeball that might be gazing upward to see it.

    We proffered before that angles are infinitely divisible. To think about this some more, lets say you had a Sharpie marker and a beach ball, and you started drawing black dots on the beach ball and counting up how many dots it took to color the beach ball 100% black, at some point way in the future, the ball would be totally black and you would have a number of dots recorded which represented how many sharpie marker dots fit on the surface of the sphere. Now switch to a razor fine-point pen. Obviously it would take a lot more fine-point dots to cover the ball than the larger dots made by the sharpie marker, but it should still be possible to turn the ball black and record the number of fine-point razor dots it took to color the ball completely black.

    How does that apply to starlight? Well, we described before the way light expands out from the source star as being an expanding sphere. If we imagine the light expansion edge-horizon as a huge beachball, then we can imagine that for every photon-width point on the edge of the light-sphere, as as well as for every place inside the volume of the light sphere, at any moment in time there has to be at least one photon there, had our eye been in that exact spot to observe it. In other words, if you could have ∞ eyeballs from ∞ imaginary people all forming a circle (sphere) around Betelgeuse, then every single one of the ∞ eyeballs would get hit by a photon.

    That brings us to the width of a photon. If a photon has a width, which I’m fairly sure it does, then there should be a finite number of photons required to draw the light sphere. Or, if the width and height of a photon is 0, then it would take ∞ photons to cover the edge of an arbitrary light sphere some time/distance from the star. So let’s call the width of a photon, ƒ. I’m not sure what the equation would be, but I think we would all agree that if ƒ is > 0 then some finite quantity of photons would be required to ensure that any eyeball pointed towards the source would receive a photon.

    The farther away you go from the star, the wider the ∞ angles become. In other words, if you go 1 billion light years away from the source, then you’re on the edge of a light sphere whose radius is 1 billion light years. We can focus on two arbitrary photons next together at this distance. If a photon has a width, ƒ, and we choose two photons π and ∂ which are next together, their combined width is 2ƒ.

    What happens if we go another 1 billion light years farther away to 2 billion light years away from the source, parallel to π’s original trajectory. At twice the distance, isn’t the number of ƒ-width photons needed to cover the light-sphere equal to twice the number of photons required to cover the light sphere at 1 billion light years? If photons have a width ƒ > 0 then would it be correct or incorrect to assume that only a finite number of photos could fit around the edge of the star, during every 1/∞th moment in time since the star started burning?

    So, either stars have an infinite amount of energy, or something special about the speed of light (faster than light communication?) enables photons to be a wave (no energy required?) until they are observed (photon created at moment of observation). Since I think any sane person would argue that there is no possible way for a star to possess infinite energy, then there are clearly some things I am missing.

     

     

     

  • How to Install PHP 5.3 on CentOS 5.5

    Posted on April 22nd, 2011 phpguru No comments

    Awesome – I found two different RPMs, try your luck with both:

    How to Upgrade or Install PHP 5.3 on CentOS 5.5 at Mokonamodoki (IUS RPMs)

    or

    PHP 5.3 on CentOS 5.5 at Webtatic (Webtatic RPMs)

    The install command I ended up using (IUS) was:

    yum install php53u.x86_64 php53u-bcmath.x86_64 php53u-cli.x86_64 \
    php53u-common.x86_64 php53u-dba.x86_64 php53u-devel.x86_64 \
    php53u-gd.x86_64 php53u-imap.x86_64 php53u-intl.x86_64 \
    php53u-mbstring.x86_64 php53u-mcrypt.x86_64 php53u-mysql.x86_64 \
    php53u-pdo.x86_64 php53u-pear.noarch php53u-pecl-apc.x86_64 \
    php53u-pecl-memcache.x86_64 php53u-pecl-xdebug.x86_64 \
    php53u-process.x86_64 php53u-pspell.x86_64 php53u-snmp.x86_64 \
    php53u-soap.x86_64 php53u-suhosin.x86_64 php53u-xml.x86_64 \
    php53u-xmlrpc.x86_64

    MySQL 5.1 and MySQL 5.5 on CentOS 5.5 at Webtatic (Webtatic RPMs)

    If you need to do any maintenance on the existing software, packages and repos you might find these links helpful also:

    RPM-cheat-sheet

    How to Add a New YUM Repository

    How to Use Yum

    How to Edit IPTables

    ius/stable/Redhat/5.5/x86_64/

    ius/stable/Redhat/5/x86_64/repoview/

  • How to install an SSL certificate on CentOS for Apache

    Posted on March 19th, 2011 phpguru 4 comments

    Getting Apache to serve up pages over a secure connection requires a little bit of configuration.

    If you want to use a self-signed certificate, you may want to look here.

    Step 1. Make sure you have openssl and mod_ssl installed on your CentOS server.

    yum install openssl mod_ssl

    Step 2. Make sure Apache is configured to load the mod_ssl module. In my case, in /etc/httpd/conf/httpd.conf it says:

    Include conf.d/*.conf

    This little line of code is how the file /etc/httpd/conf.d/ssl.conf gets loaded. The SSL configuration file for Apache is where I ended up putting the configurations for my server.

    Step 3. Now we’re ready to generate a CSR – Certificate Signing Request. This is something unique to your specific server that you use to generate a CRT (actual SSL certificate file) from your SSL vendor of choice. Note that this process could require several hours or days, along with email confirmations from your domain’s technical or administrative contact.

    This page on the CentOS wiki gives you a great overview of the process. But after I tried that, GoDaddy complained that it needed a 2048-bit CSR. So this page showed me how to generate the CSR with a 2048-bit key:

    openssl req -nodes -newkey rsa:2048 -keyout your-domain-name.key -out your-domain-name.csr

    Now of course you will be replacing your-domain-name with the exact domain name (or subdomain if applicable). By default, using openssl on the command line generates files in the current working directory, but you can pass in the full pathnames if you want, too.

    cat /path/to/your-domain-name.csr

    Step 4. Copy and paste that mess into your SSL vendor’s ‘Paste CSR’ step of SSL Cert activation. This process varies wildly by SSL vendor, and also the level of security of SSL you purchased. Be warned that SSL Certificate authorization emails may be sent to the administrative and technical contacts on file with the domain registrar, too, so this process can take up to a few days.

    Step 5. Once your SSL certificate is generated, you can download it from your SSL vendor and upload it to your server. If you’re using GoDaddy you’ll need the gd_bundle.crt file too.

    Step 6. Now that you have your key, SSL Cert (.crt file) and the ca bundle (Certificate Authority) you have to edit the http.conf or ssl.conf file for Apache to know where to load the certificate files. This is how my ssl.conf looks

    SSLCertificateFile /etc/pki/tls/certs/your-domain-name.crt
    SSLCertificateKeyFile /etc/pki/tls/private/your-domain-name.key
    
    SSLCACertificateFile /etc/pki/tls/certs/gd_bundle.crt

    Step 7. Use apachectl to do a syntax check on the config files

    apachectl -t
    syntax OK

    Step 8. Fix any typos you made, and finally start or restart Apache:

    apachectl restart

    At this point you might get excited and try accessing your website at https:// for the first time, but on many configurations, the odds are port 443 is blocked by default. If you get a long connection or timeouts, that’s probably your issue too. So it may be necessary to open port 443 with iptables like this post shows. I found the second one worked

    iptables -I INPUT -p tcp -m state --state NEW,ESTABLISHED --dport 443 -j ACCEPT
    Hopefully this helped you.
  • 3-D Rendered Musical Instruments

    Posted on March 16th, 2011 phpguru No comments

    I have to credit this post to my brother.

    We both received an email forward from our uncle about an unbelievable musical instrument created using “John Deere” parts. Well, we have both seen 3D-rendered musical instruments, and that got him searching for more over his lunch break.

    Called “Resonant Chamber”

    http://www.youtube.com/watch?v=toXNVbvFXyk&feature=relmfu

    Called “Drum machine Set”

    http://www.youtube.com/watch?v=af3w8LornUY&feature=relmfu

    Called “5 Minute Countdown”

    http://www.youtube.com/watch?v=vgE0m5C5PCc&feature=relmfu

    Called “Pipe Dream Set” – This is basically showing you the construction of the John Deere movie.

    http://www.youtube.com/watch?v=SLf2nsZ9m9o&feature=relmfu

    I’d send more, but lunch is over.  WOW!!