In Excel, Splitting a Last_Name, First_Name cell, into 2 cells

Assuming that cell B2 contains a name like, Dangerfield, Rodney, here are 2 formulas you can use to create 2 cells, one with the first name, one with the last name.

For the first name:

and for the last name:

Next, copy those formulas down thru all apllicable rows.

Lastly, highlight the 2 columsn, right-click and choose Copy.
Then right-click on an empty column head to the right, and choose: Paste Values.


Special Case

What if the name is really, “last_name, first_name middle_name”, and you don’t want the middle name?
=LEFT(RIGHT(B2,LEN(B2)-FIND(",",B2)-1),FIND(" ",RIGHT(B2,LEN(B2)-FIND(",",B2)-2)))

That’s great, but what if someone does NOT have a middle name?
Then you’ll get an error.
To solve for that, need to make it even fancier:
=IF(ISERROR(LEFT(RIGHT(B2,LEN(B2)-FIND(",",B2)-1),FIND(" ",RIGHT(B2,LEN(B2)-FIND(",",B2)-2)))),RIGHT(B2,LEN(B2)-FIND(",",B2)-1),LEFT(RIGHT(B2,LEN(B2)-FIND(",",B2)-1),FIND(" ",RIGHT(B2,LEN(B2)-FIND(",",B2)-2))))

Apache and mod-rewrite – redirecting a folder to new server

If you ever need to move one (or more) subdirectories, but not an entire site over to a new webserver, and you want to redirect the traffic, here’s how you can do it:

RewriteEngine On
RewriteRule ^directory_name(.*)$ [R=301,NC,L]

If you have multiple virtual hosts on the site, you might want to specify which host name’s directory_name should get sent to new server

RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^directory_name(.*)$ [R=301,NC,L]

On Ubuntu 13+ and higher, /etc/bash_completion.d/git is now git-prompt

In this previous post I wrote about how to get some git branch information into your shell. That was written back when Ubuntu 12 LTS was the standard.

I recently upgraded a box to Ubuntu 16 LTS, and this information went away. 🙁

I discovered via trial and error, that the call that’s needed in .bashrc is now:

## To show you what branch you are in as you move around git repos
if [ -f /etc/bash_completion.d/git-prompt ]; then
. /etc/bash_completion.d/git-prompt
PS1='\[\u@\h \e[33m\]\w\[\e[0m\] $(__git_ps1 " (%s)")\n\$ '

/etc/bash_completion.d/git is now: /etc/bash_completion.d/git-prompt

Fetch a remote branch that doesn’t exist locally using git

Say you are working on not your normal computer and are working on a branch that isn’t quite ready to get merged with the official git repo for the codebase. Here’s what you can do:

git push  SOME_OTHER_ORIGIN   branch_name --tags --set-upstream

Then, when you get back to the computer you normally work on, you can do this:


git checkout -b  branch_name 
# which will switch you to that branch

$  git fetch SOME_OTHER_ORIGIN   branch_name
Password for '':
 * branch            branch_name  -> FETCH_HEAD

# Check this is what you want:
$ git log ..FETCH_HEAD

# if it is, then
$ git merge --no-ff FETCH_HEAD | more

NOTE: You might need to hide some local files that get gotten in the 1st place.

My favorite way to run screen

First, make sure you have screen installed:

$ sudo apt-get install screen

Then, create a .screenrc file with the following in it:

screen -t root sudo su -
screen -t bash2
screen -t bash3

select 0
startup_message off

caption always "%{= kw}%-w%{= bw}%n %t%{-}%+w %-= @%H - %c - (%l)"
# Call via:  screen -R -e^Hh -d
# to change the strings, look at:
# to test your changes, you can either copy the above line, the do
# CTRL-H :  and then paste in the line above
# or, CTRL-H :source ~/.screenrc

Lastly, start up screen:

screen -R -e^Hh -d

This let’s you switch screens by pressing CTRL-H and then SPACEBAR. (I found that I use CTRL-A far too much to let that be the standard screen key binding)

Let WordPress remember your FTP credentials

I’ve found it quite useful to let WordPress remember my FTP information, so that adding new plugins/themes and doing security updates can happen quite quickly.

First, gather up your FTP username, password and host.
Next, open up the ./wp-config.php file. I like to put in the FTP information after the MySQL settings area:

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

define('FTP_HOST', 'yourFTP_Hostname');
define('FTP_USER', 'yourFTP_Username');
define('FTP_PASS', 'yourFTP_Password');
define('FTP_SSL', false);

To test it out, try to install a plugin.

In case of problems

2-3% of the time, WordPress has problems doing the FTP, even though I know that the information is correct. In that case, here is a workaround.

mysql> select * from wp_options where option_name = 'ftp_credentials';
| option_id | option_name     | option_value                                                                                             | autoload |
|       876 | ftp_credentials | a:3:{s:8:"hostname";s:12:"";s:8:"username";s:8:"someUsername";s:15:"connection_type";s:3:"ftp";} | yes      |
1 row in set (0.00 sec)

Take a look at what’s there, copy and paste it to a temporary safe place, then delete it from inside of MySQL:

mysql> delete from wp_options  where option_name = 'ftp_credentials';
Query OK, 1 row affected (0.00 sec)


Switch back to your browser, and try installing the plug-in again. This time it should work.

Stash your mysql password in the .my.cnf file

Hopefully you are using usernames and passwords when accessing your MySQL databases. Security can make it hard to quickly jump in and start working in the MySQL shell if your password is quite complicated.

Here’s the solution:

create a ~/.my.cnf file and fill it with:


Next, make sure that only you can read it:

chmod 600 ~/.my.cnf

Lastly, test it out:

user@host:~$ mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 65863
Server version: 5.5.31-0ubuntu0.12.04.2 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show tables;
| Tables_in_yourDBname  |
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
11 rows in set (0.00 sec)


Voila! In there without having to worry about needing to look up your password.

Git – automagically add modified files and rm deleted files

Sometimes a script will upgrade/add/modify/delete a large swath of files (possibly due to an upgrade-type script). If you are lazy, then you’ll want a script to help you commit those files. Here’s what I’ve come up with:

To perform a git add to all modified files:

 for file in `git status | grep modified | cut -d ":" -f 2`; do git add $file; done

To perform a git rm to all modified files:

 for file in `git status | grep deleted | cut -d ":" -f 2`; do git rm $file; done