RESTful (1): What is REST?
2012-05-11 @ 5:16 pm — rc
The term representational state transfer was defined in 2000 by Roy Fielding in chapter 5 of his doctoral dissertation Representational State Transfer (REST). REST is nothing more than the description Fielding defined in his dissertation. There is and will be no RFC or a specification for it by an authoritative organization. REST is mostly based on HTTP but can be based on other protocols. Fielding is also one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification versions 1.0 and 1.1.
A RESTful web service (or RESTful API) is a web service implemented using HTTP and the principles of REST with the following four aspects:
- base URI for the web service
- media type of the data, e.g. JSON or XML
- set of supported operations as HTTP methods (GET, PUT, POST, DELETE, etc)
- hypertext driven API
REST architecture describes the following six constraints:
- separation of concerns between client and server, e.g. client is responsible for UI and server for data storage.
- stateless, each request must include all information to service the request
- cacheable client to prevent unnecessary client-server messaging
- code on demand (optional), server should be able to extent client functionality by including client-side code
- uniform interface, four guiding principles:
- identification of resources, e.g. using a URI
- client must have enough information to be able to manipulate the resource representation
- self-descriptive messages
- HATEOAS, Hypermedia as the engine of application state
REST vs SOAP
|
REST |
SOAP |
| typing |
weak |
strong |
| requires message header |
no |
yes |
| requires XML parsing |
no |
yes |
| error handling |
HTTP |
user defined |
| asynchronous support |
no |
yes |
| stateful |
no |
yes |
| |
|
|
|
|
|
|
|
|
WordPress: Hello World Widget
2012-01-13 @ 8:36 pm — rc
Hello World Widget Area
To add widgets to your theme, you must have or create a ‘widget area’ as a widget placeholder and a widget to add to your widget area.
In the functions.php file of your theme, you can create a custom widget area by using the following code.
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name'=> 'Hello World Widget Area',
'id' => 'hello_world',
'before_widget' => '<div id=\"%1$s\" class=\"widget %2$s\">',
'after_widget' => '</div>',
'before_title' => '<div id=\"div_hello_world_title\">',
'after_title' => '</div>',
));}
Hello World Widget
This simple method does not use the extension of the WP_Widget class, which is the preferred method.
In the functions.php file of your theme, add the following code for the HelloWorld Widget.
function widget_helloworld() {
echo \"Hello World!\";
}
if (function_exists('register_sidebar_widget')) {
register_sidebar_widget(__('Hello World Widget'), 'widget_helloworld');
}
To add your widget to the dynamic sidebar:
- Go to your WordPress Dashboard > Appearance > Widgets, and
- Drag’n'drop the Hello World Widget to the dynamic sidebar on the right.
Hello World Template
Finally, you need a template to include your widget area. Create a helloworld.php file and include the following code.
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Hello World Widget Area')) : ?>
<!-- if widgets are not available -->
<?php endif; ?>
| |
|
|
|
|
Google Maps API v3
2011-09-20 @ 9:51 pm — rc
1. To create an empty Google Map in your webpage:
a. Load the Google Map API from http://maps.googleapis.com/maps/api/js
b. Create a div element to place the map
c. Create the Map Options literal to define a Map Type and a center point with Longitude and Latitude
d. Create an instance of your actual map
e. Load the map on your page
http://learnfromlocals.com/examples/google-maps-example1.html
2. To create a Google Map with Markers and Info Windows
a. Follow the Steps described under 1.
b. To add points to your map, you need to add so-called overlays with markers to your map.
http://learnfromlocals.com/examples/google-maps-example2.html
var map;
var infowindow = new google.maps.InfoWindow();
function initialize() {
var latlon0 = new google.maps.LatLng(37.918201, 25.44342);
var options = {
zoom: 7,
center: latlon0,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), options);
addMarker(37.030994, 25.499511, 'Cave of Zeus, Naxos, Greece');
addMarker(37.609421, 26.239854, 'Birthplace of Dionysis, Mount Pramnos, Ikaria, Greece');
addMarker(38.496594, 26.130066, 'Homer's Rock, Vrandados, Chios, Greece');
}
function addMarker(lat, lon, content){
var latlon = new google.maps.LatLng(lat, lon);
var marker = new google.maps.Marker({
position:latlon,
map: map,
title:content
})
google.maps.event.addListener(marker, 'click', function(){
infowindow.close();
infowindow.setContent(content);
infowindow.open(map, marker);
});
}
3. Use a simplified JavaScript library to create a Google Map with markers and InfoWindows:
a. Add a script tag to load caprioit-googlemaps-lib.js,
b. Create a map,
c. Add the markers.
http://learnfromlocals.com/examples/google-maps-example4.html
var divid = 'map_canvas';
var zoomlevel = 7;
var centerlat = 37.918201;
var centerlon = 25.44342;
var maptypeid = google.maps.MapTypeId.ROADMAP;
var map = new MyGoogleMap(divid, zoomlevel, centerlat, centerlon, maptypeid);
map.addMarker('Cave of Zeus, Naxos, Greece', 37.030994, 25.499511);
map.addMarker('Birthplace of Dionysis, Mount Pramnos, Ikaria, Greece', 37.609421, 26.239854);
map.addMarker('Homer's Rock, Vrandados, Chios, Greece', 38.496594, 26.130066);
|
comments (0) | category: it |
|
|
|
|
Page Load Order and Page Load Performance
@ 3:31 pm — rc
Page Load Order
1. HTML is parsed
2. External scripts/style sheets are loaded
3. Scripts are executed as they are parsed
4. DOM is constructed
5. Images and external content are loaded
6. Page is finished loading
Page Load Performance
|
comments (0) | category: it |
|
|
|
|
Coefficient of Relationship
2009-07-15 @ 10:12 pm — rc
The index of relatedness or the coefficient of relationship expresses the chance of a gene being shared between two individuals A and B. To calculate the relatedness find the common ancestor(s). Having located the common ancestor(s), count the generation distance between the common ancestor(s) and respectively A and B. Add up the generation distance of A and the generation distance of B to find the total generation distance of A and B.
r = a * (1/2)^g
where
r = relatedness
a = common ancestor(s)
g = generation distance
E.g.
First cousins have 2 common ancestors, thus a=2, with a generation distance of 2+2=4, thus g=4.
relatedness between first cousins = 2 * (1/2)^4 = 2 * (1/2 * 1/2 * 1/2 * 1/2) = 1/8
For relationships as distant as third cousin (2 * (1/2)^8=1/128) the relatedness is close to the baseline probability that a gene will be shared by any random individual taken from the population.
- Joe Chang, Professor of Statistics, Yale University (yale.edu)
| |
|
|
|
|
Eclipse 3.5 Galileo on Ubuntu 9.04 Jaunty Jackalope
2009-06-25 @ 10:37 am — rc
By default Eclipse 3.2 which is packaged with Ubuntu 9.04 and can be installed using the Synaptic Package Manager runs with the GNU Compiler for Java, GCJ JVM and not the JVM provided by SUN. Additionally, Eclipse for Ubuntu is missing jUnit 4 due to legal restrictions on its use of Java 5, and it is disabled, causing import problems that prevents updating software or installing new features.
1. change java sdk
To check which java sdk is available:
sudo update-java-alternatives -l
Set the java-6-sun as the default java sdk:
sudo update-java-alternatives -s java-6-sun
2. download the x86 32bits version for linux of Eclipse Galileo, extract the archive and copy it to /usr/local/bin/eclipse-3.5
http://www.eclipse.org/downloads/
3. set JAVA_HOME in .bashrc
#configuration for java
JAVA_HOME=”/usr/lib/jvm/java-1.6.0-sun”
export JAVA_HOME
PATH=.:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export PATH
4. create a startup script, copy it to /usr/bin and make sure the username:group permission are 755 for the correct user
#!/bin/bash
PATH=/usr/lib/jvm/java-6-sun-1.6.0.13/bin:$PATH
/usr/local/bin/eclipse-3.5/eclipse
5. add the /usr/bin/eclipse script to the desktop menu via the >System>Preferences>Main Menu option which will create a desktop configuration file ~/.local/share/applications/alacarte-made.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/usr/local/bin/eclipse-3.5/icon.xpm
Exec=/usr/bin/eclipse
Name[en_US]=Eclipse Galileo 3.5
Name=Eclipse Galileo 3.5
Icon=gnome-panel-launcher
or create a desktop configuration file /usr/share/applications/eclipse.desktop
[Desktop Entry]
Type=Application
Name=Eclipse 3.5 Galileo
Icon=/usr/local/bin/eclipse-3.5/eclipse.xpm
Exec=/usr/bin/eclipse
Categories=Application
Alacarte is a menu editor for GNOME desktop, it implements the XDG menu specification.
| |
|
|
|
|
Opera: customize size of speed dial
2009-06-22 @ 2:47 am — rc
To customize the number of rows and columns of opera’s speed dial option:
1. in the address bar type opera:about to locate the .opera configuration directory;
2. close opera to prevent it from editing the config files we need to adjust;
3. open the speeddial.ini and add the size configuration somewhere in the file:
[size]
rows:3
columns:6
4. start opera.
| |
|
|
|
|
FIX and AdsML
2009-06-15 @ 8:32 am — rc
FIX or Financial Information eXchange Protocol is a series of messaging specifications for trade-related messages.
AdsML is an initiative supported by Ifra, an international association for media publishing, the Newspaper Association of America (NAA) and IDEAlliance, a leader in XML-based standards development for the graphics communication industry, to create a comprehensive standard for end-to-end advertising workflow.
|
comments (0) | category: it |
|
|
|
|
|
|
|
|
| |
|
|
|
|
The Death of Literature Death in literature is an elementary metaphor, as the fear of death is one of our Id’s primal impulses, together with the sexual urge to reproduce and overcome it. The resurrection of our mind is the symbol for the cycle of life, the seasons, birth and death, crucifixion and resurrection, destruction and creation, night and day, there’s probably nothing more universal, nothing more primal than death and life. The article in the Guardian In theory: the death of literature is a great short essay that analyzes the perspective of the Romantics on death in literature as an elementary original perspective that lays at the root of the birth of the modern novel. It’s a very original view with lots of references in high overview, which makes it easy to make any argument, but it’s convincing until midway when the argument becomes an old man’s lamentation on modern times. Here is where the author Andrew Gallix the other essence of the Romantics in my opinion, namely the overcoming of the fear of death in favor of a naive and blind will for creation, this resurrection of the conscious mind is what represents the true power of the Romantic era. In the face of death we are not afraid to throw ourselves in the abyss and love.
Der Zauberberg (1982) An international production of Thomas Mann’s 20th century classic about the first world war, Der Zauberberg (1982).
Divine Mathematics: George Cantor and Infinity In Dangerous Knowledge – BBC, Georg Cantor’s Continuum Hypothesis and Georg Cantor‘s life is described. Cantor was obsessed with the problem of infinity. Cantor reminds me Pythagoras, who founded a religious school of Pythagoreans who searched the divine truth by revealing the mathematical formulas that described nature.
Boltzmann defined a breakthrough in the field of probability, which is crucial for the theory of entropy and chaos.
Solve Puzzles for Science - Fold.it Solve puzzles for science with Fold.it. Crowd-sourcing scientific problems.
The Master and Margarita - Russia TV The Master and Margarita – Russia TV
Russia’s first television production of The Master and Margarita, the novel by Mikhail Bulgakov. Vladimir Bortko is the director and screenwriter of the new adaptation. The mini-series of ten 52-minute episodes was first screened on the state television channel “Россия” (“Russia”) on December, 2005. The Master and Margarita is a novel by Mikhail Bulgakov, woven about the premise of a visit by the Devil to the fervently atheistic Soviet Union. Many critics consider the book to be one of the greatest novels of the 20th century, as well as one of the foremost Soviet satires, directed against a suffocatingly bureaucratic social order.
Hunting the Hidden Dimension Hunting the Hidden Dimension Pt. 1
This film is about looking at the world around us in a completely different way. If you pay attention, you can see that fractals appear throughout nature. But until Benoit Mandelbrot came along, no one really understood what was there all along. more...
Benoit Mandelbrot, Father of Eternity, Coined the Term 'Fractal' Benoit Mandelbrot, Mathematician, Dies at 85
Dr. Mandelbrot coined the term “fractal” to refer to a new class of mathematical shapes whose uneven contours could mimic the irregularities found in nature.
Comparative Democracy Originally, I was playing with the idea that representatives should have to pass an exam to become eligable to run for political office. While listening to C-SPAN broadcasts of Congress committees, or members of Congress giving interviews to NPR, where on some shows they are allowed more speaking time than the 20 or 30 seconds, I am too often shocked by the lack of depth and the absence of fact in their statements. more...
The Tree of Life The Tree of Life Project (ToL) is a collaborative effort of biologists from around the world. The project provides information about the diversity of organisms on Earth, their evolutionary history (phylogeny), and characteristics.
Another project that visualizes the phylogeny of life for the plants phylum is Deep Green by the Green Plant Phylogeny Research Coordination Group of Berkeley University.
Litarary Word Comparison Introduction
This is one of the small research projects that I am currently conducting. I am not pretending to offer or accomplish any scientific added value to the research community in the field of Natural Language Processing (NLP) but humbly submit my efforts to gain further personal learning. While the research remains unfinished and until I publish it formally, I will keep this post as a mini-post. As a Universal Man, a Humanist, a Renaissance Man each individual man has an obligation to question and further his or her knowledge and understanding, as it lies within our capacities. Learning is a tool to humble our heart, and most of all we should mistrust brave hearts.
Matt Ridley in his book Nature via Nurture says (says Richard Dawkins in his The Ancestor’s Tale in The Mouse Tale chapter) that “the list of words in David Copperfield is almost the same as the list of words in The Catcher in the Rye.” Springing from this saying, I concluded that it would be an interesting project to create a plotter diagram in which the major works in literature (written, translated or edited into modern English for reasons of ease of comparison) are set out as number of total words versus the number of different words used and another network graph that displays the relative closeness of literary works by words used. The first diagram is the easiest to create of course, so I will start with this first, then moving on to the next network diagram. more...
|