Instructions:
- Get the latest build from the arrozcru autobuilds page
- Unzip the folder into C:/Program Files/ffmpeg
- Add C:/Program Files/ffmpeg/bin to your system’s PATH environment variable
Optional libx264 preset setup:
If you use libx264 presets (by using the -vpre flag) you need to do the following setup.
- Create a HOME environment variable for your user pointing to your home directory. (e.g. for Vista C:/Users/moose or for XP C:/Documents and Settings/moose )
- Create a .ffmpeg folder in your home directory
- Copy the preset files from C:/Program Files/ffmpeg/share/*.ffpreset into %HOME%/.ffmpeg
- Now you can open a command prompt and use ffmpeg. :D (e.g. This is my Vimeo video conversion command. ffmpeg -i input.mov -vcodec libx264 -vpre hq -crf 24 -g 25 -acodec libmp3lame -ab 192k -ar 44100 output.mp4 )
*note: libfaac is not included in the build since libfaac is considered to be a non-free plugin. :(
2 Comments »
Thanks to Mozilla for providing excellent linux font DPI support.
On my Gentoo setup, I added a Xft.dpi setting go my ~/.Xdefaults file. Now my fonts look normal again. :)
Before:

After:

No Comments »
Instructions for installing xorg-server and hal on gentoo.
I’m writing this because the gentoo documentation for X setup is very outdated. Gentoo now uses xorg 1.5 which uses hal to setup devices automatically instead of having to configure /etc/X11/xorg.conf. The Xorg 1.5 update guide might be a little helpful, but it’s missing some info and is a bit vague in places.
Xorg-server 1.5 setup
Make sure your kernel is compiled with Event interface support. (If not, see Gentoo Handbook: Configuring the kernel for help recompiling your kernel)
Device Drivers --->
Input device support --->
--- Input device support
[*] Event interface
Add X and hal USE flags (the “–alpha-order” is optional, but I like to keep my USE flags organized)
flagedit --alpha-order +hal +X
(or equivalently with euse. euse is from the app-portage/gentoolkit package)
Add to /etc/make.conf
INPUT_DEVICES="evdev"
# Change the video driver to match your video card
# or install a bunch and let hal choose
VIDEO_DRIVER="nv nvidia radeon radeonhd intel sis via vesa fbdev"
Install xorg-server (which will also install hal since the hal USE flag is now enabled)
Add hal policy files so hal can auto-detect your devices. Doesn’t hurt to add them all, hal will figure out what it needs.
cp /usr/share/hal/fdi/policy/10osvendor/* /etc/hal/fdi/policy
Add hald to startup and start hald
rc-config add hald default
/etc/init.d/hald start
Don’t need any /etc/X11/xorg.conf file
mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
Now startx
No Comments »
I recently configured the wireless on my X61 Tablet for Gentoo. I have a Intel 4965 AGN wireless card.
lspci | grep -i wireless
03:00.0 Network Controller: Intel Corporation PRO/Wireless 4965 AG or AGN Network Connection (rev 61)
Relevant kernel options (from gentoo-sources 2.6.28-r5 kernel)
Device Drivers --->
[*] Network device support --->
Wireless LAN --->
{*} Intel Wireless Wifi Core
<M> Intel Wireless WiFi Next Gen AGN
[*] Intel Wireless WiFi 4965AGN
Install wpa_supplicant and wireless-tools
emerge -av wpa_supplicant wireless-tools
Create symlink so Gentoo will initialize the wlan0 at startup
cd /etc/init.d
ln -s net.lo net.wlan0
/etc/conf.d/net
modules=( "wpa_supplicant" )
iwconfig_wlan0="mode managed"
wpa_supplicant_wlan0="-Dwext"
/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
network={
ssid="MySSID"
scan_ssid=1
key_mgmt=WPA-PSK
psk="password"
priority=5
}
I was getting SCICSIFFLAG File Not Found errors when trying to bring up my wlan0 interface. A look at the dmesg log revealed that the iwlagn module was trying to access iwlwifi-4965-2.ucode, so I emerged iwl4965-ucode to fix that.
Reinitialize the interface to see if everything worked
/etc/init.d/net.wlan0 restart
No Comments »
Creating a bootable usb stick with the Gparted live iso in Ubuntu. Gparted is a graphical partition editor which can resize, move, copy, create, delete your hard drive partitions.
Overview:
- Format your usb stick to Fat16 and make it bootable using gparted.
- Install the gparted-live*.iso using unetbootin. (unetbootin also automatically installs the syslinux bootloader)
- Reinstall syslinux onto usb stick. (Gparted’s live cd requires syslinux newer than ver 3.71. Currently (May 7 2009) Ubuntu 9.04 Jaunty has syslinux 3.63. Use
apt-cache show syslinux | grep "^Filename" to check Ubuntu’s version)
Installation Steps
1. Install gparted and unetbootin
sudo aptitude install gparted unetbootin
2. Download the gparted live iso and the latest syslinux.
wget http://superb-west.dl.sourceforge.net/sourceforge/gparted/gparted-live-0.4.4-1.iso
wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.80.tar.bz2
3. Insert your usb stick into the computer, and copy any files you want to save to your hard drive. You will be reformatting your stick and will lose all the files on the usb drive.
4. Run gparted.
Select your usb drive. (Probably something like /dev/sdc). Right click on the partition and select Unmount to unmount the drive. Format the drive to Fat16 and apply. Then make the usb drive bootable by going to Manage Flags and selecting the boot flag.

Exit gparted.
5. Remount your usb drive by unplugging and replugging your usb stick.
6. Run unetbootin
Select Diskimage ISO and locate the gparted-*.iso that you downloaded. Make sure the correct partition is selected at the bottom and click OK.

Don’t reboot yet. Just exit unetbootin.
7. Now, you would be done, except that Ubuntu’s syslinux is version 3.63 and the gparted live iso requires at least syslinux version 3.71, so you need to reinstall syslinux onto your usb stick.
Unpack the syslinux tarball you downloaded.
tar xjvf syslinux-3.80.tar.bz2
Now install syslinux onto your usb stick
cd syslinux-3.80/linux
sudo ./syslinux -s /dev/sdc1
8. Now you’re done. Reboot using your new gparted bootable usb stick.
End Notes:
This method should work on other bootable isos too.
You could try to use Fat32 if your motherboard supports booting from Fat32 USB devices. Fat16 is generally more compatible though.
If your USB stick is bigger than the the allowable Fat16 size (2gb), make two partitions: first a 1-2gb Fat16 partition for your boot drive, and a second Fat32 partition with the rest of the space.
No Comments »
Add these lines to your ~/.bashrc to make colorful grep | less output.
alias grep='grep --color=always'
export LESS='-R'
No Comments »
Often the unix commands basename and dirname are useful in shell scripts, but how do you use these in c or c++?.
The C way: libgen.h
If you’re working in c, the posix header libgen.h provides dirname and basename functions, with some limitations: They only work with char *, and dirname will modify the char * you pass into it so you need to make a copy of your original path if you wish to keep it. Example code:
// libgen_example.c
// Demonstrate libgen.h usage and pitfalls
// Compile: gcc -g -o libgen_example libgen_example.c
#include
<libgen.h> //basename and dirname
#include <string.h> //strlen and strcpy
#include <stdio.h> //printf
#include <stdlib.h> //malloc
int main(int argc, char* argv[]) {
// Demonstrate how dirname changes the path you input to it
char path[] = "default/path/to/nowhere.txt";
printf("path='%s'\n", path);
char * dir = dirname(path);
printf("path='%s' dir='%s'\n", path, dir);
char * base = basename(path);
printf("path='%s' dir='%s' base='%s'\n\n",
path, dir, base);
// Since dirname changed path, base is now "to"
// instead of "nowhere.txt" as we might have expected.
// Output:
// path='default/path/to/nowhere.txt'
// path='default/path/to' dir='default/path/to'
// path='default/path/to' dir='default/path/to' base='to'
//========
// Demonstrate c string copying
const char * another_path = "another/path";
char * modifiable_copy = (char *)malloc(strlen(another_path) + 1);
strcpy(modifiable_copy, another_path);
char * another_dir = dirname(modifiable_copy);
printf("another_path='%s'\n", another_path);
printf("modifiable_copy='%s'\n", modifiable_copy);
printf("another_dir='%s'\n\n", another_dir);
// note that after this free, another_dir is now also
// invalid since it pointed to the modifiable_copy's memory
free(modifiable_copy);
// Output:
// another_path='another/path'
// modifiable_copy='another'
// another_dir='another'
//========
// const strings declared as char * can cause segfaults
char * char_pointer_path = "char/pointer/path";
printf("char_pointer_path='%s'\n", char_pointer_path);
char * char_pointer_dir = dirname(char_pointer_path);
printf("char_pointer_path='%s' char_pointer_dir='%s'\n",
char_pointer_path, char_pointer_dir);
// Output:
// char_pointer_path='char/pointer/path'
// Segmentation fault
}
The C++ way: boost::filesystem
If you’re looking for a better c++ solution, see the c++ boost filesystem library. boost::filesystem::path.parent_path() can be used like dirname and boost::filesystem::path.filename() acts like basename.
The boost::filesystem library also has many other useful functions for dealing with files and paths (e.g. fs::complete(path) for obtaining an absolute path, fs::exists(path) will check if the path exists, fs::create_directories(path), fs::remove(path), fs::copy_file(from,to) name a few). Note that some of these are functions are boost::filesystem::path methods and some are in boost::filesystem. According to the faq, operations done by the operating system are provided in boost::filesystem functions, but functions just performed on the lexical path (just path string manipulations) are provided as boost::filesystem::path methods.
// filesystem_example.cpp
// Demonstrate using boost::filesystem
// Compile: g++ -I /usr/local/include/boost-1_38/ -L /usr/local/lib -lboost_filesystem-gcc41-mt-1_38 -o filesystem_example filesystem_example.cpp
#include <boost/filesystem.hpp>
#include <iostream>
namespace fs = boost::filesystem;
int main(int argc, char* argv[])
{
fs::path pathname("default/path/to/nowhere.txt");
std::string dirname = pathname.parent_path().string();
std::string basename = pathname.filename();
std::cout << "pathname = " << pathname << std::endl;
std::cout << "dirname = " << dirname << std::endl;
std::cout << "basename = " << basename << std::endl;
// Output:
// pathname = default/path/to/nowhere.txt
// dirname = default/path/to
// basename = nowhere.txt
std::cout << std::endl;
std::cout << "extension = " << pathname.extension() << std::endl;
std::cout << "complete = " << fs::complete(pathname) << std::endl;
std::cout << "exists = " << ((fs::exists(pathname)) ? "true" : "false") << std::endl;
// Output:
// extension = .txt
// complete = /home/moose/default/path/to/nowhere.txt
// exists = false
}
Tags = basename, boost, c++, cpp, dirname, example, filesystem, libgen.h, path, string
No Comments »
My experiences as a [g]vim user trying out emacs.
Day 1:
Emacs commands
Running emacs was no problem, as it was already installed from Fedora’s repository. Reading through some emacs tutorials, I found Emacs For VI Users very helpful. Probably my most used vi commands are delete line (dd), yank line (yy), and put (p or P). Emacs confusingly uses “yank” to describe the vi equivalent “put” command of inserting saved text into the document. Getting used to the sequences of ctrl / alt + key is strange when I’m used to the efficient vi commands. ”yy” becomes “Ctrl+a Ctrl+k Ctrl+k Ctrl+/”.
Tab behavior
Started trying to edit some c++ files using emacs, but found that the default tabbing behavior was messing up my indentation. The default emacs uses 2 spaces per indentation, and will use the tab key to automatically indent code instead of inserting a tab character. I like to tab-indent my code and view it as 4 spaces / tab. This was frustratingly difficult to solve, as emacs has so many options, and many of the emacs options have cryptic names and unclear descriptions. I finally found some sane lines to put into my ~/.emacs file from Emacs Tips N Tricks For Everybody. The
(global-set-key "\C-m" 'newline-and-indent)
line is really nice to emulate vi’s autoindent feature. Understanding GNU Emacs and Tabs is also useful for understanding emacs’s special tabbing behavior.
Day 2:
Antialiased fonts
Discovered that emacs 23 supports antialiased fonts, but there’s no stable release yet, and no Fedora 8 rpm. So, I downloaded the source from cvs and built. Now running
emacs --font="monospace-10"
works, and emacs looks great.
Start in background
I wrote a bash wrapper to always start emacs in the background (similar to gvim) with the monospace font.
#!/bin/bash
# start emacs in the background with the monospace font
exec emacs-23.0.92.1 --font="monospace-10" "$@" &
My ~/.bashrc has an alias to run this wrapper. (I put the wrapper in ~/bin/emacs)
# .bashrc alias
alias emacs="~/bin/emacs"
Matlab files
Opening a matlab .m file tries to use the ObjC mode. You can add the matlab mode to emacs using the matlab.el file from matlab-emacs. I put the file at ~/.emacs_addons/matlab.el and added these lines to my ~/.emacs file:
; Add addons dir to path
(setq load-path
(append (list nil "~/.emacs_addons")
load-path))
; Add matlab.el module
(autoload 'matlab-mode "matlab" "Enter MATLAB mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))
(autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t)
Regular expressions
Emacs offers search and replace with regular expressions using the Ctrl-Alt-% command, with some caveats
Tab bar
Opening multiple files in emacs puts each file into a buffer, but there is no [g]vim/firefox-like tab bar which shows the open files. You have to go through the list of buffers or split your window. But at least there is the TabBar mode addon.
No Comments »
Find the manufacturer and version of your motherboard with this command:
sudo dmidecode | grep "Base Board" -A 13
Example output:
Base Board Information
Manufacturer: ASUSTeK Computer INC.
Product Name: Maximus Formula
Version: Rev 1.xx
Serial Number: XXXXXXXXXXX
Asset Tag: To Be Filled By O.E.M.
Features:
Board is a hosting board
Board is replaceable
Location In Chassis: To Be Filled By O.E.M.
Chassis Handle: 0x0003
Type: Motherboard
Contained Object Handles: 0
Tags = dmidecode, find, information, manufacturer, motherboard
No Comments »
Tags = 2008, ap, biden, election, google, map, news, palin, polls, president, results, vote
No Comments »
So even though hash_map and hash_set aren’t a part of the C++ standard, there are still implementations included with the gcc compiler. You have to include or and a little magic to get them to work properly with std::string keys.
// Example code using a hash_set with std::string keys on gcc
// Example based on hash_set code from "6.7 Using Hashed Containers"
// in O'Reilly C++ Cookbook by Stephens, Diggins, Turkanis & Cogswell (2006)
// and gcc fix from post http://gcc.gnu.org/ml/libstdc++/2002-04/msg00107.html
// Tested with g++ 4.1.2
// Compile with:
// g++ -o hash hash.cpp
// Kristi Tsukida <kristi.tsukida at gmail dot com> 30-10-2008
#include <iostream>
#include <string>
#include <ext/hash_set>
using namespace std;
// The __gnu_cxx namespace contains the hash_set since it's not standard c++
using namespace __gnu_cxx;
// This is the magic that will allow the usage of string keys in the hash
namespace __gnu_cxx
{
template<> struct hash< std::string >
{
size_t operator()( const std::string& x ) const
{
return hash< const char* >()( x.c_str() );
}
};
}
// must specify the hash<string> hash function
typedef hash_set<string, hash<string> > string_hash_set;
int main()
{
string_hash_set hs;
string s = "bravo";
hs.insert(s);
s = "alpha";
hs.insert(s);
s = "charlie";
hs.insert(s);
for(string_hash_set::const_iterator p = hs.begin(); p!= hs.end(); ++p)
{
cout << *p << endl;
}
}
Tags = c++, example, gcc, hash, hash table, hash_map, hash_set, std, string, __gnu_cxx
1 Comment »
General instructions to rebuild a Fedora source rpm.
Note: This example uses the vlc source rpm, but it doesn’t work on my Fedora 8 system because there are problems installing dependencies, but the general commands should work on other packages
- Install build tools
su -c 'yum install yum-utils rpmdevtools'
- Download source package. Either use yumdownloader to download from an existing repository:
yumdownloader --source vlc
or download directly from a server
wget -nd ftp://ftp.pbone.net/mirror/rpm.livna.org/fedora/development/SRPMS/\
vlc-0.9.0-0.5.20080802git.lvn10.src.rpm
- Install the source package. This will unpack the source into your /$HOME/rpmbuild directory.
rpm -Uvh vlc-0.8.6i-1.lvn8.src.rpm
- Install build dependencies for the source package
su -c 'yum-builddep vlc-0.8.6i-1.lvn8.src.rpm'
- Edit the spec file
cd ~/rpmbuild/SPECS
vim vlc.spec
- Add the new source package
cd ../SOURCES
wget -nd http://download.videolan.org/pub/videolan/vlc/0.9.2/vlc-0.9.2.tar.bz2
- Build the rpm
cd ../SPECS
rpmbuild -bb vlc.spec
- Install the rpm
cd ../RPMS/x86_64
rpm -Uvh vlc-0.9.2.fc8.x86_64.rpm
References:
Building a kernel from the src rpm
Fedora rpm guide
Tags = 0.9.2, fedora, package, rebuild, recompile, rpm, rpmbuild, source, update, vlc, yum
No Comments »
Skymaps provides free monthly constellation maps which are nicely printable. It also includes a monthly list of astronomical events such as meteor showers, eclipses, and moon phases.
Tags = constellation, free, map, meteor, moon, planets, skymaps, stars
No Comments »
Add all files which aren’t currently under version control to the svn:ignore property.
for line in $(svn status | grep ^? | awk '{print $2}')
do
pushd $(dirname $line)
svn propset svn:ignore "$(svn propget svn:ignore)$(echo -e "\n$(basename $line)")" .
popd
done
svn commit
Tags = ignore, propget, propset, svn
2 Comments »

isnoop tracker screenshot
Isnoop pachage tracker will generate an rss feed for UPS, FedEx, USPS, or DHL package tracking information and view your package’s path in a google map. Useful when you’re anxiously awaiting a package to arrive.
Tags = dhl, fedex, google, isnoop, map, package, rss, tracker, ups, usps
No Comments »