Declare character encoding in HTML

5 07 2010

Writing documents in english, german and norwegian leaves you with a mess of different character encodings in documents and also webpages.

Just wrote a plain HTML page with norwegian special characters and Firefox, did not show the characters correctly, so I had to find out how to specify that the encoding of the norwegian æøå’s is UTF-8.

Fortunately there is a good explanation on the W3C Blog.

The code to specify the encoding is

http-equiv="Content-Type" content="text/html; charset=UTF-8"

I have no illusion about some browser (IE?) getting it wrong anyway. At least Firefox seems to comply…


HowTo: Download YouTube videos (the easy way)

25 01 2010

Update: The Adobe Flash Player used to cache the .flv video files in the /tmp directory, so one could just copy the file from the directory after it was completely loaded and with the browser tab still active (!important).

This has changed. The Adobe Flash Player now deletes the file after it finished caching and keeps a so calles handle on it. Liori explains this very clearly and I blockquote the how to. Thanks!

Now we need to use two tools. First is lsof, which shows all opened handles by all processes. The key knowledge is that the deleted file is still created as /tmp/Flash*. Lets find the handle:

lsof|grep Flash

firefox-b 23220 liori 83u REG 254,0 10565348 929 /tmp/FlashXXQCq4K0 (deleted)

I added lsof’s header to make it clearer. Note that funny (deleted) remark—when you check the contents of /tmp, you won’t see that file! We’re interested in the PID and the FD number. FD is the opened handle’s number, and PID is an identifier used to distinguish different programs.

Second tool is the /proc filesystem. This is a special directory existing on all commonly used Linux installations. It contains data about running system: driver settings, process list, diagnostic information. What’s most interesting is that it contains files representing all opened file handles. In our case (PID=23220 and FD=83) the handle representing our deleted file is /proc/23220/fd/83. Again, if you just try to list that directory, you will only see a broken symlink. But what if you do this?

cat /proc/23220/fd/83 >video.flv
…you’ll get the contents of the deleted file!

This technique is of course not only useful to grab videos downloaded by your flash plugin. Any time you delete a file, but realize that it is still opened by some program, you can recover it.

This is the old post quoting FRuMMaGe on Ubuntuforums

Many people have been asking how to download youtube videos, and kept being pointed to useless software which will do it for them.

Here is the easy way:

Step 1: Find the video you want to download and wait for it to completely finish loading.

Step 2: Minimize your browser (do NOT close it, some browsers delete the temp directory upon closing), and navigate to the directory /tmp

Step 3: Drag the flash file onto your desktop. Voila!

This definitely works with firefox, and probably most other browsers aswell. Enjoy!

Telling IE6 to Open Internet Links in New Window

6 10 2009

This is out of the usual purpose of this site, but I am documenting this because I used some time on it to find out.

On my work computer setting an individual startpage is disabled and one is forced on the intranet site at first and have to navigate on from there, which can be quite anoying, given that I am programming and having to look up code fixes all the time.

I helped myself out with desktop shortcuts, BUT:

IE6 does not allow tabs and opens the shortcuts always in a window already opened, e.g. my remote Outlook email client… -> very annoying…

Then I googled the problem and found a post on metafiler suggesting a fix for this inconvienience.

First of all, it’s instructive to realize what the start command does. It knows nothing of Internet Explorer or any other browser. All it knows it how to look up the program associated with a URL type or file extension. So when you run “start file.html” it looks up in the registry what application is registered for .html file types, and launches it. Similarly, if you use “start http://url” it will look in the registry for the “HTTP:” URL handler, and launch whatever application is registered there. You can view these associations in Explorer (Tools – Folder Options – File Types.)

This lead to the following conclusion

  1. It is possible to start the browser from the commandline with “start”
  2. This can be added to a .bat file opening my standard set of webpages
  3. Windows can be told to open http connections in a new window

It took some fidling but this is the solution:

  1. Right click the Windows Start button
  2. Choose Open
  3. Got to Tools – Folder Options – File Types
  4. Scroll down the list and mark something like Protokoll for hypertext connections (I am seeing this in norwegian so I assume it might be like that – it is quite on top of the list shortly after Internet shortcuts)
  5. Choose Advanced
  6. you should see the default action: open
  7. Change the entry WWW_OpenURL to WWW_OpenURLNewWindow
  8. Click OK and close the file explorer. Done.

Now create a batch file to start the day, that is:

  1. rightclick the desktop,
  2. choose New – Text file
  3. name it GoodMorning.txt
  4. Open GoodMorning.txt and add some lines like:
  5. start

  6. Save and close the file
  7. Important: Rename it to GoodMorning.bat this tells windows to execute the content
  8. Double click it after starting the computer and all pages listed get opened in a separate Window

Just for the record.