How to use WordPress XML-RPC?

Posted: 16th July 2010 by Joys of Programming in Wordpress, XML-RPC

http://blogrescue.com/2010/03/wordpress-and-xml-rpc/

http://codex.wordpress.org/XML-RPC_wp

How to make use of Kernest Fonts in your Website?

Posted: 15th July 2010 by Joys of Programming in Web
Tags: Google Fonts, kernest fonts, web fonts

Kernest is a collection of web fonts. If you are not aware of what is a web font, you can refer the article on using Google Fonts in your website.

Choose a font from Kernest and get the associated link of the font. For example, let’s use Gamaliel. The associated link is


http://kernest.com/fonts/gamaliel.css

To use this font, we must specify this link as the CSS style

<link href="http://kernest.com/fonts/gamaliel.css" media="screen" rel="stylesheet" type="text/css"

Now let’s write a small stylesheet which makes use of this font. All you have to do is to specify Gamaliel as the font family

<style>
h1 {
 font-family: 'gamaliel',arial,serif;
 font-size: 52px;
}
</style>

As you can see, I am using Gamaliel for the h1 tag

This font can be seen in action here.

The source code of the page is

<html>
<head>
<title>Kernest Fonts: Examples- Joys of Programming</title>
<link href="http://kernest.com/fonts/gamaliel.css" media="screen" rel="stylesheet" type="text/css"
<style>
h1 {
 font-family: 'gamaliel',arial,serif;
 font-size: 52px;
}
</style>
</head>
<body>

<h1>Joys of Programming: Experimenting with Kernest Fonts</h1>
</body>
</html>

With web fonts, you can turn your web site with any great looking fonts- something similar to those found in books

Are you tired of using some default fonts commonly available in all computers? Then you are not aware of web fonts? You may be wondering what is a Web Font? A browser displays the content of a web page normally available in a computer. It won’t be able to display the content of a website using unrecognized fonts (usually ending up in displaying with the available font). With a web-font, if the font is not present in the user’s computer, it will load the font from the link mentioned by the publisher.

So the primary requirement for using a web-font is to mention the source of the font. A lot of free and premium fonts are currently available. Google Font Directory contains some web-fonts. Let’s explore how to use these web fonts.

Choose a font from the Google Font Directory and get the associated link of the font. For example, let’s use Reenie Beanie. The associated link is


http://fonts.googleapis.com/css?family=Reenie+Beanie

To use this font, we must specify this link as the CSS style

<link href='http://fonts.googleapis.com/css?family=Reenie+Beanie' rel='stylesheet' type='text/css'>

Now let’s write a small stylesheet which makes use of this font. All you have to do is to specify Reenie Beanie as the font family

h1 {
 font-family: 'Reenie Beanie',arial,serif;
 font-size: 52;
}

As you can see, I am using Reenie Beanie for the h1 tag

This font can be seen in action here.

The source code of the page is

<html>
<head>
<title>Google Font API: Examples- Joys of Programming</title>
<link href='http://fonts.googleapis.com/css?family=Reenie+Beanie' rel='stylesheet' type='text/css'>
<style>
h1 {
 font-family: 'Reenie Beanie',arial,serif;
 font-size: 52;
}
</style>
</head>
<body>

<h1>Joys of Programming</h1>
</body>
</html>

If you want to work with XML-RPC, you must first install xmlrpc-c libraries. But if you are a developer and want to develop softwares using xmlrpc-c libraries, you must install the development packages. For ubuntu/linux

$ sudo apt-get install libxmlrpc-c3-dev

The header files will be available in /usr/include/xmlrpc-c and the libraries will be available in /usr/lib.

How to Install XML-RPC in Linux (Ubuntu)?

Posted: 21st June 2010 by Joys of Programming in C/C++, XML-RPC, libxmlrpc
Tags: libxmlrpc, libxmlrpc-c3, XML-RPC

To work with XML-RPC in Linux, you must install the xmlrpc-c libraries. In ubuntu, it is available as libxmlrpc-c3 package.

$ sudo apt-get install libxmlrpc-c3

More about the Ubuntu package libxmlrpc-c3 can be found here.

json_object_get_array: Access an array JSON object

Posted: 1st June 2010 by Joys of Programming in C/C++, JSON, Linux, json-c
Tags: json_object_get_array

json_object_get_array() is used to access an array within a  json object. JSON contains key:value pairs, where value can be an array. The values within an array can also be an array, integer, boolean, double.

#include <json/json.h>
#include <stdio.h>

void json_parse(json_object * jobj) {
  enum json_type type;
  json_object_object_foreach(jobj, key, val) {
    type = json_object_get_type(val);
    switch (type) {
      case json_type_array: printf("type: json_type_array, ");
                          jobj = json_object_object_get(jobj, key);
                          int arraylen = json_object_array_length(jobj);
                          printf("Array Length: %d\n",arraylen);
                          int i;
                          json_object * jvalue;
                          for (i=0; i< arraylen; i++){
                            jvalue = json_object_array_get_idx(jobj, i);
                            printf("value[%d]: %s\n",i, json_object_get_string(jvalue));
                          }
                          break;
    }
  }
}
int main() {
  char * string = "{ \"tags\": [ \"c++\", \"php\", \"java\"] \
                     }";
  printf ("JSON string: %s\n", string);
  json_object * jobj = json_tokener_parse(string);
  json_parse(jobj);
}

Let’s compile the program. If you fail any compilation issues, refer the post.
On executing the program, we get the following output

$ ./a.out
JSON string: { "tags": [ "c++", "php", "java"]                      }
type: json_type_array, Array Length: 3
value[0]: c++
value[1]: php
value[2]: java

The input to the program was

{
    "tags": [
        "c++",
        "php",
        "java"
    ]
}

json_object_object_get() is used to get the json object. JSON contains key:value pairs. The value can be an array, integer, boolean, double. It can also be a json object. That means to access the values within the json object, we must recursively go through json objects. The following program shows this

#include <json/json.h>
#include <stdio.h>

void json_parse(json_object * jobj) {
  enum json_type type;
  json_object_object_foreach(jobj, key, val) {
    printf("type: ",type);
    type = json_object_get_type(val);
    switch (type) {
      case json_type_null: printf("json_type_null\n");
                           break;
      case json_type_boolean: printf("json_type_boolean\n");
                           printf("          value: %d\n", json_object_get_boolean(val));
                           break;
      case json_type_double: printf("json_type_double\n");
                          printf("          value: %lf\n", json_object_get_double(val));
                           break;
      case json_type_int: printf("json_type_int\n");
                          printf("          value: %d\n", json_object_get_int(val));
                           break;
      case json_type_object: printf("json_type_object\n");
                           jobj = json_object_object_get(jobj, key);
                           json_parse(jobj);
                           break;
      case json_type_string: printf("json_type_string\n");
                           printf("          value: %s\n", json_object_get_string(val));
                           break;
    }
  }
}
int main() {
  char * string = "{\"sitename\" : \"joys of programming\",\
                     \"author-details\": { \"admin\": false, \"name\" : \"Joys of Programming\", \"Number of Posts\" : 10 } \
                     }";
  json_object * jobj = json_tokener_parse(string);
  json_parse(jobj);
}

Let’s compile the program. If you fail any compilation issues, refer the post.
On executing the program, we get the following output


$ ./a.out
JSON string: {"sitename" : "joys of programming",                     "author-details": { "admin": false, "name" : "Joys of Programming", "Number of Posts" : 10 }                      }
type: json_type_string
          value: joys of programming
type: json_type_object
type: json_type_boolean
          value: 0
type: json_type_string
          value: Joys of Programming
type: json_type_int
          value: 10

The input to the program was


{
    "sitename" : "joys of programming",
    "author-details": {
        "admin": false,
        "name" : "Joys of Programming",
        "Number of Posts" : 10
    }
}

As you can see that “author-details” is again a json object. See how the json_object_object_get() is recursively used to parse the json objects

Pages: 1 2 3 4 5 6 7 8 9 10 ...24 25 26 Next