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.
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!
PuTTY “Access denied” message
When I start a new session in PuTTY, I receive an error message stating "Access denied" immediately after I input my login username, which is immediately followed by a prompt for my password. Then, I am able to enter my password and successfully login to my server.
I thought the message was odd, and after some quick internet searching I learned that you can Ctrl + right-click on the PuTTY window and then select "Event log" (See grawity's answer on superuser.com). The event log showed "GSSAPI authentication request refused". Per Kem Mason's comment on the aforementioned superuser.com answer, I disabled (de-selected) "Attempt GSSAPI authentication (SSH-2 only) under Connection > SSH > Auth > GSSAPI. Now, PuTTY does not attempt to authenticate via GSSAPI and the slightly annoying error message does not appear.
InnoDB Tips – MySQL
Today while building an InnoDB database for MySQL I learned two things:
- 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.
- A foreign key must be a primary key in the foreign table.
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:
- 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.
- 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.
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
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.
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!
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!
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>eth0system-config-networksudo vim /etc/resolv.confsudo vim /etc/sysconfig/network-scripts/ifcfg-eth0sudo 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.