Monthly Archives: March 2011

Saving flash videos like youtube

When you watch a flash video like youtube in a browser, the video file is saved on your harddisk at a temporary location. And, if you watch a video and then another video in the same window, the first one will be deleted.

On Linux, the file is usually saved in /tmp/FlashXXXXX where the XXXXX is some random string.

On Mac, the file is somewhere under /private, you can find it with the command:

find /private/ 2>/dev/null | grep /Flash

To save the video, simply copy the file. Make sure you wait until the video is fully downloaded in the browser.

Btw, sometimes you can make the volume louder when playing the file with a video player instead of youtube.

Bash co-processes and other tricks

I thought I already knew all the most practical tricks in bash. But I have a feeling I found something I will use a lot, check it out:

paste <(ls -1) <(ls -1|tr 'A-Z' 'a-z')| 
{ while read old new; do echo mv -v $old $new; done; }

This also brings me to the other tip. When doing tricky stuff like this, it’s good to first print the commands you want to execute. If it all looks good, just pipe the output to bash to execute.

How to mirror a Subversion repository using Bazaar

With Subversion alone you cannot mirror projects across repositories. Luckily with Bazaar this works out of the box.

bzr co https://url_to_svn_repo/proj1/trunk proj1
cd proj1
bzr push https://your_other_repo/vendor/proj1/trunk

Easy and intuitive. This will check out the entire history of the source repository and replay the changes one by one in the target repository. The repository where you push will have the same commits as the source repository, except the committer information, which will be lost. Also note that in this example we push to a Subversion repository with Bazaar. Both the source and target repositories are Subversion, the local Bazaar repository in the middle just bridges the gap.

Keeping the mirror up to date is simple:

cd proj1
bzr up && bzr push

Keep in mind that you should NEVER commit to the mirror except with the bzr mirror script. It’s best if you setup access controls to prevent regular developer accounts to commit to the mirror. Typically you want to branch from the mirror and work on the branch. You can even push your branch back to the source repository (to a new branch, not the original project). And when you do that, bazaar will replay only the changes in your branch, not the full history.

If you want to schedule the mirroring script in a Windows environment there may be some gotchas. I’ve seen error message dialogs popping up when bzr is trying to access Subversion repositories, for example:

  • “the procedure entry point could not be located in the dynamic link library libsvn_subr-1.dll”
  • “the ordinal 4540 could not be located in the dynamic link library libeay32.dll”

Even if the script works just fine after you dismiss these popups, it won’t work in non-interactive mode (when running as a scheduled batch).

In my case the cause was the wrong libsvn_subr-1.dll library was found. Probably this can be solved by fixing library path settings. I simply uninstalled the Subversion client on the machine to remove the duplicate (and apparently incompatible) libraries.

Another gotcha you may have is with repository authentication. You can make it work with a correct authentication.conf file. The directory to put this file is in the output of the “bzr version” command, look for the line “Bazaar configuration”.