Manuals, writings and idea's from an techie.

How can I force format read only usb drive in OSX

Check disk device with Disk Utility, then
sudo diskutil unmountdisk force diskXXX
sudo dd if=/dev/zero of=/dev/diskXXX bs=1024 count=1024

Howto start the native OSX tftp deamon

sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist
sudo launchctl start
files will be served from /private/tftpboot

sudo launchctl stop

What’s a CPU Year?

GFlops, G-hours, and CPU hours

1 Flops, GFlops, and TFlops
2 G-hours
3 CPU Hours and CPU Years
4 Credits

Flops, GFlops, and TFlops

FLOPS is a standard measure of computing power — “Floating Point Operations Per Second”. A GigaFlop (or Gflop) is a billion FLOPS. A TeraFlps (or TFlop) is a trillion FLOPS.

So a 1 FLOP machine will do one “operation” in a second. A 1 GFlop machine will do a billion operations in a second. A 2 GFlop machine will do two billion operations in a second. ie, by this measure, a 2 GFlop machine will do twice as much computing work in the same time as a 1 GFlop machine.


A G-hour is the measure of computing work done by a one GFLOP machine in an hour (i.e., a G-hour is one billion FLOPS per second times 3,600 seconds in an hour which equals 3.6 trillion floating point operations, which is a lot of computing.)

So in an hour’s work on a volunteer computing project, a machine that operates at one GFLOP will do one G-hour of work; and the same one hour’s contribution on a machine that operates at three GFLOPS (i.e., a faster computer) would complete three G-hours of work.

CPU Hours and CPU Years

A CPU is a computer’s processor (“Central Processing Unit”).

The term CPU Hours (processor hours) is a measure of work done; a CPU Hour is the same as a G-hour, as described above.

A with G-hours, note that a CPU-hour is is not a direct measure of time. Because some computers are faster than others, CPU Hours are reported in terms of a 1 GFLOP reference machine”. That is, An hour of work on a machine twice as fast as the reference machine is credited as Two CPU Hours.

A CPU Year is simply the amuont of computing work done by a 1 GFLOP reference machine in a year of dedicated service (8760 hours).


In place of G-hours, CPU Hours or CPU Years, you will in some places see the term Credits.

One Credit is 1/100 of a day (14.4 minutes) of computing time on a 1 GFLOP reference machine.


Encode/Decode text to/from Base64 on a Mac

$ openssl base64 -in base64.decoded.txt -out base64.encoded.txt

$ openssl base64 -d -in base64.encoded.txt -out base64.decoded.txt

How To reïnstall ALL packages in Ubuntu server

dpkg –get-selections \* | awk ‘{print $1}’ | xargs -l1 aptitude reinstall

Installing HomeBrew on MacOSX

/usr/bin/ruby -e “$(/usr/bin/curl -fsSL”

brew doctor

Show all hidden folders in MacOSX

defaults write AppleShowAllFiles YES

Relaunch Finder

reset to normal:

defaults write AppleShowAllFiles NO

error reporting in any PHP script

PHP Tip – error_reporting(-1) at the top of your script during dev to turn on all warnings, notices, etc in all versions of PHP

Add Legacy Codec Support to Quicktime X

in Terminal:
+qtdefaults write LegacyCodecsEnabled yes+

Avoiding “Assertion `insz <= dlsz'" errors when wgetting large files

Some wget installs have this nasty issue, for a quick fix, just use
curl -C – -O http://yourfile

How To Create an Empty file in MacOSX

$ mkfile 10g /path/to/my/tengigfile

How to switch JAVA on your ubuntu server

sudo update-alternatives --config java

How to check your ubuntu version

lsb_release -a

fetchmail LaunchDaemon for macosx

$ vi /Library/LaunchDaemons/local.fetchmail.plist
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “”>
<plist version=”1.0″>

$ mkdir /Users/<snip>/.fetchmail

$ sudo launchctl load -w /Library/LaunchDaemons/local.fetchmail.plist

$ tail -f /var/log/system.log

fetchmail gmail via IMAP to macosx for backup

first, enable IMAP in gmail.

$ vi .fetchmailrc

if you have a mta running:

poll protocol IMAP
user ‘
<snip>‘ there with password ‘<snip>’ is ‘<snip>‘ here
options ssl keep sslcertck sslcertpath “/Users/
folder ‘[Gmail]/All Mail’

if not, deliver via procmail to /var/mail…:

poll protocol IMAP
user ‘
<snip>‘ there with password ‘<snip>’ is ‘<snip>‘ here and wants mda “/usr/bin/procmail -d %T”
options ssl keep sslcertck sslcertpath “/Users/<snip>/.ssl/certs”
folder ‘[Gmail]/All Mail’

$ mkdir -p .ssl/certs

$ openssl s_client -connect -showcerts

(copy the key)

$ vi .ssl/certs/gmailpop.pem

(paste the key)

$ wget ; mv Equifax_Secure_Certificate_Authority.cer .ssl/certs/equifax.pem ; c_rehash ~/.ssl/certs/

$ fetchmail -v

fetchmail gmail via POP3 to macosx for backup

first, enable POP for all mail in gmail.

$ vi .fetchmailrc

if you have a mta running:

poll with proto POP3 and options no dns
user ‘<snip>’ there with password ‘<snip>’ is ‘<snip>’ here options ssl keep sslcertck sslcertpath “/Users/<snip>/.ssl/certs”

if not, deliver via procmail to /var/mail…:

poll with proto POP3 and options no dns
user ‘<snip>’ there with password ‘<snip>’ is ‘<snip>’ here and wants mda “/usr/bin/procmail -d %T” options ssl keep sslcertck sslcertpath “/Users/<snip>/.ssl/certs”

$ mkdir -p .ssl/certs

$ openssl s_client -connect -showcerts

(copy the key)

$ vi .ssl/certs/gmailpop.pem

(paste the key)

$ wget ; mv Equifax_Secure_Certificate_Authority.cer .ssl/certs/equifax.pem ; c_rehash ~/.ssl/certs/

$ fetchmail -v

Make MacOSX a central syslog server (tested on Lion)

$ pushd /System/Library/LaunchDaemons
$ sudo plutil -convert xml1 /System/Library/LaunchDaemons/
$ sudo vim /System/Library/LaunchDaemons/

add to “Sockets”:


$ sudo plutil -convert binary1 /System/Library/LaunchDaemons/
$ sudo launchctl unload /System/Library/LaunchDaemons/
$ sudo launchctl load /System/Library/LaunchDaemons/

download flash movies with Safari

If you’re using Safari, there’s an easy way to download flash videos. Open the page with the movie and press Command-Option-A, which shows the Activity window. If you’re also loading other sites, you’ll see a list of them: scroll until you find the YouTube page and click on the arrow to show details about what is being loaded.

You will certainly notice an element whose size is over 0.5MB (most of the time, over 5MB). Double-click on it (even if it is still loading), and Safari will download it. When the download is over, navigate to the file in the Finder (which will probably be called get_video) and add the extension .flv to its name.


Remove old Developer Tools after installing Developer Tools 4 on macosx

sudo /Developer-3.2.6/Library/uninstall-devtools –mode=all

Cleaning old kernels in Ubuntu

The safe way:

sudo aptitude -F ‘%p’ search linux-{image,headers,restricted}-2.6~i | grep -v `uname -r | sed -r ‘s/-[a-z0-9A-Z]+$//’

or, if you’re feeling lucky:
sudo aptitude -F ‘%p’ search linux-{image,headers,restricted}-2.6~i | grep -v `uname -r | sed -r ‘s/-[a-z0-9A-Z]+$//’` | xargs sudo aptitude purge -y

How to configure Rendezvous/Bonjour/ZeroConf in OpenBSD with avahi deamon

Since the howl package is no longer available, but the excellent avahi is, here’s how to install and configure it:

(with an older OpenBSD system, you might want to check out:

1. run a pkg_info on avahi:

Information for

framework for Multicast DNS Service Discovery

Avahi is a free, standards-compliant implementation of the Zeroconf
protocols Multicast DNS and DNS-SD.
It is a system which facilitates service discovery on a local network.
This means that you can plug your laptop or computer into a network and
instantly be able to view other people who you can chat with, find
printers to print to or find files being shared.  This kind of
technology is already found in Apple MacOS X (branded Rendezvous,
Bonjour and sometimes Zeroconf) and is very convenient.

Maintainer: Antoine Jacoutot <>


Install notice:
For proper function, multicast(4) needs to be enabled. To do so, add the
following line to /etc/rc.conf.local:

To start avahi automatically, add the following to /etc/rc.local:
(after dbus-daemon but before Zeroconf-aware applications startup)

if [ -x /usr/local/sbin/avahi-daemon ]; then
echo -n ‘ avahi-daemon’; /usr/local/sbin/avahi-daemon -D

Optionally to start the unicast DNS server configuration daemon, add
if [ -x /usr/local/sbin/avahi-dnsconfd ]; then
echo -n ‘ avahi-dnsconfd’; /usr/local/sbin/avahi-dnsconfd -D

2. install the software

pkg_add avahi

* in case you run into the following, you haven’t got xbase etc… (see the openbsd install how to on the openbsd website to learn how to install this post install):

Can’t install dbus-1.2.24p4 because of libraries
|library ICE.9.0 not found
| not found anywhere
|library SM.8.0 not found
| not found anywhere
|library X11.13.0 not found
| not found anywhere
|library Xau.9.0 not found
| not found anywhere
|library Xdmcp.10.0 not found
| not found anywhere
|library pthread-stubs.0.0 not found
| not found anywhere
|library xcb.2.1 not found
| not found anywhere
Can’t use string (“dbus-1.2.24p4”) as a HASH ref while “strict refs” in use at /usr/libdata/perl5/OpenBSD/ line 883.

if not, you’ll get another shot at some important info:

bash-4.1$ sudo pkg_add avahi
avahi-0.6.27:libgamin-0.1.10p3: ok
avahi-0.6.27:pcre-8.02p1: ok
avahi-0.6.27:glib2-2.24.1p2: ok
avahi-0.6.27:gdbm-1.8.3p0: ok
avahi-0.6.27:dbus-1.2.24p4: ok
avahi-0.6.27:libdaemon-0.13: ok
avahi-0.6.27: ok
— +avahi-0.6.27 ——————-
For proper function, multicast(4) needs to be enabled. To do so, add the
following line to /etc/rc.conf.local:

To start avahi automatically, add the following to /etc/rc.local:
(after dbus-daemon but before Zeroconf-aware applications startup)

if [ -x /usr/local/sbin/avahi-daemon ]; then
echo -n ‘ avahi-daemon’; /usr/local/sbin/avahi-daemon -D

Optionally to start the unicast DNS server configuration daemon, add
if [ -x /usr/local/sbin/avahi-dnsconfd ]; then
echo -n ‘ avahi-dnsconfd’; /usr/local/sbin/avahi-dnsconfd -D
— +dbus-1.2.24p4 ——————-
To start systemwide message dbus daemon whenever the machine boots,
add the following lines to /etc/rc.local:

if [ -x /usr/local/bin/dbus-daemon ]; then
install -d -o _dbus -g _dbus /var/run/dbus
echo -n ‘ dbus’; /usr/local/bin/dbus-daemon –system

3. add the last part to rc.local, after the avahi stuff you added in step 1

4. change /etc/myname to someting .local

5. edit /etc/avahi/avahi-daemon.conf



is my cpu 64bit capable?


$ grep flags /proc/cpuinfo
if you see a lm flag, this means Long mode cpu = 64 bit CPU

Command Line Airport commands on MacOSX

$ /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

Supported arguments:
-c[] –channel=[] Set arbitrary channel on the card
-z –disassociate Disassociate from any network
-I –getinfo Print current wireless status, e.g. signal info, BSSID, port type etc.
-s[] –scan=[] Perform a wireless broadcast scan.
Will perform a directed scan if the optional is provided
-x –xml Print info as XML
-P –psk Create PSK from specified pass phrase and SSID.
The following additional arguments must be specified with this command:
–password= Specify a WPA password
–ssid= Specify SSID when creating a PSK
-h –help Show this help

Using purge to free inactive memory on Mac OS X

A note on MacOSX Memory:

Briefly, free memory is available to be used right now; wired memory is basically system memory for the kernel and other stuff; active memory is memory being used right now; and inactive memory stores info from recently quit applications. The idea with inactive memory is that if you quit and app and start it up again it’s going to launch nice and quick because the info is still in RAM.
Inactive memory can be slow to free up

There is a command called “purge” which can be used to free up memory. You should really use it sparingly (if at all) but it does actually free up all the inactive memory without having to reboot.

The purge command comes with the developer tools so you need these installed in order to use the command.

Simply open up a terminal and run this:

$ purge

How to submit a Final Cut Studio Compressor Job via Command line

/Applications/ -clustername “This Computer” -batchname “Test Batch” -jobpath “/Volumes/.mov” -settingpath “/Users/administrator/Library/Application Support/Compressor/Formats/QuickTime/Uncompressed 10-bit .setting” -destinationpath “/”

just change settingpath & destinationpath…

How to setup Passwordless SSH

1. Local:
scp ~/.ssh/*.pub username@remote:
ssh username@remote
2. Remote
mkdir .ssh
cat ~/*.pub >> ~/.ssh/authorized_keys
rm *.pub
chmod 644 ~/.ssh/authorized_keys


Script it like this:
scp ~/.ssh/*.pub user@remote:`uname -n`.pub
ssh user@remote “cat ~/*.pub >> ~/.ssh/authorized_keys”
ssh user@remote “rm ~/*.pub”

building a transparent bridge on OpenBSD

  1. get three network cards, two for the bridge, mine are re0, em0 & em1 (re0 = admin connection to serve sshd)
  2. echo ‘dhcp’ > /etc/hostname.re0
  3. echo ‘up’ > /etc/hostname.em0
  4. echo ‘up’ > /etc/hostname.em1
  5. echo  ‘add em0’  > /etc/hostname.bridge0
  6. echo ‘add em1’ >> /etc/hostname.bridge0
  7. echo ‘blocknonip em0’ >> /etc/hostname.bridge0
  8. echo ‘blocknonip em1’ >> /etc/hostname.bridge0
  9. echo ‘up’ >> /etc/hostname.bridge0
  10. vi /etc/sysctl.conf

=> uncomment “#net.inet.ip.forwarding=1”

IPMI & Gratuitous ARP

Here’s a odd one,

on one of my networks, I discovered this flowing around:

09:56:02.660795 arp who-has (ff:ff:ff:ff:ff:ff) tell

(even though i’m not in this subnet)

For those of you who have seen this,

it’s called a Gratuitous ARP and originates from an IPMI enabled nic (Intel’s IPMI = Intelligent Platform Management Interface)

IPMI basically allows for sysadmins to monitor and administrate a machine without having to go through the OS.

I found some info here:

March 26th, 2008, 06:37 PM
This issue cropped up for me just recently so even though this is an old thread I thought I’d use it to document how I turned off the gratuitous arps on my Intel SE7221BK1-E server board.Just FYI I’m in no way a network expert, so please forgive any mistakes as I am relying on various threads I came by in Googling this issue. ;)

This link ( ) describes the hardware and software involved, which is called IPMI and stands for Intelligent Platform Management Interface. Although the HOWTO part didn’t apply directly to my particular solution it cleared up a lot of my confusion over where these arps were coming from and why.

To quote the link above

IPMI stands for Intelligent Platform Management Interface and is an open standard for machine health, and control (including remote control), and is implemented by many hardware vendors – Intel is one of the originators, and early adopters of the standard. Here are some useful things that IPMI can do on the SR2300 with Linux:

* Check on hardware health, and report on problems (via the OS, or autonomously via the network)
* Provide a watchdog timer (in case the OS goes away, or programs can otherwise not run, the machine will be reset)
* Provide remote “lights out” access to both the Linux console, and the BIOS via ethernet (no serial concentrators, multi-port serial cards, or extra cabling required)
* Provide remote, OS independent control over the reset, and power buttons via ethernet (no funny remote control power sockets, relays, or other hacks required)
* Provide remote control of a server over a modem connection
* Make emergency remote management possible from a variety of simple devices (e.g. PDAs)

It is useful to know a bit about how IPMI does its stuff – so I’ll give an overview, and try to bust some weird IPMI/Intel jargon. There is a second autonomous computer on the motherboard (or baseboard, in IPMI’s politically correct / obfusicated language), this is a very simple, low power-consumption device, which should operate as long as power is connected to the machine (including when the majority of the server is powered down) – in IPMI speak, this computer is called the BMC – the Baseboard Management Controller – it uses its own firmware, which is independent of the system BIOS.

If you have an Intel motherboard it comes with software to control the BMC in various ways, but unfortunately the software only works on Windows or Redhat/Fedora Linux, and after failed tries to get it to work remotely from another Windows machine and reading that the Linux package wouldn’t install properly on other versions of Linux (I didn’t try it on Ubuntu though) I decided to try the open source versions of IPMI.

Freeipmi ( and openipmi are two such programs and freeipmi worked for me in the end.

I couldn’t find a debian/ubuntu version of freeipmi but I did fine this Fedora rpm version ( which I was able to convert to a debian package using alien then install. I wasn’t sure how to compile and install the source version so this was “the path of least resistance” for me. :)

After downloading the .rpm file I did the following to install the package:

sudo alien -d ipmiutil-2.0.9-1.i386.rpm
sudo dpkg -i ipmiutil_2.0.9-2_i386.deb
sudo ln -s /usr/lib/ /lib/

From this long thread ( I found I decided to try and load the three modules below, the third one gave me an error so it apparently wasn’t necessary, and in fact I don’t know if I needed to load any of them manually, but I went ahead and did it anyway.

sudo modprobe i2c-dev
sudo modprobe i2c-core
sudo modprobe i2c-i810

Once freeipmi was working (at least in a basic manner, afaik there are problems reading the sensors but I haven’t tried it) I was able to turn off the gratuitous arps by reading this user’s guide ( and using the “bmc-config” command (with a change/correction for the –key-pair option based on “bmc-config –help”):

sudo bmc-config –commit –key-pair “Lan_Conf_Misc:Enable_Gratuitous_ARPs=No” -D SSIF
–driver-address=0x42 –driver-device=/dev/i2c-0 –register-spacing=1

The options in the command are particular to motherboards using the SSIF driver, for other types of boards I’d suggest reading this general description (, this Ubuntu thread ( or this other thread ( (they didn’t work for me but helped my understanding).

If anyone has any tips to add here please do, I arrived at this solution after lots of trial and error and I’m sure there’s a better/quicker way but this worked for me.

I’d like to use the ipmi software to monitor the hardware so any information on how to get this to work on my type of server board would be greatly appreciated. :)

How to Change Your Hostname In OpenBSD

How to Change Your Hostname In OpenBSD

A quick note on how to change your hostname and IP configuration in OpenBSD.

Vastly more important in BSD than it is in Linux. This is where you specify the IP address of your hostname. Change the hostname here to match your hosts new name. It should be the same as what you specify in /etc/myname.

This is just like /etc/HOSTNAME in Linux. It defines the realname of the host. Simply change it to whatever you want to call your host.

/etc/hostname.xl0 (or other interface name)
Change these to line up with what you specified in /etc/hosts.

Just like Linux. This is where you specify your DNS servers and domain resolution information.

Simply put the IP address of the default router.

How to sort files by filesize in Unix/Linux/BSD/MacOSX

du -ksl * | sort -nr

Common Aspect ratio’s

in Video:

1.33:1 or 4:3 (“Four-Three”, “Four-by-Three”, or “Four-to-Three”)

1.78:1 or 16:9 (“Sixteen-Nine”, “Sixteen-by-Nine” or “Sixteen-to-Nine”)

1.60:1 or 16:10 (Widescreen computer monitor, such 1920×1200 resolution, renowned to be close to the aesthetically pleasing golden ratio (1.618)

in Film:

1.33:1 or 4:3 (silent films)

1.85:1 (“flat”,, introduced in May, 1953)

2.35:1 (“Scope”), The common anamorphic widescreen film format in use today.

2.39:1 (“two-four-oh”), named as (rounded) 2.40:1 or 2.40

Full list from wikipedia:
Sometimes referred to as the Movietone ratio, this ratio was used briefly during the transitional period when the film industry was converting to sound, from 1926-32 approx. It is produced by superimposing an optical soundtrack over a full-gate 1.33 aperture in printing, resulting in an almost square image. Films shot in this ratio are often projected or transferred to video incorrectly using a 1.37 mask. Examples of films shot in the Movietone ratio include Sunrise, M and Hallelujah!.[9]
1.33 (4:3)
35 mm original silent film ratio, commonly known in TV and video as 4:3. Also standard ratio for MPEG-2 video compression. This format is still used in many personal video cameras today and has influenced the selection or design of other aspect ratios. It is the standard 16 mm and Super 35mm ratio.
35 mm full-screen sound film image, nearly universal in movies between 1932 and 1953. Officially adopted as the Academy ratio in 1932 by AMPAS. Rarely used in theatrical context nowadays, but occasionally used for other context.
IMAX format. Imax productions use 70 mm wide film (the same as used for 70 mm feature films), but the film runs through the camera and projector sideways. This allows for a physically larger area for each image.
1.50 (3:2)
The aspect ratio of 35 mm film used for still photography when 8 perforations are exposed. Also the native aspect ratio of VistaVision.
1.56 (14:9)
Widescreen aspect ratio sometimes used in shooting commercials etc. as a compromise format between 4:3 (12:9) and 16:9. When converted to a 16:9 frame, there is slight pillarboxing, while conversion to 4:3 creates slight letterboxing.
1.60 (16:10)
Widescreen computer monitor ratio (for instance 1920×1200 resolution).
1.66 (15:9 = 5:3)
35 mm Originally a flat ratio invented by Paramount Pictures, now a standard among several European countries; native Super 16 mm frame ratio. Sometimes this ratio is expressed more accurately as 1.67.
Early 35 mm widescreen ratio, primarily used by MGM and Warner Bros. between 1953 and 1955, and since abandoned.
1.78 (16:9 = 42:32)
Video widescreen standard, used in high-definition television, one of three ratios specified for MPEG-2 video compression. Also used increasingly in personal video cameras.
35 mm US and UK widescreen standard for theatrical film. Introduced by Universal Pictures in May, 1953. Projects approximately 3 perforations (“perfs”) of image space per 4 perf frame; films can be shot in 3-perf to save cost of film stock.
Original SuperScope ratio, also used in Univisium. Used as a flat ratio for some American studios in the 1950s, abandoned in the 1960s, but recently popularized by the Red One camera system.
70 mm standard. Originally developed for Todd-AO in the 1950s.
Specified in MPEG-2 for 2.20:1 movies, but hardly used.
35 mm anamorphic prior to 1970, used by CinemaScope (“‘Scope”) and early Panavision. The anamorphic standard has subtly changed so that modern anamorphic productions are actually 2.39,[1] but often referred to as 2.35 anyway, due to old convention. (Note that anamorphic refers to the compression of the image on film to maximize an area slightly taller than standard 4-perf Academy aperture, but presents the widest of aspect ratios.)
2.37 (64:27 = 43:33)
As of 2010, TVs have been introduced with this aspect ratio and are marketed as “21:9 cinema displays”. This aspect ratio is not recognized by storage and transmission standards.
35 mm anamorphic from 1970 onwards. 2.39:1 is sometimes rounded up to 2.40:1[1]. Often commercially branded as Panavision format or ‘Scope.
Original aspect ratio of CinemaScope before optical sound was added to the film in 1954. This was also the aspect ratio of CinemaScope 55.
Cinerama at full height (three specially captured 35 mm images projected side-by-side into one composite widescreen image).
Full frame output from Super 16 mm negative when an anamorphic lens system has been used. Effectively, an image that is of the ratio 2.66:1 is squashed onto the native 15:9 aspect ratio of a Super 16 mm negative.
MGM Camera 65 (65 mm with 1.25x anamorphic squeeze). Used only on a handful of films between 1956 and 1964, such as Ben-Hur (1959).
4.00 (4:1 = 4×3:3)
Rare use of Polyvision, three 35 mm 1.33 (4:3) images projected side by side. First used in 1927 on Abel Gance’s Napoléon.

Chroma Key green and blue in RGB & hex value’s

chroma key green:

0,255,0 or Hex #00ff00

chroma key blue:

0,0,255 or Hex #0000ff

Common Video File Sizes

Format GB/Hr Hrs/TB
DV 13 75
HDV 720p 11 90
HDV 1080i 13 75
DVCPro HD 60 17
XDCAM EX 19 52
ProRes 422 1920×1080 66 15
ProRes 422 HQ 1920×1080 99 10
Cineform Low 36 28
Cineform High 58 17
Avid DNxHD 145 8-bit 61 16
Avid DNxHD 220 10-bit 100 10
Uncompressed SD 8-bit 80 12
Uncompressed SD 10-bit 97 10
Uncompressed HD 720p 8-bit 396 2.5
Uncompressed HD 720p 10-bit 497 2
Uncompressed HD 1080i 8-bit 432 2.25
Uncompressed HD 1080i 10-bit 558 1.8

Fast and reliable way to encode Theora Ogg videos using ffmpeg, libtheora, and liboggz

if this doesn’t work for you:
ffmpeg2theora -o out.ogv
ffmpeg2theora -v 8 -o out.ogv
(To solve the video artefacts)

Try the following:

from tracey jaquith at

use ffmpeg to turn any video to “rawvideo”.
pipe its output to *another* ffmpeg to turn the video to “yuv4mpegpipe”.
pipe its output to the libtheora tool.
for videos with audio, ffmpeg create a vorbis audio .ogg file.
add tasty metadata (with liboggz utils).
combine the video and audio ogg files to an .ogv output!

Detailed example:

ffmpeg -an -deinterlace -s 400×300 -r 20.00 -i videofile.avi -vcodec rawvideo -pix_fmt yuv420p -f rawvideo – |  ffmpeg -an -f rawvideo -s 400×300 -r 20.00 -i – -f yuv4mpegpipe – |  libtheora-1.0/lt-encoder_example –video-rate-target 512k – -o tmp_video.ogv

Why the double pipe above? Some videos could not go directly to yuv4mpegpipe format such that libtheora (or ffmpeg2theora) would work all the time.

We convert to yuv420p in the rawvideo step because ffmpeg2theora has (i think) some known issues of not handling all yuv422 video inputs (i found at least a few videos that did this).

ffmpeg -y -i videofile.avi -vn -acodec libvorbis -ac 2 -ab 128k -ar 44100 tmp_audio.ogg

We do the vorbis audio outside of libtheora (or ffmpeg2theora) to avoid any issues with Audio/Video sync.
oggz-comment tmp_audio.ogg -o tmp_audio_annotated.ogg TITLE=”a title” ARTIST=”an artist” LICENSE=”” DATE=”2010″ ORGANIZATION=”an organisation name” LOCATION=http://someurl

We add the metadata to the audio vorbis ogg because adding it to the video ogv file wound up making the first video frame not a keyframe (!)
oggzmerge tmp_video.ogv tmp_audio_annotated.ogg -o out_videofile.ogv

rm tmp_video.ogv tmp_audio.ogg tmp_audio_annotated.ogg
This will end up working in Firefox 3.1 and greater — the new HTML “video” tag:

<video controls=”true” autoplay=”true” src=”http://somevideo.ogv”> </video>

How to design an iPhone-friendly Website


The iPhone can display most websites without modification, however the user often won’t be able to read the text or see anything useful without pinch-zooming on your page. Here’s how to set up an iPhone-friendly version of your website that doesn’t require zooming.

1. Set the viewport width inside the <head> section of your HTML page. You can either specify an exact width in pixels, or use “device-width”:

<meta name = “viewport” content = “width = device-width”>

<meta name=”viewport” content=”width = 320″>

If you set the width to 320 pixels, then your page will appear skinny even on desktop browsers. device-width is the better option if you’re trying to create an all-in-one page.

2. Set up some CSS.

Add the link for your CSS file in the <head> section of your HTML page:

<link href=”iphone.css” type=”text/css” rel=”stylesheet” />

If you want to use the same HTML page for both iPhone and regular web browsers, you can indicate that this CSS file is only for clients with smaller screens (like the iPhone):

<link media=”only screen and (max-device-width: 480px)”
href=”iphone.css” type=”text/css” rel=”stylesheet” />

Be sure to put this line after your other CSS links.

Now set up the iphone.css file. Start off with a body tag that also sets the width:

body {
width: 320px;
font: 12pt Helvetica, sans-serif;

Helvetica is the iPhone’s default font. You can use other fonts, although the iPhone has a rather limited set of fonts available:

  • American Typewriter
  • American Typewriter Condensed
  • Arial
  • Arial Rounded MT Bold
  • Courier New
  • Georgia
  • Helvetica
  • Marker Felt
  • Times New Roman
  • Trebuchet MS
  • Verdana
  • Zapfino

Since the iPhone’s screen width is 320 pixels, you may also want to specify some CSS tags that set the max-width of certain elements, such as images and tables:

img, table {
max-width: 320px;

If you have elements in your main page that you’d like to hide completely in the iPhone version, add CSS tags for them and set the display to none:

.mobile_hidden {
display: none;

Dynamic Pages

If your site is dynamically generated (using PHP, Rails, etc.), you can display the apporopriate headers to different devices.

Instead of the <meta> tag above, add the following line to the <head> section of your HTML pages:

<?php include(“mobile_hdr.php”);?>

And here’s the mobile_hdr.php file. This looks at the browser’s User-Agent string to determine if it’s a mobile device:


if (ereg(“(iPhone|BlackBerry|PalmSource)”, $agent) != false) {
echo <<<END
<meta name=”viewport” content=”width = device-width”>
<link rel=”stylesheet” href=”/iphone.css”>
else {
echo “<!– not mobile –>”;

This example looks for iPhone, BlackBerry and Palm user-agents.

Bookmark-Friendly Pages

1. Set the page title to something short. The max length of a title on the iPhone screen is 12 characters. If your page title is longer than that, then “Really Long Spammy Title” gets truncated to “Real…title”.

2. Create an icon. Your icon should be a square 57 x 57 pixel PNG file. You don’t need to add the rounded corners or glossy highlight to your icon; the iPhone automatically creates those effects for you. (If you don’t want those effects, you can specify a “precomposed” icon.) The icon should be named either:

“apple-touch-icon.png” or

Upload the image to the root folder of your site, and it will be used as the icon for your entire site.

To specify a custom icon for a particular page, use the following code in the header of your HTML page:

<link rel=”apple-touch-icon” href=”/custom_icon.png”/> OR
<link rel=”apple-touch-icon-precomposed” href=”/custom_icon.png”/>

Testing the Page

The best way to test your pages is on the iPhone itself. There are some browser tricks you can use, though.

You can use Safari to preview how the page will look on the iPhone. First be sure the “Develop” menu is enabled (go under Preferences -> Advanced and check the “Show Develop menu” checkbox at the bottom).

Then change Safari’s user-agent string by selecting Develop -> User Agent -> Mobile Safari (iPhone). Reload the page.

Scrolling Tricks

Mobile Safari has a bug where it ignores empty named links:

<a name=”top”></a>

That prevents something like this from working:

<a href=”#top”>Back to Top</a>

The solution is to add a bit of JavaScript instead:

<a href=”javascript:window.scrollTo(0,0)”>Back to Top</a>

How to remove Stair-Stepping artefacts in a Nikon D90 Video File

The Nikon D90 is a fantastic DSLR, but as we speak, it has a huge bug. Here’s the fix for that:


D90 Rescaler (New Nov 2008)
If you’re a D90 user I’m sure you’ve seen the stairstepping of diagonal lines, as well as the flickering aliasing of horizontal lines. No more, thanks to this plugin. Lee Wilson posted the concept behind this script on the dvxuser D90 forum. Check it out. Basically the D90 uses a lousy algorithm to scale the footage down to 720p, and what the plugin does is resampling it to the original size and scaling it back down using FCP’s bicubic interpolation instead.

Download the Final Cut Plugin here:
The Too Much Too Soon Free Plugins for Final Cut Pro and Final Cut Express (Updated Aug 2009)

How to select a schema in a Postgresql query

SELECT table_name as name FROM INFORMATION_SCHEMA.tables WHERE table_schema = ‘tablename‘;

Atomic Parsley Manual


AtomicParsley is distributed under the GPL “AS IS”, without any warranty; without even the implied warranty of merchantability or fitness for either an expressed or implied particular purpose.

AtomicParsley is a command line program for reading & writing iTune-style metadata in mpeg4 files (m4a, m4b, m4p, m4v & mp4) whether iTMS drm protected or not. AtomicParsley can set most user accessible tags, and some that iTunes doesn’t let you change. Of particular note are the Mac OS X only image modification preferences that allow artwork to be modified prior to embedding. Artwork can be converted to jpeg, file size limited, reduced & squared through setting command line preferences.

Currently, AtomicParsley lets you set these type of iTunes-style tags in MPEG-4 files:

artist            lyrics            category            TVEpisodeNum
title            album artist        artwork            TVSeasonNum
album         composer        compilation            podcast flag
genre            copyright        advisory            podcast feed url
tracknumber        grouping        stik                podcast episode GUID url
disknumber        bpm/tempo        TVNetwork            purchase date
comment        description        TVShowName        encoder tool
year             keyword        TVEpisode            play gapless

3GPP & 3GPP2 files (.3gp & .3g2) have a different set of metadata tags available called assets:

title            author            performer            genre
album    *        year            copyright            description
rating            keyword        classification            location

* album asset is only available on 3gp6 and later branded files.

All mpeg-4 based files support ‘uuid’ user-defined extensions atoms & ISO copyright notices:

tagtime        url             information
ANY user-defined atom with text        ANY user-defined atom with embedded file
ISO-copyright [at movie and/or track level(s)]
Working with AtomicParsley

The format for working with files is always the same:

/path/to/AtomicParsley /path/to/your.m4a [options]

Example to set a picture file into your mpeg4 file (jpeg or png only):
AtomicParsley /path/your.m4a –artwork /path/to/your.jpg

Exampe of setting multiple tags into your mpeg4 file:
AtomicParsley /path/your.m4a –artist “I am an Artist” –title “This is the Title” –album “The iAlbum” –genre “Progressive Zydeco” –tracknum 1/2 –disknum 1/2 –year 1985 –comment ‘Superlative (I made this TODAY!!!)’ –lyrics ‘Go, Go, GO! (repeat)’ –composer “I Claudius” –grouping “Ennui” –copyright “LowDown Recordings” –bpm 20 –compilation true –advisory clean –artwork /path/to/your.jpg –artwork /path/to/your2.jpg

Example of using the artwork preferences to limit the embedded artwork size & dimensions:
export PIC_OPTIONS=”MaxDimensions=400:MaxKBytes=50:AllPixJPEG=true:SquareUp:removeTempPix”
AtomicParsley /path/your.m4a –artwork /path/to/your.jpg

Example to change your own mpeg4 file into an iTunes TV show:
AtomicParsley /path/your.mp4 –genre “TV Shows” –stik “TV Show” –TVNetwork FOOnn –TVShowName “Some Showname” –TVEpisode “1120” –TVEpisodeNum 20 –TVSeason 11

Example to change your own mpeg4 file into a Video Podcast (FrontRow requires the purl atom, iTunes doesn’t):
AtomicParsley /path/your.mp4 –podcastFlag true –stik “Movie” –podcastURL “”

Example of extracting embedded artwork in your mpeg4 file to the same folder:
AtomicParsley /path/your.m4a –extractPix

To see the atom tree of your mpeg4 file:
AtomicParsley /path/your.m4a -T

To see the metadata tags set into your mpeg4 file:
AtomicParsley /path/your.m4a -t

Note Mac users: iTunes looks at type/creator when opening an mpeg4 file. As of AtomicParsley 0.8.1, you no longer need to change extensions to/from anything – this is automatically determined through the information in the file itself and is set accordingly. A podcast mpeg-4 file may cause some concern at first because it shows up as being a protected file with a lock on the icon. This is nothing to be concerned about; iTunes uses the same icon/file info for ‘M4B ‘ and ‘M4P ‘ types – that’s it. They aren’t drm’ed in any way, just a sharing of icon/Finder info.
Note2: iTMS purchased media often has ©day set to “2005-09-06T07:00:00Z” or something similar. This is normal and is called Coordinated Universal Time and is denoted by the Z at the end. iTunes only displays the year, but in fact there is an entire date that is there.

Writing out is non-destructive – the original file is unaltered. There is a command-line option to over write the source file: use it with caution or on duplicates. Starting with version 0.9, AtomicParsley can used available padding to rapidly update tags. This option is only available with the –overWrite option.

Erasing atoms with AtomicParsley

To delete metadata “”:
AtomicParsley /path/your.m4a –artist “” –title “”

To delete all artwork (on the covr atom):
AtomicParsley /path/your.m4a –artwork REMOVE_ALL

To delete every piece of metadata (in the “moov.udta.meta.ilst” hierarchy); drm files will still play as normally:
AtomicParsley /path/your.m4a –metaEnema

Setting 3gp assets with AtomicParsley

3gp metadata assets are more complicated than iTunes-style metadata. Assets can be in either utf8 or utf16, and are for a specific language. Multiple like-named tags differing in the language are supported allowing for up to around 480 tags per asset. See the AtomicParsley –3gp-help page for more. 3gp assets are only available on 3gp files – setting iTunes-style metadata is not allowed.

3gp assets have more options than iTunes tags – most are hardcoded with defaults. Defaults are as follows:

Default encoding: utf8 (utf16 also available)
Default language: ‘eng’ (about 480 other languages supported; none are currently checked)
Default Rating: entity = ‘NONE’ (4spaces); criteria = ‘NONE’ (4 spaces)
Default Classification:  entity = ‘NONE’ (4 spaces); index = 0
Default Location: Longitude: = -73.98; Latitude = 40.77; Altitude = 4.3; Role = shooting location; Astronomical Body = Earth; Additional notes = ‘none’ [Central Park] – altitude is measured in meters; negative values are appended with a capital letter (S for southern latitudes, W for western longitudes, B for below sea level.)

Setting a title asset for the spanish language in utf16:
AtomicParsley /path/your.3g2 –3gp-title “The Rain In Spain…” lang=spa UTF16

Setting a album asset (with tracknumber) for the sve language in utf8:
AtomicParsley /path/your.3g2 –3gp-album “Bjorn Diddles His Banjo of Death” track=2 lang=sve

Setting a rating asset for the japanese language in utf16:
AtomicParsley /path/your.3g2 –3gp-rating “A superlative 4-on-the-floor house anthem.” entity=MOMA criteria=PU18 lang=jpn UTF16

Setting a location asset for the english language in utf16:
AtomicParsley /path/your.3g2 –3gp-location “Bethesda Terrace” latitude=40.77 longitude=73.98W altitude=4.3B role=”real” body=Earth notes=”Underground in Central Park” UTF16

Setting a keyword asset for the french language in utf8:
AtomicParsley /path/your.3gp –3gp-keyword “keywords=France,Paris,Basilique du Sacré-Cœur, Sewers, stinky cheeses” lang=fra

Setting copyright notices at movie and/or track level

The only defined piece of metadata designed for descriptive annotations of the presentation/track is the copyright notice. If your file contains 4 tracks, there are 5 places to set copyright notices, max — each of the tracks + movie level. There may be multiple notices, differing by language & may be present at any combination of movie and/or track level in either utf8 or utf16. Defaults are lang=eng & utf8.

Please note that at movie level, this notice is identical the the 3gp copyright asset, and if present for the same langauges this will overwrite the exising asset.

AtomicParsley /path/your.m4a –ISO-copyright “© 2006, Lalalandia Productions” movie UTF16
AtomicParsley /path/your.m4a –ISO-copyright “© 2006, Produções Da Estrada” track lang=por
AtomicParsley /path/your.m4a –ISO-copyright “©2006. USA” track=1 –ISO-copyright “©2006. Ελλάδα” track=2 lang=gre –ISO-copyright “©2006. ਬਣਾਉਟੀ” track=5 lang=pun –ISO-copyright “Callaloo Prductions, ©2006” movie lang=car

Custom uuid atoms with AtomicParsley

According the the specifications for the mpeg-4 file format, any atom not listed is reserved & is unavailable for use. However, the specification & the mpeg-4 registration authority allow for user defined extension via a mechanism called the ‘uuid’ atom. This type of atom actually has a ‘uuid’ name, but following that is 16 bytes (the actual UUID representation itself).

Because anyone or any program can implement UUID atoms, a special version of the UUID form is used – and when read back, special checks are in place to determine if any UUIDs found were created by AtomicParsley. In this way, UUIDs created by 3rd parties are ignored for reading, listings & extractions. This is all handled transparently via a simple mechanism: –meta-uuid ATOM text “Some Text”

where ATOM can be any 4 letter atom name you choose – carrying any text information you choose. Support is also present for directly embedding a file via a similar mechanism: –meta-uuid ATOM file /path/to/target/file.ext

Create your own atoms directly:
AtomicParsley /path/your.m4a –meta-uuid “YZAB” text “Some string value to set”
AtomicParsley /path/your.m4a –meta-uuid “®USP” text “6125480”
AtomicParsley /path/your.m4a –meta-uuid “©212” text “CBGB OMFUG last set”
AtomicParsley /path/your.m4a –meta-uuid “docu” file ~/Desktop/
AtomicParsley /path/your.m4a –meta-uuid “inst” file /Files/archive.dmg description=”Installer”

Deleting a custom uuid atom:
AtomicParsley /path/your.m4a –meta-uuid “©212” text “”
AtomicParsley /path/your.m4a –meta-uuid “docu” file “”

Set the tagging time (the moment the tag was written) on a uuid=tdtg atom:
AtomicParsley /path/your.m4a –tagtime

Set a url on a uuid=©url atom:
AtomicParsley /path/your.m4a –url “”

Manually removing uuid atoms:
AP /path/your.m4a –manualAtomRemove “moov.trak[1].uuid=55534d54-21d2-4fce-bb88-695cfac9c740”
AP /path/your.m4a –manualAtomRemove “moov.udta.meta.uuid=1fed6656-d911-5385-9cb2-cb2c100f06e7”

Note: any program can create a uuid atom – and are listed differently in an atom tree based on origin. Non-AP created atoms are listed slightly differently than AP-created uuid atoms:

non-AtomicParsley created uuid (from a Sony PSP file):
Atom uuid=55534d54-21d2-4fce-bb88-695cfac9c740 @ …

uuid created by AtomicParsley:

Atom uuid=971451ee-0928-59f2-b81f-b1372b62565d(APuuid=ATOM) @ …

Here you can see that after the hex-a-decimal representation of the uuid, AP has discovered an AtomicParsley-set uuid atom, and lists its name after APuuid).

Compiling AtomicParsley

A fresh svn checkout will always be the most recent version available. AtomicParsley was developed on Mac OS X 10.4x, but should be able to compile on older versions. Only gcc4 was used to compile on Mac OS X.

cd AtomicParsley && ./build

Releases of AtomicParsley are also available built using:

• Debian ‘Sarge’ 31r0a-i386 with gcc/g++4.02, libc6_2.3.5-8 & libstdc++6_4.0.2-2
• Microsoft Windows XP SP2 with VisualC++ 6.0

AtomicParsley & new atoms, bugs, etc….

If you should come across an atom (in the moov.udta.meta.ilst hierarchy) that AtomicParsley doesn’t handle, please let me know about it – I would like to be able to support it. Note: AtomicParsley will never support iTunes-style “—-” atoms. To facilitate implementation, a sample of the new atom would be needed as it could come in a few different types – or even an entirely new type.

Should you find a bug or a suspect behavior, please post to the bugs section or forum at sourceforge. A sample of the file that demonstrates the behavior would be best. Please also provide the name of the encoding program used to produce the file. Please refrain from using email as a primary means of support – it isn’t. Fun though it is to answer some questions repeatedly, imagine the fun a non-response would be.

Please remember: as long as it works on Mac OS X – to me it works *perfectly* good enough. If you find a bug on another platform (probably Windows, because Linux will have most of the same encoders as on Mac OS X) or with any form of commercial encoder, a sample would probably go a long way to making AtomicParsley work on your files.

Things to watch out for & avoid with AtomicParsley

• iTunes text tags (except for lyics) are restricted to 255 characters

• Many of the iTMS (both drm and podcast) files have **ID atoms. What they stand for can only be guessed, but their values have meaning only to Apple – as such they are displayed in raw hex. Since all metadata can be stripped (including these **ID atoms), and a drm file still plays properly, these tags can be considered superfluous metadata.

• iTunes 7 incorporates a feature called gapless playback. For unknown reason, iTunes incorporates NULL space at the end of mpeg4 files. This may (or may not) be part of the mechanism iTunes uses as part of its gapless playback. Normally, this NULL space is replicated when AP writes out. It is not if DEFAULT_PAD=0 is set.

How to mount an external LVM partition under Ubuntu 10.10

Install lvm2:
$ sudo apt-get install lvm2

Load the necessary module(s):
$ sudo modprobe dm-mod

Scan your system for LVM volumes:
$ sudo vgscan

Activate the volume:
$ sudo vgchange -ay VolGroup00

Find the logical volume that has your external root file system:
$ sudo lvs

Create a mount point for that volume:
$ sudo mkdir /mnt/fcroot

Mount it:
$ sudo mount /dev/VolGroup00/LogVol00 /mnt/fcroot -o ro,user

How to substitute something by a line break in vi

use the normal substitute commands such as:


but use the keyboard shortcut CtrlVCtrlM to create a new-line character

How to burn an iso file on MacOSX via Command Line

hdiutil burn image.iso

How to replace a string in a file with awk on a *nix system

cat oldfile | awk ‘{gsub(“;old text string”, “new text string”); print}’ > newfile
mv -f newfile oldfile

A word from the author

We all forget things.
Sometimes this a good thing, but often there is a catch.
We don’t always remember the content of that what we forgot, but the subject of it sticks in our head. Like that title of that song by that artist you can’t remember or that amazing page from a book you loved.
Now everyone has his or her own system to keep this information somewhere, and we are very capable to keep massive amounts of data in our brain without noticable effort. However, this does not share the information outside your personal sphere.

So, for you, here are my pieces of information I’d like to share.

Bram Walraet