Recursive directory merge

Posted by Chief on Mar 11, 2010 in Reference, Scripts, Tricks and Hacks
No Comments

Problem: I have two directories that are similar in structure but different in content. Say one is an older snapshot of the other. I want to copy the stuff from the new directory into the old directory (recursively).

Copy:
rsync -a SOURCE/ DEST/ --ignore-existing --whole-file

Move (no clobber):
rsync -a SOURCE/ DEST/ --remove-sent-files --ignore-existing --whole-file

Move (and clobber):
rsync -a SOURCE/ DEST/ --remove-sent-files --whole-file

Move, but only update with newer:
rsync -a SOURCE/ DEST/ --remove-sent-files --update --whole-file

Tags: , , , , , , , ,

Samba reference

Posted by Chief on Mar 11, 2010 in Reference
No Comments

When trying to set up a samba server, I found these links to be very useful.

References:

  • https://calomel.org/samba.html
  • http://ubuntuforums.org/showthread.php?t=685427

Tags: , , , , ,

Git: Recovering a file that you deleted

Posted by Chief on Mar 10, 2010 in Lessons, Reference, Scripts, Tricks and Hacks
No Comments

You might be doing some spring cleaning to your source code, or you might move files around that you think are unnecessary. Later on, you realize that one of the files you removed was a dependency. Now what? For this, we use git checkout.

If this is you:

...edit files...
git add edited-file
git commit -m "made changed"
git rm seemingly-useless-file
git commit -m "removed unreferenced dependency"
... edit file ... realize you dynamically included that file elsewhere..

Then you can simply follow up with:

git checkout 0a323 // the previous revision (hash from `git log`)
cp seemingly-useless-file seemingly-useless-file.1
git checkout master
mv seemingly-useless-file.1 seemingly-useless-file
git add seemingly-useless-file
git commit -m "Restored seemingly-useless-file"

You may want to git blame yourself while you’re at it.

If you know of a better way, please let me know.

Tags: , , , , , , , , ,

The little known PHP htmlspecialchars

Posted by Chief on Feb 20, 2010 in Reference
No Comments

Want to replace only xml entities <, >, &? Don’t use htmlentites or str_replace; use htmlspecialchars.

The only named entities for XML are &amp;, &gt; and &lt;. For all others you need to use the Unicode character code (eg. &#160;). Webkit: Entity ‘nbsp’ not defined – Convert HTML entities to XML

Tags: , , , ,

PHP 5.3.1 Error Logging and Display of Said Errors

Posted by Chief on Feb 18, 2010 in Reference
No Comments

I just installed the PHP 5.3.1 Windows installer bundle [VC9 x86 Non Thread Safe (2009-Nov-19 09:53:39)] on my Windows 7 [Ultimate] machine. I want the PHP error output to get sent to stderr when run from the command line. I don’t want the errors logged to a file because I’m developing cli tools. Since we’re dealing with the cli, I also don’t want html errors. Should be pretty easy… if you know how to edit the settings.

These worked for me:

error_reporting = E_ALL
display_errors = stderr
display_startup_errors = On
log_errors = Off
html_errors = Off
;error_log = php-errors.log

Ensure that error_log is not set, otherwise error will not be displayed. This problem may be related, but is obviously not, the date bug mentioned in the PHP bug reports. It may be fixed in the latest snapshot. As a note, the php.ini date.timezone setting is date.timezone = "Pacific/Honolulu", and I still had this problem.

Other things I noticed:
When error_log = syslog, you can find the PHP events in the windows Event Viewer -> Windows Logs -> Application. I mention it in case you want that type of thing… or think error that logging may not be working.

Tags: , , , , , ,

OpenVPN behind US Government Proxy

Posted by Chief on Feb 11, 2010 in Reference
No Comments

Using OpenVPN is possible through the government proxy server via TCP port 1194 using either amcproxy.faa.gov:8080 or awpproxy.faa.gov:8080

I read that somewhere…

Tags: , , , , ,

Copyright © 2010 cat brain.log | less All rights reserved.
Shades v1.2 theme from BuyNowShop.com.