git add -u

Here is a nice little tidbit I ran across some time ago…  Ever delete a bunch of files from a git working copy, and then had to go in and tell git that you meant to delete them?  For example:

[jason@dc40 AppStruct]$ git status
# On branch master
# Changed but not updated:
#   (use "git add/rm ..." to update what will be committed)
#
#       deleted:    Python/AppStruct/Application.py
#       modified:   Python/AppStruct/Database/PostgreSQL.py
#       deleted:    Python/AppStruct/Date.py
#       deleted:    Python/AppStruct/JSON.py
#       deleted:    Python/AppStruct/Util.py
#       deleted:    Python/AppStruct/__init__.py
#
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#       Python/AppStruct/NewFile.txt
no changes added to commit (use "git add" and/or "git commit -a")

Previously, the way to handle this would be:

   git rm ...
   git rm ...
   git rm ...
   git rm ...
   git rm ...
   git add ...
   git add ...

Rather, isn’t this easier?

   git add -u
   git add .

From the man page for git-add:

–update | -u
Only match against already tracked files in the index rather than the working tree. That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed.

PostgreSQL Dump and Restore Notes

The pg_dump and pg_restore commands provide excellent flexibility in storing a compressed dump file, and selectively restoring any part of it.

I’ve found that dropping and re-creating the target database is the cleanest way to restore a dumpfile — no stray relations left to cause trouble.

Unless you own all of the objects being restored, you may need to be SUPERUSER in order to have a successful restore.

The custom dump format is quite useful.  Unlike the normal sequence of SQL statements you may be used to from mysqldump (and pg_dump as well), the –format=custom option will create a compressed archive file (internally a tar file) that can be selectivly read with pg_restore.  That flexibility could come in handy if you *just* need the schema from 1 table, or *just* the data from another table.

Dump:
pg_dump –format=custom -U jason_super MyDatabase > MyDatabase.pgdump

Restore
pg_restore –exit-on-error –clean –dbname=MyDatabase MyDatabase.pgdump

Get all of the SQL
pg_restore TMTManage_2.pgdump | more

Get some of the SQL
pg_restore –schema=ACRM –table=Admin TMTManage_2.pgdump | more

Interesting Numeric Pattern

>>> for i in range(1,31):
...     print('  ' + '1'*30)
...     print('x ' + '1'*i)
...     print('= ' + str(int('1'*30) * int('1'*i)))
...     print()
...
  111111111111111111111111111111
x 1
= 111111111111111111111111111111

  111111111111111111111111111111
x 11
= 1222222222222222222222222222221

  111111111111111111111111111111
x 111
= 12333333333333333333333333333321

  111111111111111111111111111111
x 1111
= 123444444444444444444444444444321

  111111111111111111111111111111
x 11111
= 1234555555555555555555555555554321

  111111111111111111111111111111
x 111111
= 12345666666666666666666666666654321

  111111111111111111111111111111
x 1111111
= 123456777777777777777777777777654321

  111111111111111111111111111111
x 11111111
= 1234567888888888888888888888887654321

  111111111111111111111111111111
x 111111111
= 12345678999999999999999999999987654321

  111111111111111111111111111111
x 1111111111
= 123456790111111111111111111110987654321

  111111111111111111111111111111
x 11111111111
= 1234567901222222222222222222220987654321

  111111111111111111111111111111
x 111111111111
= 12345679012333333333333333333320987654321

  111111111111111111111111111111
x 1111111111111
= 123456790123444444444444444444320987654321

  111111111111111111111111111111
x 11111111111111
= 1234567901234555555555555555554320987654321

  111111111111111111111111111111
x 111111111111111
= 12345679012345666666666666666654320987654321

  111111111111111111111111111111
x 1111111111111111
= 123456790123456777777777777777654320987654321

  111111111111111111111111111111
x 11111111111111111
= 1234567901234567888888888888887654320987654321

  111111111111111111111111111111
x 111111111111111111
= 12345679012345678999999999999987654320987654321

  111111111111111111111111111111
x 1111111111111111111
= 123456790123456790111111111110987654320987654321

  111111111111111111111111111111
x 11111111111111111111
= 1234567901234567901222222222220987654320987654321

  111111111111111111111111111111
x 111111111111111111111
= 12345679012345679012333333333320987654320987654321

  111111111111111111111111111111
x 1111111111111111111111
= 123456790123456790123444444444320987654320987654321

  111111111111111111111111111111
x 11111111111111111111111
= 1234567901234567901234555555554320987654320987654321

  111111111111111111111111111111
x 111111111111111111111111
= 12345679012345679012345666666654320987654320987654321

  111111111111111111111111111111
x 1111111111111111111111111
= 123456790123456790123456777777654320987654320987654321

  111111111111111111111111111111
x 11111111111111111111111111
= 1234567901234567901234567888887654320987654320987654321

  111111111111111111111111111111
x 111111111111111111111111111
= 12345679012345679012345678999987654320987654320987654321

  111111111111111111111111111111
x 1111111111111111111111111111
= 123456790123456790123456790110987654320987654320987654321

  111111111111111111111111111111
x 11111111111111111111111111111
= 1234567901234567901234567901220987654320987654320987654321

  111111111111111111111111111111
x 111111111111111111111111111111
= 12345679012345679012345679012320987654320987654320987654321