linux-find-motherboard-information

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

A few sites to keep updated on election day:

Google Election Maps Shows live and historic results, polls, and Palin and Biden’s life journey

Google Election 2008 News Information on voting and election news

AP Election 2008 News Election news and webcasts

CNN Election Results

using-gcc-c-hash-classes-with-strings

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;
	}
 
}
fedora-rebuild-a-source-package

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

  1. Install build tools
    su -c 'yum install yum-utils rpmdevtools'
  2. 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
  3. Install the source package. This will unpack the source into your /$HOME/rpmbuild directory.
    rpm -Uvh vlc-0.8.6i-1.lvn8.src.rpm
  4. Install build dependencies for the source package
    su -c 'yum-builddep vlc-0.8.6i-1.lvn8.src.rpm'
  5. Edit the spec file
    cd ~/rpmbuild/SPECS
    vim vlc.spec
  6. 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
  7. Build the rpm
    cd ../SPECS
    rpmbuild -bb vlc.spec
  8. 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

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.

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
isnoop tracker screenshot

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.

google-chrome-on-linux-via-wine

So it’s possible to run the Google Chrome browser using Wine (latest dev version 1.1.4), though it’s kinda slow, and won’t do any https sites.

Ubuntu thread w/ instructions (These didn’t work for me on Fedora 8)

Wine App DB page w/instructions (These worked for me on Fedora 8)

The Yellow Icon downloads section has a bunch of cool icons / images / wallpapers.

webgadgets-amazon-price-tracker

Looks like the Webgadgets Amazon Price Tracker just got a new makeover.  This is a pretty cool site which tracks the prices of things on Amazon and graphs them so you know if you’re getting a good deal.  You can also track everything in your wishlist if you create a public wishlist on Amazon.

ubuntu-wacom-tablet-hotplugging

Update 11-04-2008: The release version of Ubuntu 8.10 Intrepid should work out of the box, so you don’t need to do any of this. However, only the stylus works. If linuxwacom comes out with an update to use the eraser and tablet buttons, you might need to manually install the linuxwacom driver, but right now, enjoy the “it just works” philosophy. :)

Ubuntu 8.10 “Intrepid Ibis” will use Xorg 7.4’s input hotplugging, allowing auto-detection of input devices (e.g. keyboards, mice, tablets) during an X session. (Previously, input devices were only detected at the startup of an X session.)

Note that there are still a number of bugs with hotplugging:

  • you must install the latest linuxwacom driver to get correct clicking
  • hotplugging will only recognize the stylus events (so no eraser or express buttons)
  • unplugging the tablet causes X to crash. Edit 9-20-08: There is a line in the linuxwacom source you need to edit to fix this (see step 4 of Manual Installation below). [linuxwacom post] Edit 11-04-08: Intrepid updated the linuxwacom driver that ships with Intrepid, so you don’t need to install the updated linuxwacom driver.

Installing LinuxWacom driver in Intrepid
(based off the Hardy linuxwacom install thread, here. Tested on Intrepid alpha 6 LiveCD)

Easy Method:

  1. Download my install_linuxwacom script
  2. Run the script
    chmod +x install_linuxwacom
    ./install_linuxwacom
  3. Enjoy!

Manual Installation Steps:

  1. Install required packages
    sudo apt-get update
    sudo apt-get install linux-headers-$(uname -r) build-essential x11proto-core-dev libxau-dev libxdmcp-dev x11proto-input-dev x11proto-kb-dev xtrans-dev libx11-dev x11proto-xext-dev libxext-dev libxi-dev linux-libc-dev libc6-dev libncurses5-dev xserver-xorg-dev tk-dev tcl-dev -y
  2. Download latest linuxwacom-dev package from linuxwacom (0.8.1-4 as of this writing)
    wget -nd http://prdownloads.sourceforge.net/linuxwacom/
    linuxwacom-0.8.1-4.tar.bz2
  3. Extract the source
    tar xjvf linuxwacom-0.8.1-4.tar.bz2
    cd linuxwacom-0.8.1-4
  4. To fix the X crashing when unplugging the tablet, edit line 381 of src/xdrv/wcmConfig.c replacing WCM_UNINIT_CALLED with WCM_XORG_XSERVER_1_4
    sed -i -e '381s/WCM_UNINIT_CALLED/WCM_XORG_XSERVER_1_4/' src/xdrv/wcmConfig.c
  5. Compile the driver
    ./configure --enable-wacom
    make
    sudo make install
  6. (Optional) You can test the kernel module before installing it. Plug in your tablet and see if it works correctly after executing these commands.
    sudo rmmod wacom
    sudo insmod src/2.6.26/wacom.ko

    If it doesn’t work, you can reload the original driver. (Or just reboot your computer)

    sudo rmmod wacom
    sudo modprobe wacom
  7. Install the kernel module (and backup the original). (Note: The 2.6.26 module works with Intrepid’s 2.6.27 kernel)
    cp /lib/modules/$(uname -r)/kernel/drivers/input/tablet/wacom.ko wacom.ko.$(uname -r)
    sudo cp src/2.6.26/wacom.ko /lib/modules/$(uname -r)/kernel/drivers/input/tablet/wacom.ko
  8. Reload the kernel module with the new version
    sudo rmmod wacom
    sudo modprobe wacom
  9. Enjoy!

Read the rest of this entry »

ubuntu-rebuild-a-source-package

# install deb build tools

sudo apt-get install build-essential fakeroot dpkg-dev devscripts

# download the source code

apt-get source package

# install other packages needed to build

sudo apt-get build-dep package
cd package

# update the version in the changelog

dch -i

# make any changes to the source
# e.g. vim debian/rules

# then build the new package

dpkg-buildpackage -rfakeroot -uc -b

#install the package

cd ..
sudo dpkg -i package.deb
opencv-corner-detection-using-cvgoodfeaturestotrack

Here’s an example opencv application which uses cvGoodFeaturesToTrack to detect corners in a webcam video feed.

download good_features.cpp source

//
// This code displays corners found by the opencv function
// GoodFeaturesToTrack (cvGoodFeaturesToTrack)
//
// Sample webcam code taken from
//   http://www.cs.iit.edu/~agam/cs512/lect-notes/
//   opencv-intro/opencv-intro.html#SECTION00070000000000000000
//
// compile with:
// gcc `pkg-config --cflags opencv` `pkg-config --libs opencv`
// -o good_features good_features.cpp
//
// Kristi Tsukida  <kristi.tsukida@gmail.com> Aug 20, 2008
//
// Note: I commented out the corner detection using the Harris
// algorithm because my computer isn't fast enough to process
// both the Harris and the eigenvalue corners in real time.
// You can uncomment it and test for yourself.
//
 
#include <cv.h>
#include <highgui.h>
 
#include <stdio.h>
#include <sys/time.h>
 
#define VIDEO_WINDOW   "Webcam"
#define CORNER_EIG     "Eigenvalue Corner Detection"
// Disable harris processing
//#define CORNER_HARRIS  "Corner Detection (Harris)"
 
#define USEC_PER_SEC 1000000L
 
CvScalar target_color[4] = { // in BGR order
		{{   0,   0, 255,   0 }},  // red
		{{   0, 255,   0,   0 }},  // green
		{{ 255,   0,   0,   0 }},  // blue
		{{   0, 255, 255,   0 }}   // yellow
};
 
// returns the number of usecs of (t2 - t1)
long time_elapsed (struct timeval &t1, struct timeval &t2) {
 
	long sec, usec;
 
	sec = t2.tv_sec - t1.tv_sec;
	usec = t2.tv_usec - t1.tv_usec;
	if (usec < 0) {
		--sec;
		usec = usec + USEC_PER_SEC;
	}
	return sec*USEC_PER_SEC + usec;
}
 
struct timeval start_time;
struct timeval end_time;
void start_timer() {
	struct timezone tz;
	gettimeofday (&start_time, &tz);
}
long end_timer() {
	struct timezone tz;
	gettimeofday (&end_time, &tz);
	return time_elapsed(start_time, end_time);
}
 
// A Simple Camera Capture Framework
int main(int argc, char *argv[]) {
	long harris_time;
	long eig_time;
 
	CvCapture* capture = 0;
	IplImage* curr_frame = 0; // current video frame
	IplImage* gray_frame = 0; // grayscale version of current frame
	int w, h; // video frame size
	IplImage* eig_image = 0;
	IplImage* temp_image = 0;
	// Disable harris processing
	//IplImage* harris_eig_image = 0;
	//IplImage* harris_temp_image = 0;
 
	// Pick one of these capture methods:
	// You must have compiled opencv with ffmpeg enabled
	// to use a web stream!
	//capture = cvCaptureFromFile(
	//		"http://user:pw@192.168.1.101:81/img/video.mjpeg");
	//capture = cvCaptureFromAVI(
	//		"http://user:pw@192.168.1.101:81/img/video.mjpeg");
 
	// Capture from a webcam
	capture = cvCaptureFromCAM(CV_CAP_ANY);
	//capture = cvCaptureFromCAM(0); // capture from video device #0
	if ( !capture) {
		fprintf(stderr, "ERROR: capture is NULL... Exiting\n");
		//getchar();
		return -1;
	}
 
	// Create a window in which the captured images will be presented
	cvNamedWindow(VIDEO_WINDOW, 0); // allow the window to be resized
 
	cvNamedWindow(CORNER_EIG, 0); // allow the window to be resized
	cvMoveWindow(CORNER_EIG, 330, 0);
 
	// Disable harris processing
	//cvNamedWindow(CORNER_HARRIS, 0); // allow the window to be resized
	//cvMoveWindow(CORNER_HARRIS, 660, 0);
 
	// Show the image captured from the camera in the window and repeat
	while (true) {
 
		// Get one frame
		curr_frame = cvQueryFrame(capture);
		if ( !curr_frame) {
			fprintf(stderr, "ERROR: frame is null... Exiting\n");
			//getchar();
			break;
		}
		// Do not release the frame!
 
		// Get frame size
		w = curr_frame->width;
		h = curr_frame->height;
 
		// Convert the frame image to grayscale
		if( ! gray_frame ) {
			//fprintf(stderr, "Allocate gray_frame\n");
			int channels = 1;
			gray_frame = cvCreateImage(
					cvGetSize(curr_frame),
					IPL_DEPTH_8U, channels);
		}
		cvCvtColor(curr_frame, gray_frame, CV_BGR2GRAY);
 
		// ==== Allocate memory for corner arrays ====
		if ( !eig_image) {
			//fprintf(stderr, "Allocate eig_image\n");
			eig_image = cvCreateImage(cvSize(w, h),
					IPL_DEPTH_32F, 1);
		}
		if ( !temp_image) {
			//fprintf(stderr, "Allocate temp_image\n");
			temp_image = cvCreateImage(cvSize(w, h),
					IPL_DEPTH_32F, 1);
		}
// Disable harris processing
//		if ( !harris_eig_image) {
//			//fprintf(stderr, "Allocate harris_eig_image\n");
//			harris_eig_image = cvCreateImage(cvSize(w, h),
//					IPL_DEPTH_32F, 1);
//		}
//		if ( !harris_temp_image) {
//			//fprintf(stderr, "Allocate harris_temp_image\n");
//			harris_temp_image = cvCreateImage(cvSize(w, h),
//					IPL_DEPTH_32F, 1);
//		}
 
		// ==== Corner Detection: MinEigenVal method ====
		start_timer();
		const int MAX_CORNERS = 100;
		CvPoint2D32f corners[MAX_CORNERS] = {0};
		int corner_count = MAX_CORNERS;
		double quality_level = 0.1;
		double min_distance = 5;
		int eig_block_size = 3;
		int use_harris = false;
 
		cvGoodFeaturesToTrack(gray_frame,
				eig_image,                    // output
				temp_image,
				corners,
				&corner_count,
				quality_level,
				min_distance,
				NULL,
				eig_block_size,
				use_harris);
		cvScale(eig_image, eig_image, 100, 0.00);
		eig_time = end_timer();
		cvShowImage(CORNER_EIG, eig_image);
 
// Disable harris processing
//		// ==== Corner Detection: Harris method ====
//		start_timer();
////		const int MAX_CORNERS = 100;
//		CvPoint2D32f harris_corners[MAX_CORNERS] = {0};
//		int harris_corner_count = MAX_CORNERS;
//		double harris_quality_level = 0.1;
//		double harris_min_distance = 1;
//		int harris_eig_block_size = 3;
//		int harris_use_harris = true;
//
//		cvGoodFeaturesToTrack(gray_frame,
//				harris_eig_image,                    // output
//				harris_temp_image,
//				harris_corners,
//				&harris_corner_count,
//				harris_quality_level,
//				harris_min_distance,
//				NULL,
//				harris_eig_block_size,
//				harris_use_harris);
//		cvScale(harris_eig_image, harris_eig_image, 200, 0.50);
//		harris_time = end_timer();
//		cvShowImage(CORNER_HARRIS, harris_eig_image);
//
//		fprintf(stderr, "harris time: %i  eig time: %i\n", harris_time, eig_time);
 
		// ==== Draw circles around detected corners in original image
		//fprintf(stderr, "corner[0] = (%f, %f)\n", corners[0].x, corners[0].y);
		for( int i = 0; i < corner_count; i++) {
			int radius = h/25;
			cvCircle(curr_frame,
					cvPoint((int)(corners[i].x + 0.5f),(int)(corners[i].y + 0.5f)),
					radius,
					target_color[0]);
		}
		cvShowImage(VIDEO_WINDOW, curr_frame);
 
		// If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
		// remove higher bits using AND operator
		if ( (cvWaitKey(10) & 255) == 27)
			break;
	}
 
	// Release the capture device housekeeping
	cvReleaseCapture( &capture);
	cvDestroyWindow(VIDEO_WINDOW);
	cvDestroyWindow(CORNER_EIG);
// Disable harris processing
//	cvDestroyWindow(CORNER_HARRIS);
	return 0;
}
vim-case-insensitive-searches

Use “\c” anywhere in a search to ignore case (overriding your ignorecase or smartcase settings).
e.g. “/\cfoo” or “/foo\c” will match foo, Foo, fOO, FOO, etc.

Use “\C” anywhere in a search to force case matching.
e.g. “/\Cfoo” or “/foo\C” will only match foo.

You can set vim to ignore case on all your searches by running “:set ignorecase“.
If “ignorecase” is on, you can vim to ignore case on searches of only lowercase letters by running “:set smartcase“. (Searches with any capitalization or with “\C” will run a case-sensitive search.)

from Vim’s :help ignorecase and :help smartcase

[cc lang="cpp"]
// this is a syntax highlighting test
#include
#define BLAH “blah”
const float pi = 3.14; /* yum */
typedef struct Foo {
char * bar;
} Foo;
void nothing() {
int useless; // test
}
/* this is a comment
* yay */
int main() {
char * message = “hello world\n”;
printf(message);
nothing();
for( int i = 0; i < 5; i++) {
fprintf(stderr, “%i\n”, i);
break;
}
return null;
}
[/cc]