Jul 06 2009

Serial Mouse with Scroll on Ubuntu 9.04

Hello,

Just changed my mouse to a Serial one, and the Scroll don’t work. So what to do?

Edit /etc/X11/xorg.conf and add this lines:

Section “InputDevice”
Identifier “Configured Mouse”
Driver “Mouse”
Option “CorePointer”
Option “Device” “/dev/ttyS0″
Option “Protocol” “IntelliMouse”
Option “ZAxisMapping” “4 5″
EndSection

Remember that your Protocol can be other, so verify it typing:

$ inputttach –help

Best Regards,
Matheus

Jul 05 2009

Quick Flickr Widget 1.2.10.2, WordPress

Hello,

The author of Quick-Flickr-Widget the Konstantin Kovshenin just launched a new version. So I decided to re-update his plugin with my modifications to get a better random system.

Quick-Flickr-Widget 1.2.10.2 – With random on tags

Quick-Flickr-Widget first modification in version 1.2.7.2 (Explain better what is the updates that I did)

Best Regards,
Matheus

Jul 04 2009

Chart to your URL Shortener with Statistics.

Hello

I decided to implement a Chart vision of the access to a address of the last 30 days. THe system that I choosed is Open Flash Chart.

The new methods:
getAccess($id) – Return an Associative Array with the access by date and the total
formatData($data) – Receive the access of getAccess and transform it in a Numeric Array.
criarLabels() – Create the labels to the bottom part of the chart.

If you want to access it, you have to manually get the ID and use http://www.example.com/diretorio/chart.php?id=ID where ID is UID from the MySQL table.

Example:

URL Shortener with Statistics and Chart.

Creating your own Url shortener
Statistics on your URL Shortener

Best Regards,
Matheus

PS: Don’t forget the Rewrite Rules.

Jul 04 2009

Install Apache2, PHP5, PHPmyAdmin, MySQL

Hello,

I will just show how to quickly install Apache 2, PHP5, MYSQL and PHPmyAdmin in Ubuntu.

Install apache2 with:

$ sudo apt-get install apache2

Install PHP5:

$ sudo apt-get install php5 php5-common php5-cli

Install MYSQL:

$ sudo apt-get install mysql-client mysql-server

(During the installation it will ask you password for root user of MySQL)

Install PHPMyAdmin:

$ sudo apt-get install phpmyadmin

(It will ask the MySQL password and of the PHPMyAdmin user)

Best Regards,
Matheus

Jul 02 2009

Statistics on your URL Shortener.

Hello

A few weeks ago I showed you how to create your own URL-Shortener. I decide to improve it, creating a simple system to control the number of access

First of all you need to add some tables to your data base:

CREATE TABLE access (
  aid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  urls_uid INTEGER UNSIGNED NOT NULL,
  information_iid INTEGER UNSIGNED NOT NULL,
  date DATE NULL,
  PRIMARY KEY(aid),
  INDEX access_FKIndex1(information_iid),
  INDEX access_FKIndex2(urls_uid)
);

CREATE TABLE information (
  iid INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  ip VARCHAR(255) NULL,
  PRIMARY KEY(iid)
);

After this you should do a modification in your function-little-url.php in the function take_url($url):

function take_lurl($lurl) {
        global $link;
        $q = "SELECT * FROM `urls` WHERE `unique_chars` = ‘".$lurl."’";
        $r = mysql_query($q, $link); // Realiza consulta.
        if(mysql_num_rows($r)>0) {
                 $info = mysql_fetch_array($r);
                 $url = $info["url"]; // Pega endereço real
                 $uid = $info["uid"]; // Pega ID do endereço
                 $ip = $_SERVER[‘REMOTE_ADDR’]; // Pega IP do usuário
                 $qr = "select iid from `information` where ip = ‘".$ip."’" ;
                 $rr = mysql_query($qr, $link);  // Procura se este IP já está no banco de dados
                 if(mysql_num_rows($rr)>0) { // Caso esteja insere somente um acesso novo proveniente deste IP
                        $iid = mysql_result($rr,0,"iid");
                        mysql_query("INSERT INTO `access` (urls_uid,information_iid,date) values (".$uid.", ".$iid.", now())", $link);
                 } else { // Caso não esteja, cria um registro com este IP e após cria um acesso.
                        $qr = mysql_query("INSERT INTO `information` (ip) values (‘".$ip."’)", $link);
                        $iid = mysql_insert_id($qr);
                        mysql_query("INSERT INTO `access` (urls_uid,information_iid,date) values (".$uid.", ".$iid.", now())", $link);
                 }
        } else {
                echo "Sorry, link not found!";
        }
        return $url;
}

In this System there is a table with IPs that already accessed some URL, when a URL is accessed it verify the IP, if it is on the table just create an access to this IP in the new address. Otherwise, add the IP and create the access to the address.

How to create a URL-Shortener with Statistics

Matheus

Jul 01 2009

B Tree, Data Structure

Hello

This is a implementation of B-Tree. This program read a list of ZipCodes and insert then in a Tree, and it should calculate the time of add each one. But i think it is something wrong.

B-Tree

Best Regards,
Matheus