Thursday 29 November 2012

Pattern recognition algorithms

Boost based Computer Vision and Pattern Recognition Library implements many useful algorithms such as Principal Component Analysis, Eigen solver, etc.

http://boostcvpr.sourceforge.net/

Saturday 17 November 2012

windows/fedora dual boot - update grub2

After kernel updates the grub boot menu will include both the new kernel version and the previous kernel version.

Remove old kernels (keeping 2)


$ yum install yum-utils
$ package-cleanup --oldkernels --count=2



Update grub's boot menu


It's probably a good idea to make a backup of the old grub.cfg file

$ grub2-mkconfig -o /boot/grub2/grub.cfg

This will update the grub config used to load the boot menu.

You can customize the menu order by renaming the 10_* entries in /etc/grub.d/

Customize the boot order:

Find the menu entries:

$ grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2

Set the default menu entry:

$ grub2-set-default 'one-of-the-above-menu-entries'

Check to see if it worked:

$ grub2-editenv list

Sunday 4 November 2012

gtest - google unit testing framework

Primer

http://code.google.com/p/googletest/wiki/Primer

Simple test case

#include <gtest/gtest.h>

TEST(TestSuite, TestCase1)
{
    ASSERT_TRUE(expr);
}

TEST(TestSuite, TestCase2)
{
    ASSERT_TRUE(expr);
}

Get the main function for free

Link gtest_main.cc and you get RUN_ALL_TESTS free

What to do if a test fails

Abort the test on expression failure:

    ASSERT_TRUE(expr);

Continue the test on expression failure:

    EXPECT_TRUE(expr);

Floating point comparison:

    ASSERT_FLOAT_EQ(val1, val2);
    ASSERT_DOUBLE_EQ(val1, val2);
    ASSERT_NEAR(val1, val2, epsilon);

    EXPECT_FLOAT_EQ(val1, val2);
    EXPECT_DOUBLE_EQ(val1, val2);
    EXPECT_NEAR(val1, val2, epsilon);

Command line options

Repeat tests (useful for finding subtle race conditions)

    --gtest_repeat=1000 

Enter the debugger upon test failure

    --gtest_break_on_failure

Generate an xml report "foobar.xml"

    --gtest_output="xml:foobar"

Only run some tests

    --gtest_filter=TestSuite* // runs all suites matching TestSuite*
    --gtest_filter=TestSuite*-*.*2 // runs all suites matching TestSuite* except cases ending in '2'
    --gtest_filter=Foo*:Bar* // separate different reg-ex's with ':'



mysql, python, peewee

I want to use python to work with my mysql database

install the python bindings

$ sudo yum install MySQL-python

download and install peewee - an object-relational mapping utility to python

$ wget https://github.com/coleifer/peewee/archive/master.tar.gz
$ gunzip peewee-master.tar.gz
$ tar -xvf peewee-master.tar
$ cd peewee-master/
$ sudo python setup.py install
$ sudo python setup.py test


Saturday 3 November 2012

mysql


Install the the client and server software

$ sudo yum install mysql
$ sudo yum install mysql-server

start mysql server

$ sudo service mysqld start

automatically start mysql daemon on startup

$ sudo chkconfig --level 2345 mysqld on

set root password

$ mysqladmin -u root password foobar

login to localhost server

$ mysql -u root -p
mysql>

create a new user

mysql> create user 'username'@'localhost' identified by 'password';
mysql> grant all privileges on *.* to 'username'@'localhost' with grant option;

mysql-workbench: admin GUI

$ sudo yum install mysql-workbench

Tutorial on creating a database using mysql-workbench here

Mount NTFS partition in linux

Display available hard disks:
$ sudo fdisk -l

Device Boot  Start    End       Blocks    Id  System
/dev/sda2    206848   307202047 153497600 7   HPFS/NTFS/exFAT

Manually mount:
$ sudo mount -t ntfs-3g -o defaults,user,rw /dev/sda2 /mnt/windows/

Set up auto mounting in /etc/fstab:
add the following line to your /etc/fstab:
/dev/sda2 /mnt/windows/ ntfs-3g defaults,user,rw 0 0






Thursday 1 November 2012

gnu screen rc and commands

I am not 100% happy with my screen.rc; it kind of works at the moment but I will edit this post as I find improvements.

.screenrc

# skip the startup message
startup_message off

# go to home dir
chdir

# Automatically detach on hangup.
autodetach on

# Change default scrollback value for new windows
defscrollback 1000

# start with visual bell as default
vbell on
vbell_msg "bell on %t (%n)"

# look and feel

term screen-256color

hardstatus alwayslastline "%{=r}%{G} %{c}%w"

shelltitle "shell"

# highlighting for text marking and printing messages
# '=': replace current settings
# 's': standout
# 'dd': default fore / default back
sorendition =s dd

Commands

Move the current window to a new position (window number):
^a:number [new window number]

eg: ^a:number 5 will move the current window to position number 5

Rename a window
^a<shift>a [new window name]