Python Debugger

It’s pretty simple to have your python script jump out to the debugger.  Place these 2 lines right before where you want to start monitoring (otherwise, you’ll need to do a lot of stepping thru code).

import pdb

Some useful ones to remember are:

  • b: set a breakpoint
  • c: continue debugging until you hit a breakpoint
  • s: step through the code
  • n: to go to next line of code
  • l: list source code for the current file (default: 11 lines including the line being executed)
  • u: navigate up a stack frame
  • d: navigate down a stack frame
  • p: to print the value of an expression in the current context

Setting your git username and email address

Single Repo

If you need to quickly set the user and email address for a single git repo, you can do this:

git config
git config "John Doe"

If you want to modify the .git/config file directly, you can add in this block:

name = John Doe
email =

All Repos

git config --global
git config --global "John Doe"

Delete partitions on Drives (USB especially)

Microsoft DiskPart version 6.2.9200

Copyright (C) 1999-2012 Microsoft Corporation.
On computer: COMPUTER

DISKPART> list disk

Disk ### Status Size Free Dyn Gpt
——– ————- ——- ——- — —
Disk 0 Online 298 GB 0 B
Disk 1 Online 7509 MB 6619 MB

DISKPART> select disk 1

Disk 1 is now the selected disk.


DiskPart succeeded in cleaning the disk.

DISKPART> create partition primary

DiskPart succeeded in creating the specified partition.


This info was copied from:

Using xcopy to safely copy (and verify) files from one drive to another

I recently upgraded my “data” drive from a 3TB to a WD Black 6TB Performance Desktop Hard Disk Drive – 7200 RPM SATA 6 Gb/s 128MB Cache 3.5 Inch drive.

Once I had both drives installed in the computer, it was time to copy data.

Head over to: Start Menu -> All Programs -> Accessories -> Command Prompt. Right click on it, and choose “Run as administrator”

xcopy f:\ e:\ /f /h /i /j /o /s /v /x 1>>c:\xferlog.txt 2>&1

Continue reading Using xcopy to safely copy (and verify) files from one drive to another

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.

Keeping track of what keeps me on track