Mike T. Moore's Web Dev Blog

18Nov/110

vim notes – swap split windows

If you are using :vsplit to create a split window setup in vim, you can use <c-w> r to rotate the open windows (cycles content from one window to the next, for all open windows). FYI: the c in <c-w> represents the Ctrl key on your keyboard. For more about moving vim windows around, type :help window-moving when in vim.

Tagged as: No Comments
17Oct/110

List duplicate entries from MySQL table

I ran a script at the end of the day last Friday and filled a MySQL database table with 18,757 entries. This table was a mapping table for a many-to-many relationship. First thing this morning, I wanted to double-check my work from Friday, knowing full well I was at the end of my rope that day. I wanted to check for duplicate entries. Thanks to this MySQL Forums response by user Peter Brawley, I found a query to list all duplicate entries in a table:

SELECT a,b
FROM tbl
GROUP BY a,b
HAVING COUNT(*)>1;

This helped me find 199 duplicates! Now, go read about cloning!

14Oct/110

InnoDB Tips – MySQL

Today while building an InnoDB database for MySQL I learned two things:

  1. A foreign key constraint can only be created if both the table with the constraint and the table with the foreign key already exist. This means that you must use the `ALTER TABLE` syntax to add a constraint after the table has been created, you cannot add the constraint as part of the `CREATE TABLE` syntax.
  2. A foreign key must be a primary key in the foreign table.
12Oct/110

Colemak keyboard layout to replace QWERTY?

I am interested in trying out Colemak, an alternative to the QWERTY keyboard layout. I follow @jammycakes on twitter and he is quite the Colemak advocate. The incentives to switch to Colemak are convincing &emdash; ergonomic and comfortable, easy to learn (not many differences from QWERTY, not many changes in keyboard shortcuts), fast, and free!

My first question was if I needed to buy a new keyboard, but Colemak is software. The Colemak website explains that you only need to download the software and use it in conjunction with your normal QWERTY layout. There is a lot of information about the layout on the Colemak website, including lessons.

My only concerns are:

  1. Once I learn to use Colemak, will I be able to use vim? I use vim for editing code five days a week at work and for personal projects at home.
  2. How challenging will it be to switch between QWERTY and Colemak? I have a feeling that this won't be much of a hassle, but it is a concern.

I'll find out as soon as I can find the time to download Colemak and try it out.

16Sep/110

Default PHP session.save_path directive

I ran into the following error on my nginx/fastcgi/php setup:

Warning: session_start(): open(/var/lib/php/session/sess_eqq5jroup02i23vme076c9g6s3, O_RDWR) failed: Permission denied (13) in /some/location on line 10 

The solution is to change ownership on the directory defined as the session.save_path in the php.ini file. The default is /var/lib/php/session. For some reason the ownership was set as root:apache, but I needed to change it to root:nginx. I did this with the following command:

sudo chown nginx:root /var/lib/php/ -R

I was able to do this because I read this blog post.

Edit 10/02/2011

The previous command is not necessary/correct. Here is the one that works:

sudo chown :nginx -R /var/lib/php
6Sep/110

CentOS: Unable to establish SSL connection.

If you attempt to use wget on CentOS and get the error Unable to establish SSL connection., then try running wget with the option --no-check-certificate.

Tagged as: , No Comments
31Aug/110

Determine IP address of domain via linux terminal

If you need to determine the IP address of a domain, use nslookup domainname.com. Thanks to Bohemian Blog for this tip!

Filed under: Linux No Comments
31Aug/110

CentOS 5.6 on VirtualBox – Part 2

I had previously posted about being unable to access my nginx web server here.

I have CentOS 5.6 installed on VirtualBox, which is in turn installed on Windows Vista Home Premium. I also installed nginx 1.0.5 as a web server. I disabled iptables and set the VirtualBox network adapter to "Bridged Adapter". I ran ifconfig to find the IP address and used it to SSH in to the virtual machine with PuTTY. But, I was attempting to access the server via a web browser with http://localhost and http://127.0.0.1, which (duh!) wasn't working.

Tonight, I was able to access the server via my browser by typing the IP address that ifconfig outputs, which is not 127.0.0.1. Well, now I know!

Filed under: CentOS, Linux, nginx No Comments
30Aug/110

CentOS 5.6 on VirtualBox

I installed CentOS 5.6 on VirtualBox, on Windows Vista. After disabling iptables (sudo /etc/init.d/iptables stop), I setup the Network Adapter in the VirtualBox Devices menu to Bridged Adapter. This enables networking and I am able to use yum and also ping servers.

I also have installed nginx and git so that I might use this as a local development server. I have only done this once, about a year ago, but with Debian. I remember needing to set a static IP address so that I could connect via SSH and web browser outside of the VirtualBox OS. So far, I have not been able to get it to work.

Some places that I might need to edit configuration:

  • sudo setup, Network configuration > Edit Devices > eth0
  • system-config-network
  • sudo vim /etc/resolv.conf
  • sudo vim /etc/sysconfig/network-scripts/ifcfg-eth0
  • sudo vim /etc/sysconfig/network

To restart the network:

sudo service network restart

Update

I was able to solve this problem and I explain it here.