How to open file links in Firefox 1.5 and above

Found some instructions about How to open file links in Firefox 1.5 and above and I’m going to try it out just as soon as I can reset my browser.

Basically you add something like the following to your user.js file which is in C:\Documents and Settings\[User Name]\Application Data\Mozilla\Firefox\Profiles\[Profile]\user.js.

user_pref("capability.policy.policynames", "localfilelinks");
user_pref("capability.policy.localfilelinks.sites", "http://www.example.com");
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");

Internet explorer support for file URIs

The URI file://bender-xp/C$/ works in an anchor tag in IE8 to open the \\bender-xp\C$ file share on my network. In this case bender-xp was the name of my local machine but it works for remote file shares too (I tested it to a Samba share on another box).

Unfortunately my version of Firefox (version 9.0.1) doesn’t support this.

Using PHP output buffering to read a file

There’s a function in PHP called readfile which will read a file and send its contents to stdout. That can be handy, but it’s not much good to you if you want to read the content of the file into a string.

There’s a neat trick using PHP’s output buffering that enables you to read the content of a file into a string without printing anything on stdout, and it goes like this:

  // start an output buffer
  ob_start();
  // print the file to the output buffer
  readfile( $file_path );
  // get the contents of the output buffer
  $content = ob_get_contents();
  // cancel the output buffer
  ob_end_clean();

Bash aliases for listing hidden files

I finally figured out the ls command to list hidden files, and decided to setup a ~/.bash_aliases file for the first time. My ~/.bash_aliases file is now:

alias l.='ls -d .[!.]*'
alias ll.='ll -d .[!.]*'

So I have an “l.” command which will list hidden files and directories, and an “ll.” command which will list the same information in detail.

Extracting a single file from a tar archive

You can use a parameter to the -x command line switch to tell the tar command that you just want to extract one particular file from the archive. For example:

  $ tar -x filename/to/extract -f tarfile.tar

You can use the -O command line switch in conjunction with the above to have the file’s contents printed on stdout rather than created in the file system.