Oct 19 2009

URL Shortener using Auto-Increment field.

Good Night,

This is a new version of URL-Shortener that don’t create random IDs to websites, it uses the auto-increment field and replace it to other base.

Read more »

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 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

May 09 2009

Creating your own Url shortener.

Good Night,

Here I will show you how to create your own url shortener.

First of all you need to create a table like this:

CREATE TABLE IF NOT EXISTS `urls` (
`uid` int(11) NOT NULL auto_increment,
`url` text default NULL,
`unique_chars` varchar(25) BINARY NOT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `unique_chars` (`unique_chars`)
);

This code was taken from Abhise in this post “Create your own tinyurl with php and mySQL” that was my bigest reference, from it I took some functions and update other ones to be more efficient. For an example I changed the field to BINARY so it be CASE SENSITIVE (aaaa different from AAAA)

The Abhise says to create many files, I particularly, created one file with all functions where I add all the functions and just called the functions in the files.

Read more »

May 06 2009

Quick Flickr Widget, WordPress.

Hello,

I found this interesting plugin for wordpress Quick-flickr-widget. A widget to show pics from Flickr in your blog. You can configure it in many ways, to get the last pic, to use tags, to get random pics. But this last one I didn`t like, this option use a feed with your last updates. So I have an idea to improve this, to get all tags, and select random tags and use this tags to select pics. It uses to random system, so it is better.

I implemented this in Quick Flickr Widget creating the interface and the new functions. I contacted the author of this plugin to see if he have interest to put this in his. If he don`t want to, you can take it from here. Quick flickr widget with random tags

See you,
Matheus

PS: I used the version as 1.2.7.2. I did this improvements in two steps that is way .2. The original version is 2.7.2 and .2 from this new implementation. Probably if the author use this it will be a different version.

May 06 2009

Linked List, Data Structure

Hello,

What is a Linked List? Linked-list is a list that each element has a pointer to the next one.

The professor once again send us an enunciation to solve and it is too big. And I will not translate it. Inside the problem it have a Linked list.

Problem using linked-list..

Regards,
Matheus

PS: You can see the enunciation in portuguese and then use google translate to translate it

Read more »

Apr 29 2009

List, with pointers, Data Structure

Hello,

Today I will introduce you to a list using pointers. This list doesn’t have limit of elements (if you have infinite memory). Again the enunciation is too big, so take the file, read it and learn.

Stack with pointers implementation

Regards,
Matheus

PS: You can see the enunciation in portuguese and then use google translate to translate it

Apr 27 2009

Netbeans 6.5.1, Line-spacing

Hello,

I was using NetBeans in Ubuntu 9.04 when i started a new project and I realized that the line-spacing is so fucking bigger. To fix this you have to do this:

Edit the file “org-netbeans-modules-editor-settings-CustomPreferences.xml”

$ pico org-netbeans-modules-editor-settings-CustomPreferences.xml

This file will be in:

/home/user/.netbeans/6.5/config/Editors/Preferences

If the file and the directory exists just add the following lines:

<entry javaType=”java.lang.Float” name=”line-height-correction”
xml:space=”preserve”>
<value><![CDATA[0.75]]></value>
</entry>

If don’t you have to create the directory “Preferences”:
$ mkdir Preferences
(In /home/user/.netbeans/6.5/config/Editors)

$ cd Preferences

And create the file:

$ pico org-netbeans-modules-editor-settings-CustomPreferences.xml

Add the following lines:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE editor-preferences PUBLIC “-//NetBeans//DTD Editor Preferences 1.0//EN” “http://www.netbeans.org/dtds/EditorPreferences-1_0.dtd”>
<editor-preferences>
<entry javaType=”java.lang.String” name=”code-template-expand-key” xml:space=”preserve”>
<value><![CDATA[TAB]]></value>
</entry>
<entry javaType=”java.lang.Float” name=”line-height-correction” xml:space=”preserve”>
<value><![CDATA[0.75]]></value>
</entry>
</editor-preferences>

Save, restart netbeans and enjoy it. ;)

Good Night,
Matheus

Portuguese Version

References:
http://my.opera.com/Nobita2708/blog/show.dml/2914020
http://www.linux4all.net/how_to_change_line_height_in_netbeans_editor
http://www.cs.wcupa.edu/rkline/netbeans-lin.html
http://www.google.com.br/search?hl=pt-BR&q=line+spacing+ubuntu+netbeans&btnG=Pesquisar&meta=

Apr 25 2009

List, Data Structure

Good afternoon,

Like I said before I’m having Data Structure class. And today I will introduce you the List concept. A linear data structure. There is similar data structures like linked list, double linked list. The stack and the queue are special implementations of lists. The list can receive elements in any position, remove elements from any position, remove a specified element, add in order and others.

The professor told us to solve this:

1. Create the data type tLista in a headerfile
2. This list must be a list of elements of tAgenda
3. The type tAgenda is a type that represents a name (30 chars) and a telephone number
4. Create a function maior(a,b) that compare the name of 2 entries
5. Implement all the functions
6. Create a program that have a menu to use all functions and the specified search must use the name.
7. The program should be able to show the list in alphabetic order

List implementation.

Regards,
Matheus