Monday, December 03, 2007

How to create a DSL connection on ubuntu

If your router/modem is set in bridge mode and you need to dial to make a connection you must use pppoE (Point to Point Protocol Over Ethernet) it's similar to the usual modem dial-up connection, but the difference is that you use the network an not the land line to connect.

In ubuntu you can run a little script called:


# pppoeconf




Just accept the defaults an make sure you give the right username/password.

it will edit this file:


# cat /etc/ppp/peers/dsl-provider

# Minimalistic default options file for DSL/PPPoE connections

noipdefault
defaultroute
replacedefaultroute
hide-password
#lcp-echo-interval 30
#lcp-echo-failure 4
noauth
persist
#mtu 1492
usepeerdns
plugin rp-pppoe.so
nic-ath0
user "xxxxxxxxxxx"



Now to create a connection use:

# pon dsl-provider

Plugin rp-pppoe.so loaded.


"dsl-provider" is name I chose for the connection which is the default

And to stop a connection use:

# poff



To stop all processes:

# poff -a




You can check the log using this commmand:

# plog
pppd[3928] : pppd 2.4.4 started by root, uid 0

Wednesday, September 19, 2007

My Firefox Toolbars are blank !

For some unknown reason my web developer and delicious firefox toobars disappeared, I could see the space where they used to be but no icons or anything was there. I tried with the view toolbars menu , checking and unchecking to hide and show them, but that didn't work. Finally I found the solution, firefox have an option called firefox safemode http://kb.mozillazine.org/Safe_mode which allows us to troubleshoot some problems (like this one), all you have to do is:

1. Close any running intance of firefox.
2. Type this command :


firefox -safe-mode


For more info for different OSs check here
3. Then check the box for "Reset toolbars and controls"

4. Click on "Make changes and restart"


That's it... your toolbar icons should appear again.

Wednesday, September 05, 2007

Oditt.com: web 2.0 for podcast episodes

Oditt it's a community-based site focused on ranking podcast episodes. It's very useful if you want to find specific podcast episodes about very narrow subjects, you can use tags, categories, or just keywords. Also, you can find RSS feeds for tags, categories, popular and recent episodes.

Check some oracle episodes here: http://www.oditt.com/tag/oracle.

Friday, June 01, 2007

Beryl keyboard and mouse shortcuts

Here are some default beryl shortcuts:

Ctrl + Alt + Drag the mouse : rotate the cube to any direction in the space.

Ctrl + left/right arrow key : rotate the cube to the left or right direction

Windows key + Pause : shows the window thumbnails or also called window picker , you can also place the mouse in the top right corner for the same action.

Remember that any shortcut can be changed in the beryl manager.

Wednesday, May 30, 2007

Fatal error installing symfony using PEAR

A memory error occurred when I was trying to install symfony using the "pear install" command:

root@cam-desktop:/home/cam# pear install symfony/symfony-beta
downloading symfony-1.0.2.tgz ...
Starting to download symfony-1.0.2.tgz (1,903,264 bytes)
......................................................................................................................................................................................................................................................................................................................................................................................done: 1,903,264 bytes

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 8192 bytes) in /usr/share/php/PEAR/Installer.php on line 518


The solution was to increase the memory to allocate for php to 32Mb:


root@cam-desktop:/home/cam# PHP_PEAR_PHP_BIN='/usr/bin/php5 -d memory_limit=32M export PHP_PEAR_PHP_BIN

root@cam# export PHP_PEAR_PHP_BIN
root@cam# pear install symfony/symfony-betadownloading symfony-1.0.2.tgz ...
Starting to download symfony-1.0.2.tgz (1,903,264 bytes)
......................................................................................................................................................................................................................................................................................................................................................................................done: 1,903,264 bytes
install ok: channel://pear.symfony-project.com/symfony-1.0.2

Sunday, May 27, 2007

Enable vim syntax color highlightning in Ubuntu

Syntax color highlighting enables parts of text (tags, functions, etc) to be shown in a different color to ease the visualization of the text file, this is done based on the file extension (.php,.sql,.html,etc).

To enable this function in Ubuntu or other distros edit or create the file .vimrc which must be located in the user home directory:


vi /root/.vimrc


add this line:

:syntax enable


That's it.

Saturday, May 26, 2007

Ubuntu Feisty doesn't support php4 anymore

Ubuntu Feisty Fawn (7.04) release, doesn't include php4 in their repositories, php5 is the default version for php. If you want to use php4 applications you better install Ubuntu Dapper Drake (6.06).

Firefox keybord shortcuts for urls

Here are some useful firefox keyboard shorcuts for urls:


Ctrl + enter : to complete a .com url . You can type "google" in the url bar and then ctrl + enter to complete the "www.google.com".

Ctrl + shift + enter : to complete a .org url . You can type "mysql" in the url bar and then ctrl + shift + enter to complete the "www.mysql.org".

F6: to select or move the cursor to the address in the url bar.

Ctrl + k : to move the cursor to the search box.

Saturday, April 21, 2007

ll alias (ls -l) is not in ubuntu

If you come from a red-hat based distro and are using ubuntu for the first time (just like me) one thing you may have noticed is that ll alias is not set by default, to do that just edit your ~/.bashrc and uncomment or add the line "alias ll='ls -l'" now the next time you start a shell window that alias will be loaded.


# some more ls aliases
alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

Friday, April 20, 2007

Porting mysql group_concat to postgres

There's a very useful aggregate function in mysql that allows you to concatenate several row values into one single row value. Here is an example:



mysql> create table t1 (
-> t1_id numeric,
-> col2 varchar(50)
-> );
Query OK, 0 rows affected (0.18 sec)

mysql> create table t2 (
-> t2_id numeric,
-> t1_id numeric,
-> col2 varchar(50)
-> );
Query OK, 0 rows affected (0.17 sec)

mysql> insert into t1 values (1,'a'),(2,'b'),(3,'c');
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> insert into t2 values (1,1,'d'),(2,1,'f'),(3,2,'g'),(4,3,'f'),(5,3,'h'),(6,3,'i'),(7,3,'j');
Query OK, 7 rows affected (0.01 sec)
Records: 7 Duplicates: 0 Warnings: 0

mysql> select * from t1;
+-------+------+
| t1_id | col2 |
+-------+------+
| 1 | a |
| 2 | b |
| 3 | c |
+-------+------+
3 rows in set (0.01 sec)

mysql> select * from t2;
+-------+-------+------+
| t2_id | t1_id | col2 |
+-------+-------+------+
| 1 | 1 | d |
| 2 | 1 | f |
| 3 | 2 | g |
| 4 | 3 | f |
| 5 | 3 | h |
| 6 | 3 | i |
| 7 | 3 | j |
+-------+-------+------+
7 rows in set (0.00 sec)

mysql> select *,(select group_concat(col2) from t2 where t1_id = t.t1_id) from t1 as t;
+-------+------+-----------------------------------------------------------+
| t1_id | col2 | (select group_concat(col2) from t2 where t1_id = t.t1_id) |
+-------+------+-----------------------------------------------------------+
| 1 | a | d,f |
| 2 | b | g |
| 3 | c | f,h,i,j |
+-------+------+-----------------------------------------------------------+
3 rows in set (0.17 sec)


Postgres as you may have noticed doesn't have a function like this, so I created my own approach:

Remember that you should have enabled pspgsql for your database previously:

In the shell you must type :

createlang plpgsql -Upostgres -d template1



template1=# CREATE FUNCTION concat (text, text) RETURNS text AS '
template1'# DECLARE
template1'# result text;
template1'# BEGIN
template1'# IF $1 is not null THEN
template1'# result := $1 || $2;
template1'# END IF;
template1'#
template1'# RETURN result;
template1'# END;
template1'# ' LANGUAGE plpgsql;
CREATE FUNCTION

template1=# CREATE AGGREGATE row_concat(
template1(# sfunc = concat,
template1(# basetype = text,
template1(# stype = text,
template1(# initcond = ''
template1(# );
CREATE AGGREGATE


template1=# create table t1 (
template1(# t1_id numeric,
template1(# col2 varchar(50)
template1(# );
CREATE TABLE
template1=#
template1=# create table t2 (
template1(# t2_id numeric,
template1(# t1_id numeric,
template1(# col2 varchar(50)
template1(# );
CREATE TABLE

template1=# insert into t1 values (1,'a');
INSERT 0 1
template1=# insert into t1 values (2,'b');
INSERT 0 1
template1=# insert into t1 values (3,'c');
INSERT 0 1

INSERT 0 1
template1=# insert into t2 values (1,1,'d');
INSERT 0 1
template1=# insert into t2 values (2,1,'f');
INSERT 0 1
template1=# insert into t2 values (3,2,'g');
INSERT 0 1
template1=# insert into t2 values (4,3,'f');
INSERT 0 1
template1=# insert into t2 values (5,3,'h');
INSERT 0 1
template1=# insert into t2 values (6,3,'i');
INSERT 0 1
template1=# insert into t2 values (7,3,'j');
INSERT 0 1

template1=# select *,(select row_concat(col2) from t2 where t1_id = t.t1_id) from t1 as t;
t1_id | col2 | ?column?
-------+------+----------
1 | a | df
2 | b | g
3 | c | fhij
(3 rows)




I didn't want to set a comma as the default separator so the user can customize easily the string. Another important thing is that if there is a null value in any row then the result will be null, like most of the aggregate functions.


template1=# select *,(select row_concat(coalesce(col2,'') || ' , ') from t2 where t1_id = t.t1_id) from t1 as t;
t1_id | col2 | ?column?
-------+------+------------------
1 | a | d , f ,
2 | b | g ,
3 | c | f , h , i , j ,
(3 rows)

Thursday, March 29, 2007

Beryl 0.2.0 + nvidia + Xinerama + Ubuntu (Edgy Eft)

I recently installed Ubuntu (Edgy Eft) on my home desktop. I wanted to try the Beryl window manager because of all the eye candy effects: 3d workspaces, window thumbnails, etc.

Beryl has a lot of plugins that you can play with, some of them are maybe very experimental but I think this project will be big in the future. I haven't seen much about Vista aero but I think, Beryl has to nothing to envy. Mac users would say "deja vu" but this is linux, free and open source and surely it will become something very interesting.

I must say that I thought the process of installing Beryl would be very frustrating (it's just 0.2.0 version), but it just run flawlessly at the first try (following this how-to wiki ). Now I use Beryl as the default window manager, it's running smoothly so far. I think it's all about the video card and the driver, I have an nvidia GeForce 6200 using this driver and also with it you can easily set the dual monitor configuration ( Xinerama ).



I tried to capture my two screens using Xvidcap but to get a decent frame rate all I could capture was a 40 x 40 pixels frame of the screen :(. Instead I used my camera pointing to one monitor and this is what I got:






Tuesday, February 13, 2007

Web 2.0 video

This is a really cool video about Web 2.0. It summarizes in about 4 minutes how the web has evolved and how it's helping us to be more connected, more citizens of the world and there are now less and less boundaries...

Wednesday, December 06, 2006

Firefox 2.0 cool tip for recovering closed tabs

Firefox 2.0 has a nice command to recover a closed tab. In case you have accidentally closed a tab , just press ctrl+ shift+ t , and it will get back the tab. Very useful for people that have a lot of open tabs at the time (just like me).

Postgres 8.2 has been released

Postgres 8.2 is now on the streets. New features have been added:

-- Higher performance (+20% on OLTP tests)
-- Improved Warm standby databases
-- Online index builds
-- SQL2003 aggregates
-- Improved TSearch2 with Generalized Inverted Indexes
-- Support for DTrace probes
-- Advisory Locks
-- New ISN/ISBN and pgCrypto modules
-- Selective pg_dump options

Check this link for more info: http://www.postgresql.org/about/press/presskit82.html.en

Monday, October 23, 2006

2 useful linux commands

I read or heard somewhere about this two linux commands: apropos and ctrl + r. And I found it very userful.
apropos : apropos searches for a keyword in some internal database(s) and displays a list of commands related to the searched keyword. This is helpful when you don't know the exact name of a command or have no clue of the command to perform certain task. You can also google for it, but you have this additional choice.

[root@devel2 ~]# apropos mail

aliases (5) - aliases file for sendmail
clamav-milter (8) - milter compatible mail scanner
fetchmail (1) - fetch mail from a POP, IMAP, ETRN, or ODMR-capable server
formail (1) - mail (re)formatter
hesiod_free_postoffice [hesiod_getmailhost] (3) - Hesiod functions for retrieving user to postoffice mappings
hesiod_getmailhost (3) - Hesiod functions for retrieving user to postoffice mappings
htnotify (1) - sends email notifications about out-dated web pages discovered by htmerge
logrotate (8) - rotates, compresses, and mails system logs
mail (1) - send and receive mail
mailaddr (7) - mail addressing description
mailcap (4) - metamail capabilities file
mailq (1) - print the mail queue
mailstats (8) - display mail statistics
makemap (8) - create database maps for sendmail
mutt (1) - The Mutt Mail User Agent
muttrc (5) - Configuration file for the Mutt Mail User Agent
newaliases (1) - rebuild the data base for the mail aliases


Ctrl +r : When pressing this in a shell you will filter you history of typed commands by the letters you type after pressing the keys.


(reverse-i-search)`apr': man apropos

I typed here "apr" after pressing ctrl+r and it gave me "man apropos".

If you type Ctrl+r again it will move to the next match for the typed letter(s).

Wednesday, August 23, 2006

Windows XP on CentOS with VMware

I installed Windows XP SP2 as a guest OS on a CentOS using VMware server the virtual machine software.


If you wonder why the windows have that OSX look , I'm using a gnome theme called "Glossy P".
The installation is pretty straightforward but it runs a little slow as expected, i was just trying to use the Net2phone dialer which runs only on windows (there are no plans to make a port for linux) and it worked fine, to get sound and microphone support with this software you need to add a sound adapter (the hardware must first work with CentOS) to the virtual machine in the settings at the VMware server console.

I used this How-to for ubuntu, most of the steps are the same .

Wednesday, July 26, 2006

Range partitioning in MySQL 5.1

There are 5 types of table partitions in mysql: range, list, hash, key and composite (or subpartitioning), i think the most commonly used type in the database world (at least in oracle) could be range partition, in this way a expression is evaluated and according to it different partitions are created with ranges of rows. The most common method to partition by range is using dates (by years,months,days) to group large amounts of rows from a table, mysql does not support partition by date type directly (oracle does), instead a function like year() or month() should be used to get an integer value.


Playing with this partition type, first i tried to create a table with a primary key on the id column and the partition column using insert_date, but MySQL generates an error if the column insert_date is not part of the primary key:


mysql> CREATE TABLE range_partition_tab (
-> id numeric primary key,
-> data varchar(20),
-> insert_date date
-> )
-> PARTITION BY RANGE ( year (insert_date) ) (
-> PARTITION p1 VALUES LESS THAN (2005),
-> PARTITION p2 VALUES LESS THAN (2006),
-> PARTITION P3 VALUES LESS THAN MAXVALUE
-> );
ERROR 1482 (HY000): A PRIMARY KEY need to include all fields in the partition function


But after i removed the primary key clause , it created the table.


mysql> CREATE TABLE range_partition_tab (
-> id numeric ,
-> data varchar(20),
-> insert_date date
-> )
-> PARTITION BY RANGE ( year (insert_date) ) (
-> PARTITION p1 VALUES LESS THAN (2005),
-> PARTITION p2 VALUES LESS THAN (2006),
-> PARTITION P3 VALUES LESS THAN MAXVALUE
-> );
Query OK, 0 rows affected (0.08 sec)



I tried to add a new partition:


mysql> alter table range_partition_tab add partition (partition p4 values less than (2007));
ERROR 1472 (HY000): VALUES LESS THAN value must be strictly increasing for each partition


But p3 holds all the rows that match range for p4, then since none value is greater than MAXVALUE a new partition can't be added over that value.

New partitions can be added for example by splitting the low end partition (p1) with the REORGANIZE PARTITION clause:


mysql> alter table range_partition_tab reorganize partition p1 into ( partition s0 values less than (2004), partition s1 values less than (2005) );
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0


The new partition must start from the value of p1 wich is 2005 to cover the same range, otherwise MySQL generates an error:



mysql> alter table range_partition_tab reorganize partition P3 into ( partition s0 values less than (2003), partition s1 values less than (2004) );
ERROR 1499 (HY000): Reorganize of range partitions cannot change total ranges except for last partition where it can extend the range



to drop a partition:


mysql> alter table range_partition_tab drop partition p3;
Query OK, 0 rows affected (0.15 sec)
Records: 0 Duplicates: 0 Warnings: 0

Tuesday, June 06, 2006

Table partitioning in MySQL 5.1

I'm very excited that MySQL implements this feature in version 5.1.x, all the new features are bridging the gap between open source and propietary RDMS like Oracle, this feature particularly makes MySQL suitable for Data warehouse systems, not just OLTP systems as it's well known.

There are a lot of benefits in the use of table partitioning like:

- Eases the administration of the tables
- Reduces time taken in large amount of DML
- Improves the response of some queries

Table partitioning allows the DBA to define how the table and the data cointained could be stored phisically, while remaining the logical structure the same. For example a table with data of 5 years (theorically a large table) could be splitted (depending on the needs) in 5 partitions, reducing the time taken by some queries that may fit into a particular year, easing the administration of the table when the data from a year needs to be dropped or moved, enhancing the response for bulk DMLs in different years, etc.

There are some features not available yet like partitioning by range on a date column (http://bugs.mysql.com/bug.php?id=17540) and one that i reported, i couldn't find how to get data from a specific partition rather than knowing wich partition a query accesses ( http://bugs.mysql.com/bug.php?id=20279), but i think is just a matter of time.

Sunday, June 04, 2006

Memory requirement installing oracle xe on centos

I was trying to install oracle xe on a centos 4.2 box ( 256 RIMM memory, pentium 4 1.70 GHz), but i got stucked with a memory requirement error :


[root@localhost ~]# rpm -Uvh /root/oracle-xe-10.2.0.1-0.1.i386.rpm
Preparing… ########################################### [100%]
Oracle Database 10g Express Edition requires a minimum of 256 MB of physical
memory (RAM). This system has 249 MB of RAM and does not meet minimum
requirements.
error: %pre(oracle-xe-10.2.0.1-0.1.i386) scriptlet failed, exit status 1
error: install: %pre scriptlet failed (2), skipping oracle-xe-10.2.0.1-0.1


I don't know why linux reports 249Mb and where are the other 7 Mb since there is a AGP video card of 64Mb and i didn't have that problem with the windows version, but after playing around with the rpm 'install-options' i found the ones that let me pass that requirement:


[root@localhost ~]# rpm -Uvh --force --nopre /root/oracle-xe-10.2.0.1-0.1.i386.rpm
Preparing... ########################################### [100%]
1:oracle-xe ########################################### [100%]
Executing Post-install steps..........
You must run '/etc/init.d/oracle-xe configure' as root user to
configure the database.

Saturday, May 13, 2006

Alternative to xmms for playing mp3 in linux

Xmms newer versions doesn't support mp3 files because of licensing issues, i read something about Zinf and give it a try, and it works great playing mp3, i'm using Centos 4 i just needed to install the libid3 package (id3lib-3.8.3-7.2.el4.rf.i386.rpm) and it was up and running:


[root@localhost ~]# rpm -Uvh zinf-2.2.5-1.i386.rpm
error: Failed dependencies:
libid3-3.8.so.3 is needed by zinf-2.2.5-1.i386

[root@localhost ~]# rpm -Uvh zinf-2.2.5-1.i386.rpm
Preparing... ########################################### [100%]
1:zinf ########################################### [100%]




You can get zinf from : http://www.zinf.org/download.php

Update:

After using zinf for a while a realized that it crash a lot, i'm back to xmms its a lot more stable, just downloading the xmms-mp3 package it can play mp3s.