Subversion recommits
A colleague at work was facing a dilemma and asked for help and I figured that the solution might be usable for others. Here’s the setup. Our SVN trunk typically matches production. Don’t ask why, it just does. Once a release is pushed into production the contents of whatever was deployed is merged into trunk. More like it obliterates what was in trunk.
In this particular case a commit was made after deployment but before the merge, effectively wiping out the changes to trunk. However we still needed to have the commits re-applied. We could have attempted some SVN slight-of-hand, but as it usually works out, the simplest solution is usually the best.
The easiest, and most scriptable solution was to use the way back machine and apply somediff and patch magic. Here’s what we did (make sure your completely up to date when you do).
- Get the files that were changed in the previous revision with
svn log -v -r [REV] |grep "^ M " |awk '{print $2}' |cut -c2- - Go old school and diff and patch
svn diff -r [REV] [FILE] | patch -R [FILE] - Commit away!
Assuming the changes you want applied are in version 2, and HEAD is at version 3, here’s how it might look
for f in `svn log -v -r 3 |grep "^ M " |awk '{print $2}'|cut -c2-`; do svn diff -r HEAD $f | patch -R $f; done
Lastly, issue the commit and your back to where you should be…
Get a quick fingerprint from public key
Due to the GitHub “SSH Key Vulnerability”, all of my keys were deactivated and I needed to reactivate them. Without going into details about the issue, GitHub provides you a list of your key fingerprints that you need to validate and reactivate. If you don’t know the fingerprints of your keys, you might think your stuck. Not necessarily.
If you have the public key handy, you can do this:
ssh-keygen -l -f [public key file]
And you get exactly what you need; a fingerprint of your public key.
Xcode 4.3 quirks
With the Xcode 4.3 update, Xcode has become a full-fledged application in the App Store. There are a few implications to this seemingly innocuous change, but they can (and have) cause a few hiccups that I’m going to point out below. The obvious change is that Xcode is no longer installed via an installer. Should help out tremendously for updates so developers are no longer forced to re-download a gigabyte plus of data for the small fraction that was actually updated.
More importantly though, is that Xcode was just one application in a suite of tools that was installed in /Developer. In order for Xcode to become an “application” in the App Store vis-a-vis an installer, a number of changes were made that will affect Xcode users prior to 4.3.
Continue Reading →
Getting a background texture behind a UITableView
In many apps when you viewing the top of a UITableView and you pull down you get one of three things: a plain white background (i.e. YouTube), a pull to refresh (i.e. twitter), or a textured or differently colored background (i.e. contacts). By default when you have a UITableView, you will get the first option, a plain white background.
If however you would like to do something like contacts where the perceived “background” of the table view is something other than default. If that’s the case, it’s relatively easy to do. Here’s how.
In your UITableViewController (usually viewDidLoad:)
// This sets the lighter linen looking background. see UIColor for more "System Colors" [[[self navigationController] view] setBackgroundColor:[UIColor underPageBackgroundColor]]; // Make the background of the table view transparent. [[self tableView] setBackgroundColor:[UIColor clearColor]];
Then implement this method in your UITableViewController:
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { [cell setBackgroundColor:[UIColor whiteColor]]; }
After playing around and failing in different ways, this seems to be the simplest solution by far. Simple, easy and does what it should.
Mac OS X Lion Clean Install Quirks
I decided to do a clean install on my development laptop with Lion to clean out the cruft. Not that it really needed to be done, but I was curious to see if there were any discernible differences between the Snow Leopard (SL) upgrade and a clean install.
For those who are wondering, you can find a plethora of resources on how to do it if you so choose, but I did want to point out a few quirks that I ran into after the install. I’m not sure if these are environmental differences that I had adjusted a some point in the past, but when I re-installed a clean version of Lion a few things changed.
- Mission Control – By default, there’s really only one space. If you upgraded an existing SL installation and used spaces, it created them by default in MC. Furthermore, Control-UP activates MC. Control-Down does the old Exposé routine.
- Tap to Drag – I don’t remember the actual starting state of this but I checked on another laptop and my desktop with the Magic Trackpad and they were configured the same so I’m working under the assumption that this may affect a few people like myself. If you were used to the whole tap to drag routine, it’s not there — well technical it’s there but not active. Once you activate the tap to click, tap to drag doesn’t. And it’s not in the Trackpad preference pane either. Strangely enough, it’s tucked away under Universal Access/ Mouse & Trackpad/ Trackpad Options…

As I find more quirks I’ll update this post.
Enjoy.
Selective Site Mirroring with wget
Since Cloudera doesn’t seem to support an rsync server for us to mirror against, I had to resort to using wget to mirror their CDH distribution. To save some time for those who are attempting to do something similar, here’s a wget one-liner to grab only the RPM’s (while maintaining the directory structure):
wget -N -r -nH -np --cut-dirs=3 -A rpm,xml http://archive.cloudera.com/redhat/cdh/3/
Create a Linux Boot ISO image to start via Kickstart
Getting tired of creating new VM’s, and don’t want to clone for a particular reason but want them standardized? Easy. By creating a boot image that immediately starts a kickstart installation, you can completely automate creating a VM regardless of virtualization solution your using.
To create the isolinux boot image:
Mount the DVD image.
mount -o loop /path/to/dvd.iso /mnt
Copy the data locally.
rsync -av /mnt/isolinux [where ever]
Edit the isolinux.cfg file to update and point to proper kickstart location, and make it auto start by setting prompt to 0.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | default linux prompt 0 timeout 600 display boot.msg F1 boot.msg F2 options.msg F3 general.msg F4 param.msg F5 rescue.msg label linux kernel vmlinuz append initrd=initrd.img ks=nfs:192.168.0.1:/mnt/vg1/iso/kickstart/centos55_text.ks label text kernel vmlinuz append initrd=initrd.img text label ks kernel vmlinuz append ks initrd=initrd.img label local localboot 1 label memtest86 kernel memtest append - |
Create a simple script in the isolinux directory to do the heavy lifting.
1 2 3 4 5 6 | #!/bin/sh ISO_NAME=centos55_boot.iso # Remove the old iso. rm -f $ISO_NAME # Make the image. mkisofs -o $ISO_NAME -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T $PWD |
Kick it off and you should now have a viable boot image. Once you boot the newly created guest, just boot using the new image and it will automatically start your kickstart installation.
OpenAM Apache Web Agent
Make sure you set the Encode Cookie Value to Yes or True. If it’s not able to be modified, it’s an inherited setting that you will need to change. If you don’t, you’ll get a 500 error once a successful login has occurred.
Update Postgres in Ubuntu
The Postgres website download page doesn’t do a great job of documenting how to keep PG up to the latest release. Even for those of us who are using 10.10, the standard repositories still point to older 8.X versions. To ensure that you have access to the latest version of PostgreSQL in Ubuntu, install Martin Pitt’s backports PPA. If you are running Ubuntu >= 9.10 you can do this with one simple command:
sudo add-apt-repository ppa:pitti/postgresql
Once that is done, you may need to enable the updates to use backports. In Synaptic, open Settings -> Repositories and select the Updates tab. Make sure that “Unsupported updates” is checked.
Then just update as usual, and Postgres will be updated to the latest and greatest.
Regex Recipes
Since I went through the time to create these, I might as well document a few of them for myself and anyone else who might be looking for it. As I refine and author more, I’ll add them here.
Phone Number Validation
This would be useful to validate phone numbers of customers, clients or prospects. This only validates the 10 digit phone number that does not have parenthesis and dashes. Minor modifications would be necessary to validate with those formatting characters included. (via NANPA.)
^(8(?:00|88)|([2-9])(?!\2{2}|9[\d]|00|11)[\d]{2})([2-9&&[^5]][\d]{2}|(?:5(?!55)[\d]{2}))([\d]{4})$[UPDATE: Didn't like what I had before and this should be a smaller, more optimized, version.]
This regex covers:
- All ERC (Easily Recognizable Codes) which would include codes like 333,444,555, etc.
- Allowance for toll-free numbers (800,866,877,888, etc.)
- ERC Service codes 211,311,411,511,611,711,811,911.
- Unallocated and/or premium codes (200,300,400,500,700,900, etc.)
- Standard area codes from 201 to 989.
- Removal of 555 Central Office prefix.
If you want to give these a try there are a number of online utilities, but RegExr is one of my favorites.
