No Network Icons, Internet Still Working

So, I ran into some very bizarre Windows networking behavior the other day, and thought I’d share both the experience and remedy.

My intent was to install a USB wireless adapter for the purpose of cleaning one more wire off my desk. Due to the fact that the extremely generic and cheapo nature of the USB wireless adapter, finding the correct drivers was a chore. Once the right ones were located, I had to go remove the previously installed, incorrect driver for the adapter. Lo and behold, I came to notice something very quirky about this particular Windows installation. Both my ethernet and wireless adapters were viewable in the Device Manager, however neither had an icon under “adapter settings” in the Network Center. All manner of obvious tricks were not working: winsock reset, removing all drivers and allowing for auto detection, etc. From my cursory research, this problem usually went hand in hand with loss of network activity and ultimately, access to the internet; this was not the case, as I was using the same computer to research a solution. I was able to locate a registry fix on Windows 7 Forums thread that seemed to do the trick for me:

  1. Run regedit
  2. Locate the following registry key: HKEY_LOCAL-MACHINE\SYSTEM\CurrentControlSet\Control\Network
  3. Right click and select ‘Export’ to back up the entire key
  4. Expand ‘Network’ and then delete the ‘Config’ entry. DO NOT DELETE THE ENTIRE ‘NETWORK’ KEY!
  5. Restart the computer, the ‘Config’ entry will be reconstructed on reboot

Change the Behavior of the Home and End Keys on OS X

Something I find very peculiar when I amwas working on my Mac machines is the default behavior of the home and end keys on the OS X operating system. When I’m pages deep in code and the quirky behavior is forgotten about, pressing home and having it jump to the very beginning of the document is quite the shock. Needless to say, after this happened repeatedly, it was time to find a cure.

I was very happy to find that you can remap the keys simply by creating and/or editing a keybinding dictionary file (described here, found here) located in your user’s Library directory.

So, without further adieu, create or open the file ~/Library/KeyBindings/DefaultKeyBinding.dict and append the following:

{
/* Remap Home / End to be correct */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
}

The Long Lost Skype Plugin For Pidgin

After perusing the internet for a suitable Skype plugin for Pidgin, it was much to my dismay to discover that the website the download was supposed to be available from, eion.robbmob.com, was unavailable. So, after scouring the world wide web some more, I was able to locate the original file name and then a mirror that was still up. So, without further adieu, below is the Skype4Pidgin installer.

Download skype4pidgin-installer.exe

PS: Skype4Pidgin is open source.

PHP Cannot Connect to MySQL (Error 13) But CLI Can

Sometimes More often than not, quirky things happens when initially setting up a server environment. Usually, this quirks tend to arise when getting the various components of your stack talking to each other. In this situation, PHP and MySQL have been properly configured, however a problem has presented itself: the command line interface to PHP is connecting to MySQL just fine, however when testing the connection via a script run from a web browser, it results in the error:

Could not connect: Can't connect to MySQL server on 'MYSQL.SERVER' (13)

This particular problem popped up on a CentOS 5.8 server, however this annoyance can be experienced on a number of systems, as it has to do with the default network security behavior of SELinux, which does not allow connections from HTTP to MySQL. You can allow this behavior by running the following command:

setsebool -P httpd_can_network_connect_db=1

Alternatively, you can disable SELinux entirely; that’s a tutorial for another day, though.

Update Ruby to 1.9.3 in OS X Lion 10.7.3

It’s really quite simple, as annoying (possibly daunting, too) as it may seem. You don’t need Homebrew, although you can do it that way if you would like. Here’s the nitty gritty, just open up a Terminal window and follow along.

Install RVM (Ruby Version Manager)
curl -L get.rvm.io | bash -s stable

If you have any other Terminal windows open, use the below command in each open window at this point, replacing username with your actual username:
source /Users/username/.rvm/scripts/rvm

Install Ruby 1.9.3
rvm install 1.9.3

Run Ruby with the version flag to double check our work.
ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]

Reset FileMaker Server 8 Admin Password

In situations where the administrative bus factor was one and you are not privy to the FileMaker Server (FileMaker Server 8, that is) administrator password, fret not! You are in luck, it is indeed possible to circumvent this protection. I cannot stress enough that this is not common practice and falls into the category of “database server open heart surgery” … do not attempt this if you are unfamiliar with the unix command line or the OS X architecture.

Make sure any and all FileMaker Pro users are disconnected before attempting this process.

Step #1 – Back up the existing FileMaker Server .plist file

sudo cp /Library/FileMaker\ Server/Library/Preferences/ByHost/com.filemaker.fmserver.MACADDRESS.plist ~

Replace MACADDRESS with your computer’s MAC address. Alternative, you can list the directory to see what .plist yours might be:

sudo ls /Library/FileMaker\ Server/Library/Preferences/ByHost/

Step #2 – Edit the .plist file and save as new .plist file

Using a .plist editor, remove the ‘AdminAuth’ key and value completely. When done, save the updated .plist as a new file, I chose new.plist in this example.

Step #3 – Forcefully shut down the FileMaker Server

This is not a recommended way to shut down your FileMaker database, as it could cause corruption, especially if the database is actively being used. Please make sure to have a recent backup before attempting this step.

Use ps aux | grep FileMaker to find the process id of fmserverd, then kill it:

kill PROCESSID

Step #4 – Update the .plist file FileMaker Server uses for configuration

sudo cp ~/new.plist /Library/FileMaker\ Server/Library/Preferences/ByHost/com.filemaker.fmserver.MACADDRESS.plist
sudo chown fmserver:fmsadmin /Library/FileMaker\ Server/Library/Preferences/ByHost/com.filemaker.fmserver.MACADDRESS.plist

Step #5 – Reboot the FileMaker Server machine

Reboot the FileMaker Server machine and when FileMaker Server automatically launches, it will no longer require an administrator password. Use fmsadmin or a GUI administration tool to log in and set a password to resecure the FileMaker database.

Setting Up A LAMP Stack on Debian Squeeze

As it’s mostly for the sake of my own posterity, I’m going to be extremely concise with this walk through on setting up a LAMP stack on the Debian Linux distribution, specifically, Debian 6.0 (Squeeze).

Note: All commands are from root’s perspective, as we’ll be setting up users for each of the sites. Further note that this tutorial does not encompass jailing users to their home directory.

Step #1 Installing Apache2
apt-get install apache2
Optionally, enable mod_rewrite using ‘a2enmod’
a2enmode rewrite

Step #2 Configure an Apache2 Virtual Host
Create a new sites-available configuration file for apache2.
vi /etc/apache2/sites-available/mysite.com
Enter the following contents (modify the details for the site you are setting up) into said file:
<VirtualHost *:80>
ServerAdmin info@mysite.com
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /srv/www/mysite.com/public_html
ErrorLog /srv/www/mysite.com/logs/error.log
CustomLog /srv/www/mysite.com/logs/access.log combined
</VirtualHost>

Step #3 Create the appropriate directories
mkdir -p /srv/www/mysite.com/public_html
mkdir /srv/www/mysite.com/logs

Step #4 Enable apache2 site using ‘a2ensite’
a2ensite mysite.com
To disable a website, use the command ‘a2dissite’

Step #5 Install and configure the MySQL server
apt-get install mysql-server
Once the installation runs, execute the following command to begin a GUI based secure setup of MySQL:
mysql_secure_installation
Create a database and user after logging into the MySQL server using the ‘mysql’ command:
create database mysitedotcom;
grant all on mysitedotcom.* to 'mysitedotcom' identified by 'apassword';

Step #6 Install and configure PHP
apt-get install php5-php-pear php5-suhosin php5-mysql
Optionally, install ‘php5-curl’ for cURL support in PHP.

Step #7 Create a user for this site
useradd mysitedotcom
passwd mysitedotcom
usermod -d /srv/www/mysite.com mysitedotcom
chown -R mysitedotcom:mysitedotcom /srv/www/mysite.com

Step #8 Restart Apache2
/etc/init.d/apache2 restart

Setting Up SSL Certificates On PHP Fog Apps

Let me tell you, it was something of an endeavor setting up an SSL certificate on a PHP Fog application, mostly due to lack of (obvious) documentation, but their technical support was extremely fast and helpful, so we were able to get through the issues quickly. Here’s a little step-by-step write up for those of you who might still be in the dark about the whole SSL certificate installation process.

First of all, be ready to fork over $20 per month to enable the ability to attach an SSL certificate to your PHP Fog application. (C’mon guys, really? I get that IPs are limited, and Amazon’s ELB has a price too, but there’s got to be a better and more cost effective way to do this.)

Second, you’re going to want to log into a computer with OpenSSL installed, so that you can generate the private key to sign your Certificate Request (CSR) file. Run the following command to generate the private key, and be sure to not use a PEM passphrase:

openssl genrsa -out phpfog.key 2048

Now, we are going to generate the Certificate Request. Run the following command to generate the CSR file, using www.yourdomain.com or *.yourdomain.com for the “Common Name” input when it prompts you:

openssl req -new -key www.reconapi.com.key -out phpfog.csr

You can now use this .CSR file to generate your SSL certificate from your provider. I used a Comodo PositiveSSL certificate from NameCheap, which ran me a grand total of $8.95 … however they’re currently running a promotion offering PositiveSSL certificates for $1.99 with the registration or transfer of a domain name. (affiliate link)

Once you generate your SSL certificate with your .CSR file, your provider will make the certificate available for download via e-mail or their website. Be sure to download all related certificates, including the intermediary certificate if there is one available.

Now, navigate to your application’s dashboard on PHP Fog, and select the SSL tab from the sidebar. You are going to be filling out two (possibly three) text boxes with relevant certificate information:

  • Paste the contents of www_yourdomain_com.crt into the Signed Certificate text box.
  • Paste the contents of phpfog.key into the box labeled RSA or DSA Private Key Used to Sign the Certificate.
  • If you received an intermediary certificate, check the box “Use intermediate certificate” and paste the contents of the intermediary certificate file into the text box that appears.

You should be good to go, just click the orange ‘Enable SSL’ button to proceed! Remember, you will have to add some sort of redirection to your application, it won’t automatically forward your visitors to the proper secure pages. I tried using mod_rewrite, however %{HTTPS} does not seem to work, so here’s a little PHP snippet that works instead:

if($_SERVER['HTTP_X_FORWARDED_PROTO'] !== 'https') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}"); exit;
}

Mount Box.net Storage As Network Drive

Box.net has been running a recent promotion giving away a FREE 50GB of cloud storage if you sign up for your account via one of their iOS applications. Naturally, this was very tempting. However, after signing up I realized there was no easy way to upload mass amounts of files. Well, a little Google magic and I had a solution to make the newly acquired 50GB “cloud drive” mount as a network drive and be available through Windows Explorer!

  • Mount Network Drive > Specify an alternate network location
  • Enter https://www.box.net/dav in the “Internet or network address” field
  • Once you click next, you will be prompted to enter your box.net credentials. After you enter your username and password and successfully log in, name your “Network Drive” and you’re good to go!

Reset the Root MySQL Password on Ubuntu 10.04

It’s a commonality among sleep-deprived developers to set up a sandbox at 3AM and wake up not remembering the passwords that were set before the retreat into la-la land. Well, resetting the root user’s administrative password for MySQL is a little tedious, but it’s not impossible:

  • sudo /etc/init.d/mysql stop
  • sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
    You will now be able to log into MySQL as root with no password, since you have launched the MySQL daemon with the flag to skip the privilege index.
  • mysql -u root
    • FLUSH PRIVILEGES;
    • SET PASSWORD FOR root@'localhost' = PASSWORD('password');
    • UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
    • FLUSH PRIVILEGES;
  • sudo /etc/init.d/mysql stop
  • sudo /etc/init.d/mysql start