QoolArchives. An Archives WordPress plugin

We would like to inform you about the QoolArchives WordPress plugin!!
This plugin tries to solve a big WordPress problem that has to do with CPU load and speed.

The problem
When you have a wordpress site with 200-400 articles, WordPress is just fine but when it comes to a site that has more than 1500-2000 posts, then WordPress is a real CPU load monster! The problem is because WordPress asks the total number of posts from the database every time we make a request, making the DB to run a full scan of the post’s table. This can really kill your server!!!

The cause
Wordpress uses FOUND_ROWS. What this does is, that it asks the database for the total number of rows found on a query with no need for a second sql query to count the rows. As mentioned above, this is fine for a wordpress installation with 200-400 posts but it sucks when you have to do with thousands of posts.

The QoolArchives sollution
The plugin creates archived posts and moves the posts from the post’s table to another one. Thus making the post’s table smaller and easier for the FOUND_ROWS function to deal with.

Side effects
The plugin has some side-effects though.

Widgets problem
The calendar and the archives widgets will display records only for posts that have not been archived yet. So if the latest archive has been created at 28-03-2011 the calendar will display records only for days after 28-03-2011 . This is not such a big problem cause you can actually see the posts by going to a previous day :

www.example.com/2011/03/27

Download
You can download the plugin here: QoolArchives WP plugin

Any demos?
The QoolArchives plugin has been installed here: Writer.gr

Read More
Online casino technology

The Technology Behind Online Casino

For some years now, they have been sprouting out of the ground: online casinos. Countless providers enable gambling fans to indulge in their favourite leisure activities around the clock on the Internet. Those who used to like to go to the casino in the past can now save their time and simply switch on the computer. But how exactly does this principle actually work?

Because where in a real casino there is a dealer who distributes cards and chips, has an eye on everything and is responsible for ensuring that a game goes smoothly, an online casino needs an adequate replacement. How can you ensure that the games work as you are used to from real life?

For this purpose, very special types of software are used, which have experienced their own hype since the advent of online casinos and have virtually formed a new industry. There are now almost as many well-known software manufacturers for online casinos as there are providers on the net, although a few of them stand out clearly. Take MicroGaming, for example, which is regarded as a pioneer in software development. As early as the mid-1990s, the company began to deal with online gambling and was thus one of the first companies to pave the way on the market. Providers such as 32RedCasino Online Portugal or Online Casino Srbija are among the best and most reputable MicroGaming customers. Here, the company is responsible for trying your luck on digital gaming machines or roulette tables and perhaps winning big money at 32Red and Co.

But Microgaming is not the only giant on the market. Soon after the company began to be successful, other companies came up with the idea to deal with this topic as well, and Net Entertainment Casinos, Playtech and many others soon followed. No matter which online casino you play at, it’s probably one of the big names behind it. Most of the companies founded themselves in the course of the 1990s, experienced the boom around the Internet and everything related to it, that is to say, at first hand and are perfectly adjusted to what the customers and ultimately the users would like to have offered when they register in an online casino to try their luck.

But how exactly does it work with this casino software? After all, what you see on a slot machine in a slot game, for example, must have been generated somewhere. There are indeed certain generators for this purpose. They are called Random Number Generators, or RNG for short, and thus stand as a rough translation for nothing else than the term random number generator. It is their job to ensure that the numbers that appear on the digital machine actually appear there at random. Fortunately, the current state of the art makes this possible, but the way the RNGs work is generally still considered to be relatively complicated, so that one has to have a lot of mathematically on the box in order to be able to follow this system.

The most important thing in this area is of course fair play. Users would certainly not react enthusiastically if it were found out that online casinos use software that deliberately ensures that few profits are made. In this case, you should really stick to reputable suppliers, because you get the guarantee that everything goes right. Apart from that, the providers don’t really need to cheat their customers at all, because in fact the probability to hit the jackpot on a slot machine is so small that the online casino itself usually has a plus factor. Smaller winnings are always in, but that someone has a really big fish on the fishing rod, happens only rarely. If the technology, which is the software behind the gaming machines on the Internet, but functions fairly and does not favour or disadvantage anyone, then you don’t really have to worry about anything like that as a player.

Due to the fact that most slots machines are operated by a random generator, the player has to say goodbye to the idea of using a tactic in some way. If everything is to be right, then one simply has to live with the fact that it depends entirely on the happiness or bad luck of the individual, whether one goes home with a profit or a loss. The payout of the prize therefore actually depends on an invoice, not on the moment you press the stop button or on which spin was the previous one. The same applies to the software, which determines which cards can be used for which purpose.

Read More

Using APIs With PHP? Here Are Your Classes

Do you want to use an API but you are too lazy to write your own code to handle the requests? If you code in PHP as I do, then you will definitely need these classes. By using the classes listed here you will be able of using a great number of web services with an easy and documented way.

Pear

We couldn’t write a post about PHP classes without PEAR. PEAR  stands for “PHP Extension and Application Repository” and the Web Services category is the place to get ready made classes for:

  • Akismet
  • Amazon
  • Blogging
  • Compete
  • Delicious
  • Digg
  • eBay
  • Facebook
  • Google
  • Twitter
  • Yahoo
  • Youtube

and many more.

Even though PEAR is a great resource for web services related classes, sometimes you might want to use another class that doesn’t rely on PEAR to do the job or a more sophisticated one. The list that follows has PHP classes for different web services.

Read More

If Programming Languages Were Real Persons

What if programming languages were real persons like you and me? What if they were parts of families and had relations and affairs? Have you ever thought of going to a supermarket and Visual Basic was the young woman waiting in the line in front of you?

Well we did. We let our imagination free and we came up with pictures and facts :). We hope you enjoy this article since it only exist as a geeks humor. Names are fictional and images has been collected from Google’s search.

Charlie C

C is a 70 years old man that knows a lot. Perhaps too proud to reveal what he knows and sometimes too cryptic. He is a very strict person that follows his way of doing things and nothing seems possible to change his mind. In the past he was known as one of the strictest teachers in the Devel City university.

C can make you happy or disappoint you so much that, you want go for one of his sons or daughters. It depends on how much you try to learn his ways. The more you try the more he gives you.

C has been the main builder behind large projects like the Linuxious stadium and other large scaled buildings that we all use. He still works as a freelancer engineer and has involved in many other projects. Even at his age and with a lot of competition mainly from his son C++, C is still the choice of many companies to do things in Devel City.

C has 3 daughters :

  • Perl,
  • Java and
  • C#

and one son, C++.

Vin C++

C++ is 45 years old teacher at the Devel City university, following his father’s steps to become as respected as he is. He loves his father so much that tried to continue his work and knowledge. Being a younger man than C though, made him a much more friendly guy, in the means of approach, than his father. He works as a teacher in the Devel City university and his students have a love and hate affair with him.

C++ often lets his students choose their way in the learning process since he follows a different way of teaching approach than his father used to. His students love him because he lets them work in their own way but sometimes they fear his inheritance of C.

Most of his followers admire his wide range of knowledge that mixes C’s knowledge with knowledge gained through his life.

There are also a lot of people that criticise him of being so wide. Most of the time they talk about him as a direct descendant of C that has adopted all of his fathers disadvantages and added some more to it.

C++ has spent many years to get rid some of his fathers bad habits and never does things not needed. He prefers to put as much effort as needed to do the job right and never bloats things. This is why his projects are much more targeted than his fathers.

Montana Perl

Perl is a 37 years old young woman and works as a data analyst at the department of linguistics in Devel City. As a sexy young woman, her colleagues just love to work with her.

She is extremely clever, very strict when it comes to how people treat to her but has added great value to her carrier with her regular way of expressing things and her unique way of finding needles in haystacks. Many of her colleagues depend on Perl to fix things and they call her a “Swiss knife”.

Her father was a source of inspiration for Perl. Many of her father’s principles was inherited and many more added to her philosophy of how things should be done and why. She is a rather laconic character that speaks less but means a lot.

Perl finds it easy to work on different environments and performs well with a little help from her beloved husband Cygwin who always supports her ambitions.

Perl loves to travel. Each summer she goes around the world, most of the time she will be riding a camel in Africa and many times you might find her playing Golf in the State of the union stadium.

She also loves poetry and runs her own amusement company named Acme which aids in teaching young kids the way to do things the funny way.

Bianca Java

Java is a 35 years old sexy young woman and a mother also. Being so young and mature, Java is one of the most popular women in Devel City. She is very adoptable and can work everywhere. Her name comes as a feature in many projects and a lot of companies want their projects to carry her “Java powered” signature of quality.

Being C++’s sister, does not stop Java to be one of the biggest competitors of her brother. As a woman, Java is clean and manages to keep garbage out of her place, clean and clear. She works at JVM, a company specialized in ports creation.

Java loves sun. Each summer is Java’s favorite season and she loves playing with Duke in the beach.

Java has created her own legacy, just like her father did and has 2 daughters that promise to be as competitive as she is. Her daughters also work at JVM and stand out from the crowd of talented persons in Devel City. Their names are:

  • Groovy and
  • Scala

Jessica Groovy

Groovy is 21. Young but her impact in Devel City is bigger than just big. She was greatly inspired by her aunt Perl and her best friend Ruby.

Groovy is laconic and very expressive like her aunt, got any possible knowledge of her mother and added some cool ways to do her job in JVM. Most of the time she guides her colleagues in a rather strange way… by adding question marks (?) wherever she thinks something should be checked again.

Jane Scala

Scala is 22 years old.She is sweet and quite friendly but many of her friends in Devel City feel a little thread when it comes to job opportunities. The case of Twittorix, where the managers of the project asked Scala to do the job, made Ruby upset.

Scala like her little sister Groovy, got all of her mother’s knowledge and took it to a newer level. Not only Scala can work the same way as her mother does, she can also make new ways of working and doing things for a specific job which makes her a valuable part of JVM. Scala gets a lot of suggestions to work for NET (another ports creation company) but she is too busy with JVM at the moment that makes this a little hard to accomplish.

Pierson PHP

PHP is 29 years old and Java’s bitter friend. PHP runs her own company in Devel City called Zendix and has become one of the worlds well known ladies because of her easy way of doing things, her adoption of new technologies and a large fun club that make her desirable and efficient.

PHP was a student of C, Java’s father and used to work with Perl where she got her expressive character and power. Being a very beautiful woman, PHP has a lot of admirers that range from newcomers to Devel city, to old residents. She might seem easy but she needs a lot of attention to master her ways.

Sometimes her affairs are too strong and sometimes people seem to glance at Java and Ruby which makes her trying to add some of Java’s charm into her character. This, makes a lot of people say that PHP tries to become Java in some way.

Recently, PHP was voted as the 3rd most popular person in Devel’s city Object’s awards.

Mary JavaScript

JavaScript is often confused with Java in Devel City especially from newcomers… but you know what they say that: “where no smoke without fire”. Many rumors say that JavaScript is Java’s half sister but she denies it, so does Java.

JavaScript is 32 and her close friends call her “JS”. She is very strict but relaxed also. This, makes her a wonderful companion for most of Devel’s residents and she is very popular since a large part of the city has used her services at least once.

JS is one of the most successful women in Devel City. She runs a network of more than 20 companies some of which are unique.  jQuerysius, Mootool and Dojodic, to name a few are popping out each and every day.

She works silently and a lot of people think that she spents most of her time to make her job look glamourus. Most of her competitors say that she is good only for that but, to be honest, all of them know that there are some things that only she can accomplish.

She believes that to become successful, you have to keep your friends close and, your enemies closer. So, she tries to cooperate and coexist with all other businessman and businesswoman in Devel City. Everybody loves her even if she breaks things up sometimes.

Angelina Ruby

Ruby is a good friend of Groovy. She is 20 years old and she is one of the upcoming names in Devel City mainly because of her professional maturity and the way she manages to do a job cleanly and fast. Although Scala, Groovy’s sister, got a big job from Ruby’s hands (case of Twittorix), Ruby is still considered as one of the best professionals out there.

Ruby, became one of the most successful women in City of Devel, after the creation of her Rails company  and got a lot of fame. She also inspired many other famous women in Devel City to start their own Rails-like companies with PHP being one of them with Symfoniac LTD.

She is a very calm person and not fond of surprises. When she works, she wants to have everything there as helpful as it can be for her and her co-workers. Most of the time she applies the POLS principle to her job.

Some Devel City residents state that, if Perl goes away one day, Ruby will do the job as good as she does and with more freedom than with Perl.

Ruby believes in one principle: “Divide and Conquer”, this is why she has divided all of her company groups into Gems. Ruby just needs to use a gem to do a particular job.

Jack Python

One of the most known and respected persons in Devel City, is Python. A 54 years old construction builder. Some people believe that he can use the power of his brain to do magic. Python works in a rather modern way that his age implies and here is where he amazes Devel’s residents.

Python always finds new ways of doing things. If a tool is good to work with, Python will use it with no particular disadvantages. Python is one of the best man in Devel to work with since he allows anyone to work the way he thinks is better.

His favorite words are spam and eggs and his projects are named after his nickname. For example PyGameing station and PyS6000 which was a futuristic TV series.

Python as his name implies, is a snakes lover and has a lot of them as pets. His favorite pet is an Anaconda.

His work has been approved by some of the biggest companies in Devel City like 10^10, Yohaaa and DERN.

Read More

All The Developer’s Books You Ever Wanted

Here is a big list of downloadable, programming related, books in PDF format for your everyday reference and advice. We tried to cover as many as we could think of but some things might be missing. We hope this list to be a good reference for all of you who need a place to find and download books about a specific aspect of programming.

Actionscript 3.0

  • ActionScript 3.0
  • ActionScript 3.0 Cheat Sheet
  • ActionScript Primer

APIs

  • How to design a Good API and why it Matters
  • WolfRam Alpha API
  • The little manual of API design
  • Live Search API
  • JavaScript for Acrobat API
  • Google Maps API
  • Twitgoo Developer API
  • Newsgator REST API
  • The Linux Kernel API
  • JDBC 2.0 Standard Extension API
  • The Facebook Platform
  • BOSS API
  • YQL API

ASP/.NET

  • ASP security standards
  • Introducing ASP
  • ASP.NET page lifecycle
  • ASP Cheat Sheet
  • Authentication and Security Mechanisms in ASP.NET Web Applications
  • ASP.NET using VB.NET

C/C++

  • C++ Essentials
  • A Design Rationale for C++/CLI
  • More C++
  • Optimizing software in C++
  • Thinking in C++
  • Functional Programming in C++
  • Static Interfaces in C++
  • Memory model for multithreaded C++
  • C Only Books Not in PDF Format (Thanks to wgj)
    • The C Book
    • C Elements of Style (Available as PDF but separate chapters)
    • Numerical Recipes in C (Also separate chapters available in PDF)

CSS3

  • Introduction to CSS3
  • Fonts Spec Presentation
  • CSS3 display:magic;
  • CSS3 Cheatsheet

CMS/CMS’s API

  • Drupal 6 API
  • Joomla
  • WordPress Plugin API
  • WordPress Widgets

F#

  • F# Cheat Sheet
  • Language Overview
  • F# Warmup

Groovy

  • Programming with Groovy
  • Real Life Groovy
  • Agile Web Development with Groovy and Grails
  • Groovy Metaprogramming

Java

  • Java Generics
  • Java Quick Reference
  • Java Stack Inspection
  • Java Coding Style
  • Multithreaded Java
  • Bytecode verification
  • Java Primer

JavaScript

  • JavaScript Cheat Sheet
  • Reference Booklet
  • JavaScript as a real programming language
  • RDFa with JS
  • jQuery
    • jQuery 1.2 cheatsheet
    • jQuery Selectors
    • JavaScript & jQuery
  • mootools
    • Mootools basics
    • Mootools Essentials
  • PrototypeJS
    • Developer Notes for PrototypeJS
    • Prototype Cheat Sheet
    • JS and AJAX with Prototypejs

Lisp

  • Basic Lisp
  • Lisp 1.5 Manual
  • The Complete idiot’s guide to Lisp packages
  • Using Lisp as a markup language

MySQL

  • Cheat Sheet
  • MySQL on Windows
  • Hackproofing MySQL

Objective-C

  • Objective-C 2.0
  • From C++ to Objective-C
  • Obj-C internals
  • For Java Programmers

Objective-J

  • Objective-J book

Oracle SQL

  • Oracle SQL tutorial
  • Introduction to SQL injection attacks
  • Key Functions

PHP

  • The Manual
  • Secure File Uploading
  • PHP PCRE Cheat Sheet
  • Oracle & PHP
  • PHP & AJAX
  • Developer Best Practices with PHP
  • PHP Security Guide
  • PHP Extensions Writing
  • Frameworks
    • Symfony
    • CakePHP
    • CodeIgniter
    • Zend Framework
    • Prado

REST

  • RESTful Web Services
  • oAuth and REST
  • RESTful services with JavaFX
  • Using Amazon WS with REST
  • REST for Web Services
  • Describe RESTful Services with WSDL 2.0
  • How to define REST Web Services

Ruby

  • Ruby Language Expressions
  • Programming Ruby Secong Edition
  • Ruby Programming
  • Intro to Ruby on Rails
  • Ruby on Rails Cheat Sheet
  • Guide to Ruby (poignat)

Scala

  • Scala Tutorial
  • Scala Overview
  • Codemash

SQLite

  • Functions Aggregators and Collations
  • Setup on Windows
  • SQLite Information

Tcl/Tk

  • Manual
  • Scripting Graphical Commands

YAML

  • YAML Spec
  • Ruby and YAML

This post will be updated regularly with new books and sections.

Try to solve the new Formula Cube! It works exactly like a Rubik’s Cube but it is only $2, from China. Learn to solve it with the tutorial on rubiksplace.com or use the solver to calculate the solution in a few steps. (Please subscribe for a membership to stop adding promotional messages to the documents)

Read More

Google Maps From A to Z

During the last years, online maps have evolved so much that they hold valuable information and capabilities. The most well known maps are Google’s Maps. Google Maps are powered by a powerful engine and also have a large community offering support.

Google allows web masters to add and customize maps on their sites with the Google Maps API. To use the Google Maps API, you have to get an API key from Google. Each API key is valid for a certain domain but you get generate as many keys as you want.

Creating our first simple map

Implementing Google Maps in your site is plain easy. You just have to add:

  • A link to a JavaScript file provided by Google
  • Some lines of JavaScript with some parameters
  • A layer where our map will be displayed.

The link to the JavaScript file:

<script charset="UTF-8" src="https://maps.google.com/maps?file=api&amp;v=2&hl=en&oe=utf-8&key=API_KEY" type="text/javascript"></script>

Note: We can change the language used in our map implementation by changing the “hl=en” part and use our preferred language, for example “hl=el” for Greek language or “hl=fr” for French language. We also change the “API_KEY” part with the key we got from Google.

Caution: Google Maps work better when loaded in UTF-8 encoded pages.

JavaScript code with parameters:
This is where some magic can happen with Google Maps. We can add some parameters in the JavaScript and change the way our maps look, react to user feedback and more. For example we can set the map to load and display a particular coordinate in the center of our view. The code to center the map to a specific location is:

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.97918, 23.71665), 13);
map.setUIToDefault();
}
}

This part of the code is where we set the coordinates we want the map to focus:

map.setCenter(new GLatLng(37.97918, 23.71665), 13);

The option “13” is the zoom level of our map. We can set a number from 1 to 17.

To get the Latitude and Longitude of a specified location you can use this tool. It is very easy to use. You just move the map around and place the location of your interest in the center of the map.

Placing markers

You can mark a place of interest in the map by using markers. The code to place a marker on a spot is:

var point = new GLatLng(37.97110, 23.72601);
map.addOverlay(new GMarker(point));

So, our code after we place a marker, looks like this:

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.97918, 23.71665), 13);
var point = new GLatLng(37.97110, 23.72601);
map.addOverlay(new GMarker(point));
map.setUIToDefault();
}
}

The example above centers our map on Athens Greece, and adds a marker on Acropolis.

Balloons:
Balloons are a kind of tool-tips that you can use to provide additional info for the place marked. For example the code bellow will add a balloon on the Acropolis Hill and display some information:

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.97110, 23.72601), 13);
var html = "Parthenon, Address: Acropolis Hill";
map.openInfoWindow(map.getCenter(),
document.createTextNode(html));
map.setUIToDefault();
}
}

Active Markers

We can combine markers and balloons to create an active marker that will display the balloon only when a user clicks on the marker. The code to do this is:

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.97918, 23.71665), 13);
var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);

function createMarker(point, index) {
var redIcon = new GIcon(baseIcon);
redIcon.image = "http://www.google.com/mapfiles/marker.png";
markerOptions = { icon:redIcon };
var marker = new GMarker(point, markerOptions);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("Parthenon, Address: Acropolis Hill");
});
return marker;
}

var latlng = new GLatLng(37.97110, 23.72601);
map.addOverlay(createMarker(latlng));
}
}

Lets go over the code again. This part adds a shadow bellow our marker:

var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);

We set the action of the marker here:

function createMarker(point, index) {
var redIcon = new GIcon(baseIcon);
redIcon.image = "http://www.google.com/mapfiles/marker.png";
markerOptions = { icon:redIcon };
var marker = new GMarker(point, markerOptions);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("Parthenon, Address: Acropolis Hill");
});
return marker;
}

Here is where our marker will be:

var latlng = new GLatLng(37.97110, 23.72601);
map.addOverlay(createMarker(latlng));

Loading a map

We can load a map with 2 ways. We can set the map to load as soon as our page is loaded using the body onload event, or we can assign the loading process to another event. Either way, the functions we need are:

  • initialize() To load the map
  • GUnload() To unload the map and free some memory used by the map.

We also need to add a div layer (any block element will do the work) assigned the id used by the JavaScript code (In our example “map_canvas”). We can also apply CSS rules to the layer.

Customizing your Maps

You can use custom icons for markers and shadows. Two great tools for creating your own icons can be found here and here. You can also customize the appearance of balloons using HTML and CSS. You should properly escape quotes (“s and ’s) though.

Adding multiple markers and grouping them

We can mark multiple locations on our maps and group them according to our needs. So, we can set our map to display different marker icons for hotels based on their category, we can set an icon with a building to help our users identify buildings of interest or another icon for bridges. To do this, we have to use an XML file.A simple XML file looks like this:

<markers>
<marker name="Your Title here" label="This is the label of the marker" desc="Description of the balloon" lat="37.97167" lng="23.72581" type="Here we set the marker's type. For example Bridge" address="The address here" icona="We place an image path here"/>
</markers>

You can add as many markers as you want in the file. One thing you should be very aware of, is that you must escape special chars like quotes and double quotes, and “#@$<>” for your titles, and your links should be escaped too. The JavaScript needed is:

<script src="https://gmaps-utility-library.googlecode.com/svn/trunk/labeledmarker/release/src/labeledmarker.js" type="text/javascript"></script>

and we also set some parameters:

var iconRed = new GIcon();
iconRed.image = '../img/marker-red.png';
iconRed.shadow = '';
iconRed.iconSize = new GSize(32, 32);
iconRed.shadowSize = new GSize(22, 20);
iconRed.iconAnchor = new GPoint(16, 16);
iconRed.infoWindowAnchor = new GPoint(5, 1);
var customIcons = [];

customIcons["ancient"] = iconRed;
var markerGroups = { "ancient": []};

So we set the customIcons property for “ancient” to iconRed and we should also use this type (ancient) in our XML file. If we named our XML file as markers.xml, then we should use this code:

GDownloadUrl("markers.xml", function(data) { //We tell Google Maps to load our file
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker"); //and read markers
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name"); //From here down we assign variables.
var label = markers[i].getAttribute("label");
var desc = markers[i].getAttribute("desc");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var icona = markers[i].getAttribute("icona");
var point = new GlatLng(parseFloat(markers[i].getAttribute("lat")), //and we set the lat-long
parseFloat(markers[i].getAttribute("lng")));
var marker = createMarker(point, name, label, desc, address, type, icona);
map.addOverlay(marker);
}
});
}
}

function createMarker(point, name, label, desc, address, type, icona) {
var marker = new LabeledMarker(point, {icon: customIcons[type], labelText: label, labelOffset: new GSize(-6, -8)})};

You can play with the GSize() function’s parameters and set the label of each marker to be in the marker’s borders. To Group the markers we need to do this:

markerGroups[type].push(marker);
var html = "<img src=" + icona + " height=150 border=0 /><br><br><span><b>"+ name + "</b><br/>" +
desc + "<br/><b>Address:</b> " + address + "<br/><br/><span>";
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}

To set different icons based on interest you can do it using the same method described above with some variations. For each icon we use this code:

var iconRed = new GIcon();
iconRed.image = '../img/marker-red.png';
iconRed.shadow = '';
iconRed.iconSize = new GSize(32, 32);
iconRed.shadowSize = new GSize(22, 20);
iconRed.iconAnchor = new GPoint(16, 16);
iconRed.infoWindowAnchor = new GPoint(5, 1);

var iconGreen = new GIcon();
iconGreen.image = '../img/marker-green.png';
iconGreen.shadow = '';
iconGreen.iconSize = new GSize(32, 32);
iconGreen.shadowSize = new GSize(22, 20);
iconGreen.iconAnchor = new GPoint(16, 16);
iconGreen.infoWindowAnchor = new GPoint(5, 1);

var iconBrown = new GIcon();
iconBrown.image = '../img/marker-brown.png';
iconBrown.shadow = '';
iconBrown.iconSize = new GSize(32, 32);
iconBrown.shadowSize = new GSize(22, 20);
iconBrown.iconAnchor = new GPoint(16, 16);
iconBrown.infoWindowAnchor = new GPoint(5, 1);

var customIcons = [];

customIcons["hotel"] = iconRed;
customIcons["bridge"] = iconGreen;
customIcons["hill"] = iconBrown;
var markerGroups = { "hotel": [], "bridge": [], "hill": []};

So, if we set the type of each marker in our XML file as hotel,bridge and hill, we also set a different color for each icon.

Making our markers more dynamic

We can make our markers a little bit more user friendly. We can let the user decide which marker to show or hide using events from buttons, checkboxes or links.To do this you should add the following code right after the “map.addMapType(G_SATELLITE_3D_MAP); ” part:

document.getElementById("hotelCheckbox").checked = true;
document.getElementById("bridgeCheckbox").checked = true;
document.getElementById("hillCheckbox").checked = true;
document.getElementById("labelsCheckbox").checked = true;

and at the end of the JavaScript code you add this:

function toggleGroup(type) {
for (var i = 0; i < markerGroups[type].length; i++) {
var marker = markerGroups[type][i];
if (marker.isHidden()) {
marker.show();
} else {
marker.hide();
}
}
}

function toggleLabels() {
var showLabels = document.getElementById("labelsCheckbox").checked;
for (groupName in markerGroups) {
for (var i = 0; i < markerGroups[groupName].length; i++) {
var marker = markerGroups[groupName][i];
marker.setLabelVisibility(showLabels);
}
}
}

function hideAll() {
var boxes = document.getElementsByName("mark");
for(var i = 0; i < boxes.length; i++) {
if(boxes[i].checked) {
boxes[i].checked = false;
switchLayer(false, layers[i].obj);
chosen.push(i);
}
}
}

function checkChecked() {
var boxes = document.getElementsByName("mark");
for(var i = 0; i < boxes.length; i++) {
if(boxes[i].checked) return true;
}
return false;
}

The last thing to do is to add the checkbox elements on your page:

<input type="hidden" id="labelsCheckbox" onclick="toggleLabels()" checked=”checked” />
<label for=”hotelCheckbox”>Hotels</label><input type="checkbox" id="hotelCheckbox" onclick="toggleGroup('hotel')" checked=”checked” />
<label for=”bridgeCheckbox”>Bridges</label><input type="checkbox" id="bridgeCheckbox" onclick="toggleGroup('bridge')" checked=”checked” />

Our Google Maps are ready. I hope you to find this article helpful. We covered a big part of the Google Maps API and you should now be able to add Google Maps to your sites, place markers in groups and let the users choose which markers should be visible and which shouldn’t.

Read More

Technologies That Will Change The Web

Some years ago, the mp3 format was invented. It was a market killer invention since there was a whole bunch of new products and hardware that came out to support it. We saw mp3 players in our rooms, cars and phones. We also saw companies distributing paid music rise and each teen has it’s mp3 player along with his/her books. Each time a killer invention comes out, there is a whole bunch of other products in the market to support it.

The Web, was another killer invention. Some new technologies that recently came out promise to re-invent the web and we will make an effort to showcase them here. We will also try to imagine some supporting products that these technologies might produce.

Select * from internet with YQL

Technologies That Will Change The Web

One of the most promising technologies out there, is Yahoo’s YQL. Many people including me, believe that this platform is the next big thing. You can do thousand of diferrent things with YQL in so many diferrent areas that the moto is really “select * from internet”. The philosofy behind YQL is that anyone can make his data available for everyone in a specific way, so specific that someone who wants to access these data, should just use an SQL-syntax like language to get do it.

So YQL turns the web into a monsterous database waiting there for us to query it. How is this possible? Each web service should produce a datatable with a specific format, which then other people can use to extract, insert or update data. We see hundreds of community tables available in the YQL console.

In what way could YQL change the web? What if you used YQL to create a hotel booking site? Hotels could create datatables that would make hotels reservations, available rooms and pricing info available. Then we could do a YQL statement like this to get available rooms in San Fransisco:

SELECT * FROM hotels.rooms.sf WHERE room=open

The above example is fictional. YQL could be used in any way you would use a typical SQL database. Our article about how to use yql to manage your meme account will get you into it even faster.

Take the web back with Opera Unite

Take the web back with Opera Unite

Opera Unite is able to turn your browser (Opera) into a web server. This means you can share content directly with friends without having to upload anything to a Web site. Opera Unite is a Web server running inside the Opera Web browser, allowing the user to install applications and share these applications with their friends and colleagues (or everyone, if they wish). The Opera Unite server provides a proxy between the server and its clients (found at operaunite.com) to avoid the need for any special firewall configuration.

So in other words, you run your own hosting service. You can use standard techniques like JavaScript and HTML to create applications and then publish them for the world to see right from your own browser. There are already a some applications that utilize the Opera Unite API and my favorite one is Twicli.

Most of the Opera Unite use cases could be for social networking but it could be used as a collaboration tool too.

Collaborate with Google Wave

Collaborate with Google Wave

Google Wave is an online tool for real-time communication and collaboration. A wave can be both a conversation and a document where people can discuss and work together using richly formatted text, photos, videos, maps, and more. With Google wave the possibilities are endless since the wave API allows you to build anything you want.

Google Wave supports robots, gadgets,extensions and embedding that makes it so powerful for online collaboration that any other tool could be. We recently posted a tutorial on how to create a feed reader extension for Google Wave too.

Recently there was a post in the ReadWriteWeb blog with a use case of Google Wave for artists and Film-making and everyday there are new ideas on how Wave could be used.

Read More

Damn Small PHP Frameworks. Because size does matter.

First of all let me clarify, that if you are looking for a Symfony, CodeIgniter, CakePHP.. etc article, this is not what you are looking for. In this article you will find small and extra lightweight PHP frameworks that in some cases, can make your life easier. Really.

Why use a framework?

Because re-inventing the wheel again and again is something a productive (note the word used: productive* ) developer, should not do. By using a framework that supports the MVC patern (Model,View,Controler), you can keep your code readable and understandable, you seperate application logic from presentation and many more things that would require more than an article to cover.

Kohana

We start our listing with the Kohana framework. The Kohana team describes the framework as a PHP5 framework with support to the MVC architectural pattern that aims to be secure, lightweight and easy to use. The full package sized only 1.5MB (629KB compressed) has everything you need to create great and fully functional php applications. Some of the modules included are:

  • Archive – Compressed archive creation, supports zip, tar, gzip, and bzip.
  • Auth – Simple authentication and user management. Uses ORM for models.
  • Gmaps – Google Maps integration, geolocation, and API support.
  • Kodoc – Dynamic self-generated documentation. (Beta!)
  • Payment – Provides merchant and payment gateway wrappers. Supports Authorize.net, PayPal, Trident, Trust Commerce, and YourPay.

Great documentation (Wiki based, this means that everyone can contribute. Something like the PHP Manual, where user comments are the real documentation) , excellent and small tutorials like : Creating a blog with Kohana Part 1 and Part 2, make learning the kohana framework a lot easier.

Rapyd

Rapyd is another small php framework that can also be used as a library. 250KB of compressed files with an uncomressed size of 484KB. It is definetely impressive what you can do with it. Some of it’s features:

  • No compiling, no command line needed, just unzip, it will work.
  • PHP5 Strict
  • Modules support
  • Nice URLs (SEO oriented)
  • Tiny MVC in few files

epicode

epicode is an extremely lightweight PHP framework. It includes caching, session, database, form validation, twitter, oauth and asynchronous/non-blocking curl components. EpiCode started off as an MVC framework but has evolved into a set of extremely useful tools. Every tool is completely decoupled so they can be used independently or in conjunction. Each library in EpiCode is thought out and implemented in an extremely cohesive manner. The documentation can be found here.

Extra Light Framework

ELF PHP is a php framework with a very small footprint, built on Model-View-Controller architecture. Believe it or not, PHP ELF is sized only 39KB compressed and when extracted it’s size is only 72KB. Although it’s small size it features:

  • Caching system
  • URL Routing system
  • Logging system
  • Requests handler
  • Image manipulation class
  • Database abstractization
  • Minimal server load

and the plans for the Beta 3 include adding:

  • Validation class
  • Session class
  • Pagination class
  • File upload
  • Common scripts
  • Improved caching engine
  • Improved models

BaseApp

BaseApp Framework is aimed at individual commercial developers or small web application builders who need a starting point.Also if you are a CakePHP User you will find yourself at home with the API. BaseApp was inspired by CakePHP And Codeigniter but tries to do everything under 50 kb.
It has support for most common features available in frameworks these days but achieves all this in under 50 Kb of compressed Code and not MBs of it. Some technical data:

  • PHP 5 with support for new features like autoloading etc.
  • Fully MVC ( But can be used as a library also ).
  • CakePHP API ( 80 % ) and Layout.
  • Active Records and Object Relation Ship Mapping (ORM).
  • Model Validation with complementing form helpers.
  • Data Abstraction Layer with Adodb Support ( Almost all databases supported ).
  • Extensive Debugging and Exception Handling facilities ( FireBug Support Built in ).
  • Extendable Cookie and Session Handling.
  • Search engine friendly and url routing features.
  • Ajax Support through Jquery.

The project is hosted on Google code.

Read More