Managing Source and Class Files

Many implementations of the Java platform rely on hierarchical file systems to manage source and class files, although The Java Language Specification does not require this. The strategy is as follows.

Put the source code for a class, interface, enumeration, or annotation type in a text file whose name is the simple name of the type and whose extension is .java.
For example:

//in the Rectangle.java file 
package graphics;
public class Rectangle {
   ... 
}

Then, put the source file in a directory whose name reflects the name of the package to which the type belongs:

.....\graphics\Rectangle.java

The qualified name of the package member and the path name to the file are parallel, assuming the Microsoft Windows file name separator backslash (for UNIX, use the forward slash).

  • class namegraphics.Rectangle
  • pathname to filegraphics\Rectangle.java

As you should recall, by convention a company uses its reversed Internet domain name for its package names. The Example company, whose Internet domain name is example.com, would precede all its package names with com.example. Each component of the package name corresponds to a subdirectory. So, if the Example company had a com.example.graphics package that contained a Rectangle.java source file, it would be contained in a series of subdirectories like this:

....\com\example\graphics\Rectangle.java

When you compile a source file, the compiler creates a different output file for each type defined in it. The base name of the output file is the name of the type, and its extension is .class. For example, if the source file is like this

//in the Rectangle.java file
package com.example.graphics;
public class Rectangle {
      . . . 
}

class Helper{
      . . . 
}

then the compiled files will be located at:

<path to the parent directory of the output files>\com\example\graphics\Rectangle.class
<path to the parent directory of the output files>\com\example\graphics\Helper.class

Like the .java source files, the compiled .class files should be in a series of directories that reflect the package name. However, the path to the .class files does not have to be the same as the path to the .java source files. You can arrange your source and class directories separately, as:

<path_one>\sources\com\example\graphics\Rectangle.java

<path_two>\classes\com\example\graphics\Rectangle.class

By doing this, you can give the classes directory to other programmers without revealing your sources. You also need to manage source and class files in this manner so that the compiler and the Java Virtual Machine (JVM) can find all the types your program uses.

The full path to the classes directory, <path_two>\classes, is called the class path, and is set with the CLASSPATH system variable. Both the compiler and the JVM construct the path to your .class files by adding the package name to the class path. For example, if

<path_two>\classes

is your class path, and the package name is

com.example.graphics,

then the compiler and JVM look for .class files in

<path_two>\classes\com\example\graphics.

A class path may include several paths, separated by a semicolon (Windows) or colon (UNIX). By default, the compiler and the JVM search the current directory and the JAR file containing the Java platform classes so that these directories are automatically in your class path.

Setting the CLASSPATH System Variable

To display the current CLASSPATH variable, use these commands in Windows and UNIX (Bourne shell):

In Windows:   C:\> set CLASSPATH
In UNIX:      % echo $CLASSPATH

To delete the current contents of the CLASSPATH variable, use these commands:

In Windows:   C:\> set CLASSPATH=
In UNIX:      % unset CLASSPATH; export CLASSPATH

To set the CLASSPATH variable, use these commands (for example):

In Windows:   C:\> set CLASSPATH=C:\users\george\java\classes
In UNIX:      % CLASSPATH=/home/george/java/classes; export CLASSPATH

CSS Frameworks

Below is an extensive list of CSS Frameworks that can be used to develop webpages. Although Twitter Bootstrap is one of the most recognized frameworks today, the list includes some very nice projects which are all worth keeping an eye on.

Twitter Bootstrap

Sleek, intuitive, and powerful front-end framework for faster and easier web development.

Responsive: Yes

Website: http://twitter.github.com/bootstrap/

Foundation

The most advanced responsive front-end framework in the world.

Foundation 3 is built with Sass, a powerful CSS preprocessor, which allows us to much more quickly develop Foundation itself and gives you new tools to quickly customize and build on top of Foundation.

Responsive: Yes

Website: http://foundation.zurb.com/

960 Grid System

Simple grid system

The 960 Grid System is an effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.

Responsive: Yes

Website: http://960.gs/

Skeleton

A Beautiful Boilerplate for Responsive, Mobile-Friendly Development.

Skeleton is a small collection of CSS files that can help you rapidly develop sites that look beautiful at any size, be it a 17″ laptop screen or an iPhone.

Responsive: Yes

Website: http://www.getskeleton.com/

99lime HTML KickStart

Ultra–Lean HTML Building Blocks for Rapid Website Production.

HTML KickStart is an ultra–lean set of HTML5, CSS, and jQuery (javascript) files, layouts, and elements designed to give you a headstart and save you 10’s of hours on your next web project.

Responsive: No

Website: http://www.99lime.com/

Kube

CSS-framework for professional developers.

Minimal and enough. Adaptive and responsive. Revolution grid and beautiful typography. No imposed styles and freedom.

Responsive: Yes

Website: http://imperavi.com/kube/

Less Framework

An adaptive CSS grid system.

Less Framework is a CSS grid system for designing adaptive web­sites. It contains 4 layouts and 3 sets of typography presets, all based on a single grid.

Responsive: Yes

Website: http://lessframework.com/

Flaminwork

The tiny front-end framework for lazy developers.

Responsive: No

Website: http://flaminwork.com/

G5 Framework

(X)HTML5, CSS3, PHP & jQuery Front End Framework.

G5 Framework started as a personal project. In an attempt to speed up workflow, reuse the best coding practices & similar coding techniques, the framework serves as a starter file for new websites.

Responsive: No

Website: http://framework.gregbabula.info/

Easy Framework

Your new starting point for every front-end projects!

Easy is a CSS/HTML/JavaScript framework started as a personal project and then grew into something more. The idea behind it is to reduce the amount of time spent on setting up the basic master HTML template by reusing the same coding techniques.

Responsive: No

Website: http://easyframework.com/

Blueprint

Blueprint is a CSS framework, which aims to cut down on your development time. It gives you a solid foundation to build your project on top of, with an easy-to-use grid, sensible typography, useful plugins, and even a stylesheet for printing.

Responsive: No

Website: http://www.blueprintcss.org/

YAML

“Yet Another Multicolumn Layout” (YAML)

YAML is an (X)HTML/CSS framework for creating modern and flexible floated layouts. The structure is extremely versatile in its programming and absolutely accessible for end users.

Responsive: Yes

Website: http://www.yaml.de/

BlueTrip

A full featured and beautiful CSS framework which originally combined the best of Blueprint, Tripoli (hence the name), Hartija, 960.gs, and Elements, but has now found a life of its own.

Responsive: No

Website: http://bluetrip.org/

YUI 2: Grids CSS

The foundational YUI Grids CSS offers four preset page widths, six preset templates, and the ability to stack and nest subdivided regions of two, three, or four columns. The 4kb file provides over 1000 page layout combinations.

Responsive: No

Website: https://developer.yahoo.com/yui/grids/

Elements

Elements is a down to earth CSS framework.

It was built to help designers write CSS faster and more efficient. Elements goes beyond being just a framework, it’s its own project workflow.It has everything you need to complete your project, which makes you and your clients happy.

Responsive: No

Website: http://elements.projectdesigns.org/

52framework

With HTML5 support coming so fast, with the tiniest of hacks we are able to use it today in virtually al browsers. Using HTML5 makes for much cleaner mark up. This framework fully uses all the great advantages of HTML5.

Responsive: No

Website: http://52framework.com/

elastiCSS

A simple css framework to layout web-based interfaces, based on the printed layout techniques of 4 columns but with capabilities to unlimited column combinations. and capacity to make elastic, fixed and liquid layout easily

Responsive: No

Website: http://elasticss.com/

Boilerplate

noun standardized pieces of text for use as clauses in contracts or as part of a computer program.

As one of the original authors of Blueprint CSS I’ve decided to re-factor my ideas into a stripped down framework which provides the bare essentials to begin any project. This framework will be lite and strive not to suggest un-semantic naming conventions. You’re the designer and your craft is important.

Responsive: No

Website: http://code.google.com/p/css-boilerplate/

Emastic

Emastic is a CSS Framework, it’s continuing mission: to explore a strange new world, to seek out new life and new web spaces, to boldly go where no CSS Framework has gone before.

Responsive: No

Website: http://code.google.com/p/emastic/

Malo

Malo is ultra small css library for building web sites.

Malo is ultra small css library for building web sites. It is meant to be structural base for small or medium web sites. Malo derives from it’s bigger brother Emastic CSS Framework.

Responsive: No

Website: http://code.google.com/p/malo/

The Golden Grid

The Golden Grid is a web grid system. It ‘s a product of the search for the perfect modern grid system. It ‘s meant to be a CSS tool for grid based web sites.

Responsive: No

Website: http://code.google.com/p/the-golden-grid/

1kb grid

Other CSS frameworks try to do everything—grid system, style reset, basic typography, form styles. But complex systems are, well, complex. Looking for a simple, lightweight approach that doesn’t require a PhD? Meet The 1KB CSS Grid.

Responsive: No

Website: http://www.1kbgrid.com/

Fluid 960 Grid System

The Fluid 960 Grid System templates have been built upon the work of Nathan Smith and his 960 Grid System using effects from the MooTools and jQuery JavaScript libraries.

Responsive: No

Website: http://www.designinfluences.com/fluid960gs/

Baseline

Baseline is a framework built around the idea of a “real” baseline grid.

Built with typographic standards in mind, Baseline makes it easy to develop a website with a pleasing grid and good typography. Baseline starts with several files to reset the browser’s default behavior, build a basic typographic layout — including style for HTML forms and new HTML 5 elements — and build a simple grid system.

Responsive: No

Website: http://www.baselinecss.com/

Lovely CSS Framework

The Lovely CSS Framework is a simple and straight forward way to easily deploy an XHTML/CSS site.

Based on a simple 960px wide grid system, featuring multiple column layouts, and various pluggable add-ons.

Responsive: No

Website: http://code.google.com/p/lovely-css/

xCSS

Object-Oriented CSS Framework

xCSS bases on CSS and empowers a straightforward and object-oriented workflow when developing complex style cascades. Using xCSS means a dramatic cut down to your development time by: having a intuitive overview of the overall CSS structure, using variables, re-using existing style cascades and many other handy features.

Responsive: No

Website: http://xcss.antpaw.org/

FEM CSS Framework

FEM CSS Framework is a 960px width + 12 column grid system + CSS common styles, to easy and fast develop web layouts. It is based in the 960 Grid System, but with a twist in the philosophy to make it more flexible and faster to play with boxes.

Responsive: No

Website: http://www.frontendmatters.com/projects/fem-css-framework/

Helium

Helium is a framework for rapid prototyping and production-ready development. In many ways it’s similar to both Twitter Bootstrap and ZURB Foundation – in fact, it uses bits of their code. Unlike either of these two frameworks, however, Helium is designed to be much more lightweight and easier to tinker with.

Responsive: Yes

Website: https://github.com/cbrauckmuller/helium

Sidereel Groundwork

A responsive HTML5, CSS and JavaScript framework built with SASS and Compass. There is heavy focus on responsiveness and making a single layout work on different devices.

Responsive: Yes

Website: http://groundwork.sidereel.com/

Gumby

Gumby is a responsive 960 grid CSS framework. The grid lets you lay out pages quickly and easily in a natural, logical way. The framework is packaged with tons of styles and common interface elements to help you quickly put together functional prototypes.

Responsive: Yes

Website: http://gumbyframework.com

 

Credit: https://github.com/usablica

ZF2 – Sharing and reusing DB connection for dummies

(Post has been updated after comment from Flamur on a unneccessary code in Module/Module.php)
While we were used to pass the DB-Connection to a Register or later this practice was improved by retrieving it from the Bootstrap in Zend Framework 1, the ZF2 has a new service layer which looks like a new commodity. I am referring to the ServiceManager, which also something like a registry for different object instances.

In ZF2, the DB credentials are usually stored in the ./config/autoload/ directory. Normally all files within this directory will be loaded by the ModuleManager (you don’t need to care much at this time). The file global.php (or db.php) should look like this:

return array(
    'service_manager' => array(
        'factories' => array(
            'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
        ),
        'aliases' => array(
            'db' => 'Zend\Db\Adapter\Adapter',
        ),
    ),
    'db' => array(
        'driver'    => 'pdo',
        'dsn'       => 'mysql:dbname=DBNAME;host=HOSTNAME',
        'username'  => 'USERNAME',
        'password'  => 'USERPASS',
    	'driver_options' => array(
                        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES 'UTF8''
         ),
    ),
);

The following can then be retrieved at any place in Controller through:

 $this->db = $this->getServiceLocator()->get('db');

And if you are using 3rd party modules from different vendors, who require access to your DB-adapter, you can just add the following to their config/autoload/ directory:

<?php
return array(
    'service_manager' => array(
        'aliases' => array(
            'vendor_or_any_any_name_for_zend_db_adapter' => 'db', //Same as the alias in our main global.conf
        ),
    ),
);

SQL vs noSQL

There is an interesting discussion around on wether we should stick by the old Relational Databases or go with the new hype of noSQL. noSQL looks very interesting in the fact that it does not use as much resources as RDBMS, but on the other side it lacks many functionalities.
I found the video above somewhere and it is a fun and informative video about this topic.

Information Management and Information Retrieval Modules

Praxis der INformationsverabereitung und Kommunikation I was given a chance to co-author (with Prof. Dr. D. Doherr) an article for the scientific journal “Praxis der Informationsverarbeitung und Kommunikation”. The article describes some innovations in the Humbold Digital Library Project in the field of Information Retrieval and Information Representation.

The article describes some methods that were used in Humboldt Digital Library to improve the findability of the information within the works of Alexander von Humboldt.

(part of the article: Section 3.1)

Internet today with the rise of new search engines like Wolfram Alpha and similar are proving that the users are no longer satisfied with Boolean search. Although algorithms like the Page Rank, HITS and similar provide great value in the results, the information that they return is purely term related. The search in those engines is handled by comparing terms for identical or similar word results (with little or no Natural Language Processing at all). This type of search can be considered a horizontal search as it is basically searching in the surface of the information without digging deeper. There exists another not yet fully revealed concept of search, referred as vertical search. The vertical search is an old concept of mining for knowledge, but is little put in practice in the public systems. The choices and the combination of the factors that influence the vertical search is very high (it can considered infinite, because knowledge includes also a random chance of discovery), therefore no system yet has fully delivered a state of art solution for this search. The sense behind the vertical search is that visitors search for topics and not for terms. By following this logic we have enhanced our digital library with a rich Information retrieval (IR) module.

The IR is the nucleus of our digital services. Usually, the visitors of a digital library are either rewarded by the riches of the options in the IR, or in an opposite scenario they are limited to what these IR module confines them to do.

Fig 1. General description of the modules of HDL
Fig 1. General description of the modules of HDL

As shown in the figure 1 the information in the Humboldt’s digital library and network is transformed in four layers.
The top layer handles the communication between the visitors and the system. Beside the Web-CMS Contrexx  which provides just a general informative module about the project (with no interest for the knowledge mining in the DL), the rest of the modules in this layer, handle continuous fetch and push operations. These operations provide the exchange of information between the system and the visitors.
It is a fact that systems serve better when they know their inhabitants. This is valid for the computer domain as well. If the system knows the background and interests of the users, then it can filter and provide them with some specific information. Based on the interests of the user, our system creates a set of statistical information about the paragraphs that may be of interest to the user, by analyzing on the experience of other users with a similar profile. By means of Personal Profiling, Personal Notes and Favorite Bookmarks, the system retrieves information about the interests of each user. In the Personal Profile section, the users may add information such as disciplines of interests, general interests and regional interests. A composition of these interests provides a cosmos for each user.

While users interact with the system through the content browsing, IR search tools or by writing personal notes related to any paragraph, they provide important feedback to the system. The system is basically learning what paragraphs are of interest to users of similar profile. The visitors of a Digital Library jump around the space of the digital library in search for the correct information. While they jump through links and documents, they leave behind disconnected traces of what they want and how they interact with the system. When these traces are connected to user profiles and user interests, they provide useful mining data that can be applied to other users who share the same preferences. The interactions of the user with the system are handled (stored and analyzed) by a Logger. The Logger retrieves the interactions of the user with the system. Based on these interactions, an algorithm provides for each user-profile, suggestions on the information that may better serve the users need. The Logger together with an algorithm for suggestions provides the Case-Based Reasoning (CBR) Engine. The CBR Engine takes in consideration: Click (Visits), User Personal Note, Editor Public Notes, Bookmarking of Paragraph Etc.
The CBR Engine stores an authority weight in the database. This authority weight is the influence weight, composed from the union of specific weights from the above options*. The Authority of Weight expresses a value of Interest for each Paragraph in the Humboldt Digital Library. Once a certain Value of Authority Weight (AW) for a specific Interest (ex: 5000) has been reached, the CBR system create notifications that the following paragraph should be suggested to the users of this specific Interest. This notification is visualized as the user navigates to the specific paragraph.

hdl2The level of relevance for each paragraph to the profile of the visitor is presented by a Heat Map. The heat map provides three levels of relevance. The levels are marked in different colors and they are an expression of relevance based on the AW/Interest value. The Heat Map represents only three top range values.
By using the colors of the Heat Map, and wrapping the Paragraphs in those colors, the system is informing the visitors that the paragraphs might be interesting to their profile.
As it can be seen from the Figure 1, the CBR stands as a bridge between the User Interface, the Services and the Storage System. The CBR together with the Natural Language Processing (NLP) serve as transforming engine in the second layer. The task of these two modules is to transform the search terms or search implications in one or multiple topics of search.
The term “Natural Language Processing” is normally used to describe the function of software or hardware components in a computer system which analyze or synthesize spoken or written language. A real translation from the human language to machine codes is handled by “Natural Language Understanding” (NLU). Implementing a full NLU System is a very challenging task which involves the work of many specialists from different science fields. The intent of this project was not the research on computational linguistics methods, but to facilitate the search of the information in the DL. By introducing the Thematic Variables like the Location, Time, Persons etc, our system can provides a simple NLP which can translate some phrases to correct queries. The set of the thematic
variables is referred as multi-variables and multi-variables search path. This is just another approach to retrieve information related to each paragraph in the Humboldt Digital library. The multivariable search path relies in additional thematic variables which are related to each paragraph. Every document or paragraph can be additionally described by a:

  • Theme
  • Time
  • Area / Location

Although Time and Location are pretty self-explanatory, the theme is a wide subject. In our normal spoken or narrative written language, we hide a lot of information. We may write a description about a country and not mention its name right away, we may speak of a person referring to him only once in the beginning of our speech, etc. The Boolean search will not provide any information in these cases, as the theme is hidden.
This is the case where the thematic variables come handy. The thematic variables provide additional information related to each paragraph in the HDL, describing what the paragraph covers in the space of individuals, scientific observations, ategory and an infinite set of options. Basically this means that for each paragraph, we have a commentary for the location where it was written and what it mentions, the date or period it describes, the people that the paragraph mentions and so on. To provide such information, for each paragraph in the HDL a separate thematic structure has been created and filled in with information from our Content Provider2 partners. More than 20 000 records of data were gathered only for the first document of Humboldt, ‘the Personal Narrative of Travels to the Equinoctial Regions of the New Continent during the Years 1799-1804’.
The category theme is also important. It may contain a set of keywords which if are hit from the search engine will suggest additional paragraphs. The other aspect of the theme category is related to personal interests of the visitor of the website.

This is part of the article: “Information Management beyond Digital Libraries: Alexander von Humboldt in the Web” DOI Reference: 10.1515/piko.2009.0030. For the full article, you may follow the link http://www.reference-global.com/doi/abs/10.1515/piko.2009.0030 .

MySQL Database Replication

Replication
Replication

Kur nje projekt arrin nje fare volumi informacioni, vihet re qe nuk eshte me e lehte te administrohet databaza e tij. Ne rastin tone, Projekti i Infoarkives, (http://lajme.shqiperia.com), kaloi mbi 2.1 Giga informacion. Per kete projekt ne kishim vendosur nje server te dedikuar ne dispozicion. Megjithe sistemin e cache per te rritur performancen apo procesorin e mire, duke qene se disa here brenda dites serveri terhiqte lajme dhe i shkruante ne DB, sherbimi web u be teper i ngadalte dhe po krijonte problem.

Nga natyra, tabelat myisam jane teper te shpejta ne lexim dhe nxjerrje te informacionit, por problemi kryesor shkrimi ne databaze. Rrobotet e kerkimit terhiqnin informacion i cili shkruhet ne disa tabela dhe nje prej tyre me madhesi prej afro 2Giga. Procesi i shkrimit ne nje tabele te madhe MySQL rrezultoi teper i shtrenjte. Ne nje situate kur shkrimi zgjat disa seconda dhe vendos nje “kycje” per leximin apo indeksimin e leximeve ne DB, nga mysql krijohej nje bottleneck dhe webserveri nuk pergjigjej me shpejtesine e duhur.

Per te zgjidhur probleme te tilla ka disa skenare.

  • Shtimi i RAM ne server per te lejuar cache me te mire per mysql
  • Ndarja e tabelave te informacionit ne tabela me te vogla. Per kete do duhej kalimi ne InnoDB ku perseri kerkesat per RAM do ishin me te larta
  • Kalimi ne nje strukture no-sql, pra ruajtje statike e informacionit
  • Ndarja e sherbimit te mysql ne nje server te ndryshem nga webserveri

Megjithese kishim bere disa optimizime ne MySQL dhe ne Apache per te lehtesuar proceset e secilit, ekzekutimi i te dy ketyre sherbimeve krijonte probleme. Ne nje situate te tille, shtimi i RAM ne server (qe eshte i kushtueshem) nuk ishte nje zgjidhje afatgjate.

Fatmiresisht, MySQL lejon Replikimin e databazes. Praktikisht nje server i cilesuar si kryesori (MASTER) mund te replikohet (kopjohet) nga motorri i MySQl ne disa servera te tjere qe quhen Skllever (Slaves). Ne nje situate te tille, eshte e mundur qe serveri kryesor (master) te perdoret per shkrimin e te dhenave nga rrobotet, dhe serveri skllav mund te perdoret per leximin e te dhenave nga webserveri. Ishte kjo zgjidhja qe zgjodhem per rastin e Infoarkives, praktikisht hapat e implementimit jane me poshte.

Krijimi i Log File te MySQL

Replikimi ne MySQL funksionon mbi loget e serverit.  Ketu nuk flitet per loget normal qe tregojne logimin e userave, por logu binar i MySQL.

Logu Binar permban te gjithe komandat qe ndryshojne te dhenat ose qe mund te ndryshojne te dhenat (psh INSERT). Keto komanda (statements) ruhen ne menyre kronologjike qe pershkruajne modifikimet. Nje nga qellimet e ketij logu binar eshte pikerisht replikimi.
Per replikimet, logu binar perdoret tek serveri kryesor (master) si nje rekord i komandave qe duhet ti dergohen sklleverve. Servero kryesor i dergon ngjarjet qe ndodhen ne logun binar tek serveri skllav i cili i ekzekuton ato ne menyren kronologjike (Shih me shume: Manualin e References se MySQL).

Per te krijuar logun binar, modifikohet skedari: my.cnf (zakonisht gjendet nen /etc/my.cnf) qe te permbaje komandat me poshte:


log-bin = /var/lib/mysqllog/mysql-bin.log
binlog-do-db=db_arkivaime
server-id=1

Rrjeshti i pare komandon mySQL qe te shkruaje nje Log dhe ta shkruaje ate pikerisht ne direktorine mesiper. (Kjo direktori duhet te jete me te drejta shkrimi nga perdoruesi mysql).  Rrjeshti i dyte eshte nje reference per databazen qe do te replikohet (kujdes, replikohet nje DB dhe jo te gjitha DBte e serverit.) Ne rastin me siper po replikoj db_arkivaime. Ndersa rrjeshti i trete percakton nga nje Identifikim (unik sigurisht) te ketij serveri.  Nje identifikim unik do percaktohet pak me pas dhe tek serveri skllav.

Ne menyre qe databaza qe do replikohet te lexohet nga serveri skllav, duhet qe ne mysql te krijohet nje user i cili ka te drejta replikimi.

Ne phpmyadmin apo ne mysql console (mysql -u root -p) duhet te krijohet nje perdoures me sintaksen si me poshte:


GRANT REPLICATION SLAVE ON *.* TO 'perdoruesiSkllav'@'IPjaeserveritSkllav' IDENTIFIED BY 'fjalekalimi';
FLUSH PRIVILEGES;

Me tej, ne serverin skllav duhet te modifikohet my.cnf duke shtuar informacionin si me poshte:


server-id=2
master-host=IPeMasterServer
master-connect-retry=60
master-user=perdoruesiSkllav
master-password=fjalekalimi
replicate-do-db=db_arkivaime

relay-log = /var/lib/mysql/skllav-relay.log
relay-log-index = /var/lib/mysql/skllav-relay-log.index

Sintaksa pak a shume eshte e qarte, rrjeshti i pare percakton nje identifikim per kete server dhe i percakton atij nr 2 si emertim. Rrjeshtat me poshte tregojne perdoruesin me te cilin mund te lidhet serveri skllav me serverin kryesor dhe ne fund ka disa loge qe i duhen motorrit te MySQL per te mbajtur shenim positionin ne te cilin serveri kryesor eshte tek logs.

Ne kete cast eshte e nevojshme te ndalohet serveri kryesor dhe te kopjohet databaza aktuale ne serverin skllav (ne kete menyre te dy serverat do te nisin replikimin duke pasur te njejtin informacion). Metoda ime e preferuar eshte me rsync dhe pasi te jete krijuar dhe databaza “db_arkivaime” dhe tek serveri skllav, mund te kopjohen te gjitha te dhenat nga serveri kryesor tek serveri skllav me sintaksen me poshte:

rsync -avz -e ssh [email protected]:/var/lib/mysql/db_arkivaime/ /var/lib/mysql/db_arkivaime/

Sintaksa me siper, ekzekutohet ne serverin skllav dhe kopjon ne menyre binare gjithcka qe ndodhet nen /var/lib/mysql/db_arkivaime/ tek e njejta direktori ne serverin tjeter. Normalisht ky eshte path-i ku ruhen te dhenat e DBve (nje bashkesi skedaresh, .MYI, frm, MYD).

Pervec rsync (per databaza te medha), mysqldump (apo phpmyadmin dump) mund te perdoren per te kopjuar databazen nga masteri tek serveri.

Per te gjetur pozicionin e serverit kryesor ne Logs duhet te ekzekutohet (serveri duhet startuar me pare):

SHOW MASTER STATUS;

ne mysql console apo phpmyadmin te serverit Master. Pergjigja do jete dicka e tipit:

+------------------+----------+----------------+------------------+
| File             | Position | Binlog_Do_DB   | Binlog_Ignore_DB |
+------------------+----------+----------------+------------------+
| mysql-bin.000003 |   199749 | db_arkivaime |                  |
+------------------+----------+----------------+------------------+
1 row in set (0.00 sec)

Ne kete cast tek Serveri Skllav duhet te ekzekutohet:

slave stop;
CHANGE MASTER TO MASTER_HOST='IPKryesor', MASTER_USER='perdoruesiSkllav', MASTER_PASSWORD='fjalekalimi', MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=199749;
slave start;

Pas nje restarti te serveri te slave mund te shikohet qe cdo veprim Update, Insert apo Delete ne serverin master reflektohet real time tek serveri skllav.

Implementing a Canonical URL with Zend Framework

Motivation

Unique - Courtesy Irina Souiki
Unique - Courtesy Irina Souiki

Google and the other search engines are trying to convince the webmasters to use the “what so called” Canonical URLs. The Canonical URLs will help the search engines distinguish the dublicated content which comes from different calls on the same domain. For example :

lead all to the same information, the entry point to this portal. Although a person does not care what he typed as long as he gets the information he expects, a search engine will get some(!?) confusion. The Search engine will get the same identic result, from the same domain, in 3 different URLs. Which one should the search index?!

Canonical URL Explained
Canonical URL Explained

The Canonical URL is just a simple “link tag” added to the header of your page. This link gives the owner of the page the power to tell Search Engines which one is his favourite URL for his page.

<link rel=”canonical” href=”http://www.avhumboldt.net/index.php” />

The above example is borrowed from Official Google WebMaster Central Blog and some more information on the canonical Url can be found on the article: Specify your canonical. Although the Blog of Google which is advertising this article does not include a “canonical link” (funny huh), it is a nice practice to have this feature on your website.

Implementation

If your project runs on Zend Framework, it is very easy to create canonical link by retrieving the controllers/actions and Parameters that you are using in the current URL. (And if you don’t have experience with ZF, the rest of the post will look chinese to you) If we have a closer look to the Canonical URLs, we will realize that we have to decide which domain should we use for the content to be shown. The rest of the parameters (the second part of the URLs) is the same as what it is shown on the page, in some cases we will just need to remove some arguments (like color/red/). In other words, if my URL is

http://www.avhumboldt.net/humboldt/publications/books/did/25/title/Aspects-of-Nature

or

http://avhumboldt.net/humboldt/publications/books/did/25/title/Aspects-of-Nature

I have to decide via Canonicals which one is my domain of choice and tell the Search Engines to use that one (The rest is handled by the search engine, we don’t care anymore). So all we need to do, is insert a

<link rel=”canonical” href=”http://www.avhumboldt.net/humboldt/publications/books/did/25/title/Aspects-of-Nature” />

in the header of the page. If we see the href in the canonical above, it can be divided in 2 parts, the domain name, (together with the subdirectory where I have placed my project) and the parameters which decide the content.

  1. Domain Name (+ subdirectory): www.avhumboldt.net/humboldt
  2. Parameters: /publications/books/did/25/title/Aspects-of-Nature

Since my parameters are always the same, in canonical URLs we should determine only the domain name we prefer and place the parameters afterwards. For those that are familiar with the Zend Framework MVC, the parameters of the URL are composed of /controller/action/parameters+. More information can be found in the Zend Framework Documentation. A quick solution should be by using:

“http://www.avhumboldt.net/”.$_SERVER[“REQUEST_URI”];

as the Canonical Link. The $_SERVER[“REQUEST_URI”] will return the URI which was given in order to access a page. Although this looks easy it is not recommend to anyone for use “as it is”. It will lead to some security issues with your website. (There are a lot of posts and resources out there about parameter security). A better approach to have the canonical URL is to recreate the full parameters used in the URL. This can be easily done by using Zend Frameworks Request Object. Within a Controller in Zend you can call:

$this->getRequest()->getControllerName() – to return the Controller name $this->getRequest()->getActionName() – to return the action name

and

$this->getRequest()->getParams() – to return an array with the parameters used in the URL

So we can get the Controller/Action straight forward by calling the getControllerName() and getRequestName(). We will need a little function to retrieve and place in a string all the parameters/values which are stored in the getRequest()->getParams().

public function canonicalUrl()
{
$request = Zend_Controller_Front::getInstance()->getRequest();
$filter = new Zend_Filter_Alnum(true);
$params = array();
foreach($request->getParams() as $key => $value) {
if(in_array($key, array(‘controller’, ‘action’, ‘module’))) {
continue;
}
array_push($params, $key . ‘/’ . $filter->filter($value));
}
return implode(‘/’, $params);
}

Once we have all the parameteres ordered in a /varname/value/varnam2/value… fashion, all we need to do is mix them in a Canonical URL and the best way is to create a view variable in the predispatch method of my controller:

The view variable is created for all the actions of the controller and can be accessed by any View script (those .phtml files under the view/scripts/controllername folder) Inserting them in the page is as easy as calling:

$this->headLink ()->headLink(array(’rel’ => ‘canonical’, ‘href’ => $this->canonicUrl), ‘PREPEND’);

The code above is used in the View Scripts of Zend Framework and it will create a link tag which can called from the main layout. In the Main Layout (it should be main.phtml by default) just add:

echo “nr”.$this->headLink().”nr”;

some where in the <head> section. You should have some nice canonical URLs in every page generated by your controller. A better way should be to create a plugin to have the canonical Urls for every controller, but this is what I needed so far.

List of English Stop Words

Stop Words

Stop Words are words which do not contain important significance to be used in Search Queries. Usually these words are filtered out from search queries because they return vast amount of unnecessary information. A better definition is provided below:

“Words that do not appear in the index in a particular database because they are either insignificant (i.e., articles, prepositions) or so common that the results would be higher than the system can handle (as in the case of IUCAT where terms such as United States or Department are stop words in keyword searching.) Stop words vary from system to system. Also, some systems will merely ignore stop words where use of stop words in other systems will result in retrieving zero hits. ”

http://www.iusb.edu/~libg/instruction/helpguide/handouts/2005Boolean.shtml

Since I needed to use them in a project (Humboldt Diglital Library and Network), I am posting here a list of English stop words, and below a PHP array containing these words

Here is a list of english stop words:

a
about
above
across
after
afterwards
again
against
all
almost
alone
along
already
also
although
always
am
among
amongst
amoungst
amount
an
and
another
any
anyhow
anyone
anything
anyway
anywhere
are
around
as
at
back
be
became
because
become
becomes
becoming
been
before
beforehand
behind
being
below
beside
besides
between
beyond
bill
both
bottom
but
by
call
can
cannot
cant
co
computer
con
could
couldnt
cry
de
describe
detail
do
done
down
due
during
each
eg
eight
either
eleven
else
elsewhere
empty
enough
etc
even
ever
every
everyone
everything
everywhere
except
few
fifteen
fify
fill
find
fire
first
five
for
former
formerly
forty
found
four
from
front
full
further
get
give
go
had
has
hasnt
have
he
hence
her
here
hereafter
hereby
herein
hereupon
hers
herse"
him
himse"
his
how
however
hundred
i
ie
if
in
inc
indeed
interest
into
is
it
its
itse"
keep
last
latter
latterly
least
less
ltd
made
many
may
me
meanwhile
might
mill
mine
more
moreover
most
mostly
move
much
must
my
myse"
name
namely
neither
never
nevertheless
next
nine
no
nobody
none
noone
nor
not
nothing
now
nowhere
of
off
often
on
once
one
only
onto
or
other
others
otherwise
our
ours
ourselves
out
over
own
part
per
perhaps
please
put
rather
re
same
see
seem
seemed
seeming
seems
serious
several
she
should
show
side
since
sincere
six
sixty
so
some
somehow
someone
something
sometime
sometimes
somewhere
still
such
system
take
ten
than
that
the
their
them
themselves
then
thence
there
thereafter
thereby
therefore
therein
thereupon
these
they
thick
thin
third
this
those
though
three
through
throughout
thru
thus
to
together
too
top
toward
towards
twelve
twenty
two
un
under
until
up
upon
us
very
via
was
we
well
were
what
whatever
when
whence
whenever
where
whereafter
whereas
whereby
wherein
whereupon
wherever
whether
which
while
whither
who
whoever
whole
whom
whose
why
will
with
within
without
would
yet
you
your
yours
yourself
yourselves

And here is a php array with stop words:
$stopwords = array("a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also","although","always","am","among", "amongst", "amoungst", "amount",  "an", "and", "another", "any","anyhow","anyone","anything","anyway", "anywhere", "are", "around", "as",  "at", "back","be","became", "because","become","becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom","but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven","else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own","part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the");

Updated October 3d, 2009.

This is the stop words list used by MySQL FullText feature

a’s, able, about, above, according, accordingly, across, actually, after, afterwards, again, against, ain’t, all, allow, allows, almost, alone, along, already, also, although, always, am, among, amongst, an, and, another, any, anybody, anyhow, anyone, anything, anyway, anyways, anywhere, apart, appear, appreciate, appropriate, are, aren’t, around, as, aside, ask, asking, associated, at, available, away, awfully, be, became, because, become, becomes, becoming, been, before, beforehand, behind, being, believe, below, beside, besides, best, better, between, beyond, both, brief, but, by, c’mon, c’s, came, can, can’t, cannot, cant, cause, causes, certain, certainly, changes, clearly, co, com, come, comes, concerning, consequently, consider, considering, contain, containing, contains, corresponding, could, couldn’t, course, currently, definitely, described, despite, did, didn’t, different, do, does, doesn’t, doing, don’t, done, down, downwards, during, each, edu, eg, eight, either, else, elsewhere, enough, entirely, especially, et, etc, even, ever, every, everybody, everyone, everything, everywhere, ex, exactly, example, except, far, few, fifth, first, five, followed, following, follows, for, former, formerly, forth, four, from, further, furthermore, get, gets, getting, given, gives, go, goes, going, gone, got, gotten, greetings, had, hadn’t, happens, hardly, has, hasn’t, have, haven’t, having, he, he’s, hello, help, hence, her, here, here’s, hereafter, hereby, herein, hereupon, hers, herself, hi, him, himself, his, hither, hopefully, how, howbeit, however, i’d, i’ll, i’m, i’ve, ie, if, ignored, immediate, in, inasmuch, inc, indeed, indicate, indicated, indicates, inner, insofar, instead, into, inward, is, isn’t, it, it’d, it’ll, it’s, its, itself, just, keep, keeps, kept, know, knows, known, last, lately, later, latter, latterly, least, less, lest, let, let’s, like, liked, likely, little, look, looking, looks, ltd, mainly, many, may, maybe, me, mean, meanwhile, merely, might, more, moreover, most, mostly, much, must, my, myself, name, namely, nd, near, nearly, necessary, need, needs, neither, never, nevertheless, new, next, nine, no, nobody, non, none, noone, nor, normally, not, nothing, novel, now, nowhere, obviously, of, off, often, oh, ok, okay, old, on, once, one, ones, only, onto, or, other, others, otherwise, ought, our, ours, ourselves, out, outside, over, overall, own, particular, particularly, per, perhaps, placed, please, plus, possible, presumably, probably, provides, que, quite, qv, rather, rd, re, really, reasonably, regarding, regardless, regards, relatively, respectively, right, said, same, saw, say, saying, says, second, secondly, see, seeing, seem, seemed, seeming, seems, seen, self, selves, sensible, sent, serious, seriously, seven, several, shall, she, should, shouldn’t, since, six, so, some, somebody, somehow, someone, something, sometime, sometimes, somewhat, somewhere, soon, sorry, specified, specify, specifying, still, sub, such, sup, sure, t’s, take, taken, tell, tends, th, than, thank, thanks, thanx, that, that’s, thats, the, their, theirs, them, themselves, then, thence, there, there’s, thereafter, thereby, therefore, therein, theres, thereupon, these, they, they’d, they’ll, they’re, they’ve, think, third, this, thorough, thoroughly, those, though, three, through, throughout, thru, thus, to, together, too, took, toward, towards, tried, tries, truly, try, trying, twice, two, un, under, unfortunately, unless, unlikely, until, unto, up, upon, us, use, used, useful, uses, using, usually, value, various, very, via, viz, vs, want, wants, was, wasn’t, way, we, we’d, we’ll, we’re, we’ve, welcome, well, went, were, weren’t, what, what’s, whatever, when, whence, whenever, where, where’s, whereafter, whereas, whereby, wherein, whereupon, wherever, whether, which, while, whither, who, who’s, whoever, whole, whom, whose, why, will, willing, wish, with, within, without, won’t, wonder, would, would, wouldn’t, yes, yet, you, you’d, you’ll, you’re, you’ve, your, yours, yourself, yourselves, zero

CSV Format

a,able,about,across,after,all,almost,also,am,among,an,and,any,are,as,at,be,because,been,but,by,can,cannot,could,dear,did,do,does,either,else,ever,every,for,from,get,got,had,has,have,he,her,hers,him,his,how,however,i,if,in,into,is,it,its,just,least,let,like,likely,may,me,might,most,must,my,neither,no,nor,not,of,off,often,on,only,or,other,our,own,rather,said,say,says,she,should,since,so,some,than,that,the,their,them,then,there,these,they,this,tis,to,too,twas,us,wants,was,we,were,what,when,where,which,while,who,whom,why,will,with,would,yet,you,your

I have also created another article where you can download stop words in csv, txt or as a php file