What are breadcrumbs?

Well quite simply, in web page terms this refers to a list of links (usually at the top) that appear on a web page to tell the user where they are in the structure of the website they are viewing. This makes navigating backward and forward so much easier as they have the ability to skip directly back through whole categories, rather than just using the browser’s back button.

Example

The breadcrumbs.php include file:

Copy the code below, save it in a file called breadcrumbs.php and upload it to your site. This will print out a simple unordered list (<ul>) of the parent directories by directory name. The only edits you may wish to make to this file is to change the $ul_id='crumbs'; line if you wish to change the id of the <ul>. If you wish to add a background image or border etc to the <li> simply select it as #crumbs li{} and style.


</code><?
$ul_id='crumbs';
$bc=explode("/",$_SERVER["PHP_SELF"]);
echo '<ul id="'.$ul_id.'"><li><a href="/">Home</a></li>';
while(list($key,$val)=each($bc)){
 $dir='';
 if($key > 1){
  $n=1;
  while($n < $key){
   $dir.='/'.$bc[$n];
   $val=$bc[$n];
   $n++;
  }
  if($key < count($bc)-1) echo '<li><a href="'.$dir.'">'.$val.'</a></li>';
 }
}
echo '<li>'.$pagetitle.'</li>';
echo '</ul>';</pre>
?>   This is some more usefull code
<pre><?
$url = $_SERVER['REQUEST_URI'];
echo $url;
echo "<br>";
$array = explode("/",$url);
echo $array[2]; ///which folder would you want to access ?
echo "size of array = ".sizeof($array)."<br>";
?><code>

A script to insert in the HTML where you want the breadcrumbs to appear:

Edit the URI to point to where you saved the include file (once this is done it never needs to be changed again). Edit, ‘Insert Page Title’ to add the page title to the end of the breadcrumbs.


</code><?
$pagetitle="Insert Page Title";
include("http://www.yourdomain.com/breadcrumbs.php");
?>

Note: It would be useful to automatically print the page <title> as the last crumb but PHP cannot interogate the DOM. Javascript would be required which we didn't think appropriate as nothing would be returned if Javascript was turned off.

Many people facing this problem for many kind of situations like … create dynamic javascript or css menu..,  navigation,  hit counter… for page..

you can use set variable names for page.  second good way is use this function for print page name $_SERVER["PHP_SELF"]

or if you want only page name than use this script


<?php

$pagename=pathinfo($_SERVER["PHP_SELF"]);
$pagename=$pagename["basename"];

echo $pagename;

?>

This is some more helpfull code…


$url = $_SERVER['REQUEST_URI'];
echo $url;
echo "<br>";
$array = explode("/",$url);
echo $array[2]; ///which folder would you want to access ?
echo "size of array = ".sizeof($array)."<br>";

URL unicode is another method for Creating Pretty or Clean Url and creating breadcrumbs

In this tutorial I am going to show you how to easily create or achieve the drag & drop event using flash action script

Step 1

Open flash then select file >> new >> flash document


Now in left side menu bar you can select rectangle, or circle

Here I chosen circle.

Create a circle on your blank workspace

Now make this circle a movie clip

Select modify >> convert to symbol

You will see convert to symbol dialog box

In that dialog box you have to select behavior “button” option

Place a name “circle_1” in name box & click ok

You can use any name as per your choice

Go to in action scrip panel

Please select first your object &

Select + sign

Global functions >> movie clip control >> on

Now select

Global function >> movie clip control >> start drag

You need to select the circle and right click on that and select action option.

In action panel copy paste the following code.

on (press) {startDrag(this)}

onClipEvent (mouseUp) {stopDrag()}

pressing following key you can see the drag and drop event.

Press short cut key “ctrl + enter”

You program will be run & you can drag your object by action script

You can download the original file from here : drag-drop-event

Advances in technology have revolutionized the way people live, learn and work, but these benefits have not spread around the world evenly. A digital divide exists between communities in their access to computers, the Internet, and other technologies. The United Nations is aware of the importance of including technology development as part of a larger effort to bridge this global digital divide. This article looks at how various United Nations agencies use free and open source software to meet the goal of putting technology at the service of people around the world.

The Millennium Development Goals

The Millenium Development Goals (MDGs) are a set of eight targets to help end extreme poverty worldwide by 2015. The United Nations Information and Communication Technologies Task Force, created in March 2001, has worked to advance the development goals and targets of the UN, in particular those set by the Millennium Declaration. The Global Alliance for ICT and Development (GAID) group replaced UNICTTF, and now has the task of providing an open policy dialogue on the role of information and communication technologies in development.

In their report The Role of Information and Communication Technologies in Global Development: Analyses and Policy Recommendations, the Task Force states that information and communication technologies will increasingly become one of the main enablers in the pursuit of poverty alleviation and wealth creation in developed and developing countries alike. It’s easy to overlook the importance of technology in development, though. When people are starving and don’t have access to clean water, does it matter if they have access to the Internet? Technology is not an end in itself in these situations, but it is a tool to achieve wider goals such as eradicating hunger and achieving universal primary education.

To help raise awareness of the potential for free and open source software in this area, various UN organizations and nonprofits have created the FOSS: Policy and Development Implications (FOSS-PDI) initiative. Part of this initiative consists of a mailing list that discusses specific FOSS applications that address the different MDGs, information about how different countries are using open source software, and coordination for events being planned around the world.

MySQL provides a SHOW statement that has several variant forms that display information about databases and the tables in them. SHOW is helpful for keeping track of the contents of your databases and for reminding yourself about the structure of your tables. You can also use SHOW prior to issuing ALTER TABLE; it’s often easier to figure out how to specify a change to a column after you determine the column’s current definition.

The SHOW statement can be used to obtain information about several aspects of your databases and tables:

  • List the databases managed by the server:
    SHOW DATABASES;
  • List the tables in the current database or in a given database:
    SHOW TABLES;
    SHOW TABLES FROM db_name;
  • Note that SHOW TABLES doesn’t show TEMPORARY tables.
  • Display information about columns or indexes in a table:
    SHOW COLUMNS FROM tbl_name;
    SHOW INDEX FROM tbl_name;
  • The DESCRIBE tbl_name and EXPLAIN tbl_name statements are synonymous with SHOW COLUMNS FROM tbl_name.
  • Display descriptive information about tables in the current database or in a given database:
    SHOW TABLE STATUS;
    SHOW TABLE STATUS FROM db_name;
  • This statement was introduced in MySQL 3.23.0.
  • Display the CREATE TABLE statement that corresponds to the current structure of a table:
    SHOW CREATE TABLE tbl_name;
  • This statement was introduced in MySQL 3.23.20.

Several forms of SHOW take a LIKE 'pat' clause allowing a pattern to be given that limits the scope of the output. 'pat' is interpreted as a SQL pattern that can include the ‘%‘ and ‘_‘ wildcard characters. For example, the following statement displays the names of tables in the current database that begin with 'geo':

SHOW TABLES LIKE 'geo%';

To match a literal instance of a wildcard character in a LIKE pattern, precede it with a backslash. Generally, this is done to match a literal ‘_‘, which occurs frequently in database, table, and column names.

The mysqlshow command provides some of the same information as the SHOW statement, which allows you to get database and table information from the shell:

  • List databases managed by the server:
    % mysqlshow
  • List tables in the named database:
    % mysqlshow db_name
  • Display information about columns in the named table:
    % mysqlshow db_name tbl_name
  • Display information about indexes in the named table:
    % mysqlshow --keys db_name tbl_name
  • Display descriptive information about tables in the named database:
    % mysqlshow --status db_name

The mysqldump utility allows you to see the structure of your tables in the form of a CREATE TABLE statement (much like SHOW CREATE TABLE). When using mysqldump to review table structure, be sure to invoke it with the --no-data option so that you don’t get swamped with your table’s data!

% mysqldump --no-data db_name tbl_name

If you omit the table name, mysqldump displays the structure for all tables in the database.

For both mysqlshow and mysqldump, you can specify the usual connection parameter options (such as --host or --user.)

Determining Which Table Types Your Server Supports

ISAM is the only type available before MySQL 3.23. From 3.23 on, MyISAM, MERGE, and HEAP are always available, and availability of the other types can be assessed by means of an appropriate SHOW VARIABLES statement:

SHOW VARIABLES LIKE 'have_isam';
SHOW VARIABLES LIKE 'have_bdb';
SHOW VARIABLES LIKE 'have_inno%';

If the output from the query shows that the variable has a value of YES, the corresponding table handler is enabled. If the value is something else or there is no output, the handler is unavailable. The use of the pattern have_inno% to determine InnoDB availability matches both have_innodb and have_innobase. (The latter form was used in MySQL 3.23.30 to 3.23.36 before being renamed to have_innodb.)

You can use table type information to determine whether your server supports transactions. BDB and InnoDB are the two transaction-safe table types, so check whether their handlers are enabled as described in the preceding discussion.

As of MySQL 4.1, the list of table types is available directly through the SHOW TABLE TYPES statement:

mysql> SHOW TABLE TYPES;
+--------+---------+-----------------------------------------------------------+
| Type   | Support | Comment                                                   |
+--------+---------+-----------------------------------------------------------+
| MyISAM | DEFAULT | Default type from 3.23 with great performance             |
| HEAP   | YES     | Hash based, stored in memory, useful for temporary tables |
| MERGE  | YES     | Collection of identical MyISAM tables                     |
| ISAM   | YES     | Obsolete table type; Is replaced by MyISAM                |
| InnoDB | YES     | Supports transactions, row-level locking and foreign keys |
| BDB    | YES     | Supports transactions and page-level locking              |
+--------+---------+-----------------------------------------------------------+

The Support value is YES or NO to indicate that the handler is or is not available, DISABLED if the handler is present but turned off, or DEFAULT for the table type that the server uses by default. The handler designated as DEFAULT should be considered available.

Checking a Table’s Existence or Type

It’s sometimes useful to be able to tell from within an application whether or not a given table exists. You can use SHOW TABLES to find out:

SHOW TABLES LIKE 'tbl_name';
SHOW TABLES FROM db_name LIKE 'tbl_name';

If the SHOW statement lists information for the table, it exists. It’s also possible to determine table existence with either of the following statements:

SELECT COUNT(*) FROM tbl_name;
SELECT * FROM tbl_name WHERE 0;

Each statement succeeds if the table exists and fails if it doesn’t. The first statement is most appropriate for MyISAM and ISAM tables, for which COUNT(*) with no WHERE clause is highly optimized. (It’s not so good for InnoDB or BDB tables, which require a full scan to count the rows.) The second statement is more general because is runs quickly for any table type. Use of these queries is most suitable for use within application programming languages, such as Perl or PHP, because you can test the success or failure of the query and take action accordingly. They’re not especially useful in a batch script that you run from mysql because you can’t do anything if an error occurs except terminate (or ignore the error, but then there’s obviously no point in running the query at all).

To determine the type of a table, you can use SHOW TABLE STATUS as of MySQL 3.23.0 or SHOW CREATE TABLE as of MySQL 3.23.20. The output from both statements includes a table type indicator. For versions older than 3.23.0, neither statement is available; but then the only available table type is ISAM, so there is no ambiguity about what storage format your tables use.

As of MySQL 4.1, the list of table types is available directly through the SHOW TABLE TYPES statement:

mysql> SHOW TABLE TYPES;
+--------+---------+-----------------------------------------------------------+
| Type   | Support | Comment                                                   |
+--------+---------+-----------------------------------------------------------+
| MyISAM | DEFAULT | Default type from 3.23 with great performance             |
| HEAP   | YES     | Hash based, stored in memory, useful for temporary tables |
| MERGE  | YES     | Collection of identical MyISAM tables                     |
| ISAM   | YES     | Obsolete table type; Is replaced by MyISAM                |
| InnoDB | YES     | Supports transactions, row-level locking and foreign keys |
| BDB    | YES     | Supports transactions and page-level locking              |
+--------+---------+-----------------------------------------------------------+

Introduction

C_Language_Tutorial

C is a basic language to learn the programming. Actually what is meaning of programming. Programming means input of row material, which gives us the magical statue of output on which we can ride a long journey of programming. Before c language, many

Language written such as…

COBAL

FORTRAN

ALGOL 60

CPL

BCPL

PASCAL…(etc)

B and bcpl was very close to c, because the co-worker of Dennis Ritchee wrote it. Dennis studied those languages and made advance version of them. Which afterwards

Famous as c language

Getting c started

We have known to learn any language we first know about alphabets, keywords, and special symbols. Same way in c language also we have to know

Those things in c also.

Alphabets… A, B, C… X, Y, Z

a, b, c……x, y, z

Digits… 1,2,3,4,5,6,7,8,9

Special symbols… ~, !, @,#,$,%,^,&,*,(,),_,-,+,=,|,\,{,[

},],:,;,”,’,<,,,>,.,?,/

Types of c constants

Primary constants

1) Integer constants

2) Real constant

3) Character constant

Secondary constant

1) Array

2) Pointer

3) Structure

4) Union

5) Enum

Data Types

1) Integer,

2) Character,

3) Float,

4) Double…(etc)

lets know what we say to special symbols

1)’~’= approximately equal to.

2)’! =’= Is not equal to.

3)’@’= at the rate.

4)’#’= hash.

5)’$’=

6)’^’=

7)’&&’= and.

8)’!!’= Or.

9)’{’= open curly brasses.

10)’}’= close curly brasses.

How to compile and run the program

Short way to compile Alt + F9 and to run the program Ctrl + F9 should press.

let’s start our Some basic programs

Any comment we have to write in /**/ these pattern.

Syntax of simple programs

#include<stdio.h>                                          /*header file/

#include<conio.h>                                         /*header file/

void main()

{

clrscr();

/*any opration*/

getch();

}

These is the basic syntax of any programs the topic changes some data add in these but syntax remain constant.

/*simple print hello pune statement */

#include<stdio.h>                             /*header file */

#include<conio.h>                            /*header file */

void main()

{

printf(“\nhello pune”)/             \*n = new line */

getch();

}

Output  = “hello pune”

In these program we just print simple statement hello pune which have been written in printf statement (line no 5).

Integer data type

Integer data type include the number such as 1,2,3,4,5,6,7,8,9…

1)/*addition type program through keyboard/…(comment)

#include<stdio.h>                            /*header file */

#include<conio.h>                          /*header file */

void main()

{

int a,b,c;                                         /*integer data type */

clrscr();

printf(“enter the nos”);

scanf(“%d%d”,&a,&b);

c=a+b;                                          /*operation */

printf(“\n%d”,c);

getch();

}

Output = enter two value through keyboard you will get addition

of them.

In these program we have taken 3 integer variable, in these program we have to enter 2 values from keyboard and it will show us the addition of these, because we have perform the operation at line no 9.

/*Addition type without keyboard/

#include<stdio.h>                      /*header file */

#include<conio.h>                    /*header file */

void main()

{

int a=3,b=5,c;                            /*integer data type */

clrscr();

scanf(“%d%d”,&a,&b);

c=a+b;

printf(“\n%d%d”,a,b);

getch();

}

Output = you will get addition of 3&5=8.

In these program we have taken 3 integer variables for these we have taken the value of them in program itself, c variable use to do the addition operation.

Character data type

Character data type include the alphabets…A, B, C…X, Y, Z. and a, b, c…x, y, z.

1)/*multiplication using keyboard */

#include<stdio.h>                            /*header file */

#include<conio.h>                             /*header file */

void main()

{

char ‘a’;                                             /*character data type */

clrscr();

scanf(“%c”,&a);

printf(“\n%c”,a);

getch();

}

Output = type any alphabet, that will display again.

In these program we have taken only one character and we have to put these value of that constant. And it will print again. Any single character we have to write in single cotton (‘a’).

Float data type

Float is one of the data type in which we have to enter only numbers which include decimal points. Such as 111.23,14.12,11.00 etc. Though you takes value without decimal point it will also consider, such as if we write value as 112 it will display as 112.00 which means as these value include decimal point.

#include<stdio.h>/*header file */

#include<conio.h>/*header file */

void main()

{

float a,b,c;

clrscr();

printf*(“\nenter the nos”);

scanf(“%f%f%f”,&a,&b,&c);

c=a-b;

printf(“\nc=%d”,c);

getch();

}

Output = subtraction of a and b.

In these program we have to take two such values such as it should contain decimal point. After compiling these c will perform subtraction operation.

/*To calculate the gross salary, of any person whose dearness allowance is 60% of basic salary, and house rental allowance is 40% of basic salary. And basic salary is input */

#include<stdio.h>                                    /*header file */

#include<conio.h>                                  /*header file */

void main()

{

float basic p,da,grpay,hra;                   /*float data type */

clrscr();

printf(“\nenter the nos”);

scanf(“%f”,&basic p);

da=0.6*basic p;                                 /*operation */

hra=0.4*basic p;                               /*operation */

grpay=basic p+da+hra;                   /*operation */

printf(“\n%f”,da);

printf(“\n%f”,hra);

printf(“\n%f”,grpay);

getch();

}

Output = In these program we have to enter the basic salary through keyboard and you will get gross salary.

In these program we have taken basic salary as input and after that da, hra, grpay, are calculated by formula.

/*The distance between two cities (in km) is input through keyboard

Write a program to convert and print these numbers in to meter, inches and centimeter */

#include<stdio.h>                         /*header file */

#include<conio.h>                       /*header file */

void main()

{

float km,m,cm,inches,ft;             /*float data type */

clrscr();

printf(“\nenter the distance in km”);

scanf(“%f”,&km);

m=km*1000;                             /*operation */

cm=m*100;                              /*operation */

inches=m/2.54;                       /*operation */

ft=inches/12;                          /*operation */

printf(“ \n%f”,m);

printf(“\n%f”,cm);

printf(“\n%f”,inches);

printf(“\n%f”,ft);

getch();

}

Output = suppose you have enter distance in km is 1000,then distance in m=1000000,cm=100000000,inches=40000000,ft=3333333.25,will found as we done in operation.

/*If marks obtain by a student in five subjects. Calculate the average and percentage. Consider that all marks out of 100*/

#include<stdio.h>                                          /*header file */

#include<conio.h>                                         /*header file */

void main();

{

int a,b,c,d,e,avg;                                            /*float data type */

float per;

clrscr();                                                           /*float data type */

printf(“enter the marks of subjects”);

scanf(“%d%d%d%d%d”,&a,&b,&c,&d,&e);

avg=a+b+c+d+e;                                           /* operation */

per=avg/5;                                                      /* operation */

printf(“%d%f”,avg,per);

getch();

}

Output = suppose we enter the marks of subject just as 77,66,55,69,72,then the avg=339and per=67.00.

5)/*Temperature of a city in Fahrenheit degree is input through the keyboard.Write a program to convert these temperature into centigrade degree */

#include<stdio.h>

#include<conio.h>

void main()

{

float fr,cent;

clrscr();

printf(“enter the temperature in farad”);

scanf(“%d”,&fr);

cent=5.0/9.0*(fr-32);

printf(“temperature in centigrade=%f”,cent);

getch();

}

Output = suppose you have enter the temperature in centigrade is 200 then the temperature in fr will be 93.33.

6)/*length & breadth of a rectangle and radius of circle are input through the keyboard. Write a program to calculate the area &perimeter of the area & circumference of the circle */

#include<stdio.h>

#include<conio.h>

void main();

{

int l,b,r,area1,perimeter;

float area2,circum;                                        /*float data type */

clrscr();                                   /*float data type */

printf(“enter the length & breadth of rentangle”);

scanf(“%d%d”,&l,&b);

area1=l*b;                  /*aea of rentangle */

perimeter = 2*l+2*b;                                     /*perimeter of rentangle*/

printf(“area of rentangle =%d”,area);

printf(“perimeter of rentangle =%d”,perimeter);

printf(/n/nenter the radius of circle);

area2=3.14*r*r;/*area of circle*/

circum=2*3.14*r;/*circumference of circle*/

printf(“area of circle =%d”,area2);

printf(“circumstance of circle =%d”,circumstance);

getch();

}

Output =

7)Two numbers are input through the keyboard into two locations c and d write a program to interchange thee contents of c and d

#include<stdio.h>

#include<conio.h>

void main();

{

int l,b,r;

clrscr();

printf(“enter the number at location l and b”);

scanf(“%d%d”,&l,&b);

r=b;

b=l;

l=r;

printf(“value of c =%d”,c);

printf(“value of d=%d”,d);

getch();

}

8) Write a program to calculate the sum of its digits in which the entering numbers are input through keyboard.

#include<stdio.h>

#include<conio.h>

void main();

{

int a,b,num,sum;

clrscr();

printf(“enter the numbers ”);

scanf(“%d”,&num);

a=num%10;

n=num/10;

sum=sum+a;

a=num%10;

n=num/10;

sum=sum+a;

a=num%10;

n=num/10;

sum=sum+a;

a=num%10;

n=num/10;

sum=sum+a;

a=num%10;

sum=sum+a;

printf(“the sum of five digits of%d is %d”,num,sum);

getch();

}

9)/*Write a program to reverse the five digit number*/

#include<stdio.h>

#include<cono.h>

void main();

{

int a,b,n;

int revnum;

clrscr();

printf(“enter the numbers ”);

scanf(“%d”,&n);

a=n%10;

n=n/10;

revnum=revnum+10000;

a=n%10;

n=n/10;

revnum=revnum+1000;

a=n%10;

n=n/10;

revnum=revnum+100;

a=num%10;

n=num/10;

revnum=revnum+10;

a=num%10;

revnum=revnum+a;

printf(“the reverse number is %d”,revnum);

getch();

}

For this I used Daniel Berger’s win32-service package. This is a great package that does literally everything for you to enable you to create a nice Windows service. Just install the gem like this:

gem install win32-service

I used examples/daemon_test.rb as the base template to make my Windows Service. This piece of code contains all that is needed to run the code snippet above as a service. In this file you will find a class called Daemon that has a number of methods necessary for running a Windows service. Put in the necessary requires and place your ActiveRecord initialization code at the beginning of the code. Then under service_main, while the status == RUNNING, put in the main processing code, minus the loop. Your code could possibly look something like this (don’t cut and paste this code, just use it as a reference):

require 'rubygems'
require 'logger'
require 'active_record'
require 'c:/myrailsapp/app/models/message' # remember to put in the absolute path here
require "win32/service"
include Win32

ActiveRecord::Base.establish_connection({
:adapter  => "mysql",
:host     => "localhost",
:username => "xxx",
:password => "xxx",
:database => "mydatabase"
})

# I start the service name with an 'A' so that it appears at the top
SERVICE_NAME = "MyProcess Service"
SERVICE_DISPLAYNAME = "MyProcess"

if ARGV[0] == "install"
svc = Service.new
svc.create_service{ |s|
s.service_name = SERVICE_NAME
s.display_name = SERVICE_DISPLAYNAME
s.binary_path_name = 'ruby ' + File.expand_path($0)
s.dependencies = []
}
svc.close
puts "installed"
elsif ARGV[0] == "start"
Service.start(SERVICE_NAME)
# do stuff before starting
puts "Ok, started"
elsif ARGV[0] == "stop"
Service.stop(SERVICE_NAME)
# do stuff before stopping
puts "Ok, stopped"
elsif ARGV[0] == "uninstall" || ARGV[0] == "delete"
begin
Service.stop(SERVICE_NAME)
rescue
end
Service.delete(SERVICE_NAME)
# do stuff before deleting
puts "deleted"
elsif ARGV[0] == "pause"
Service.pause(SERVICE_NAME)
# do stuff before pausing
puts "Ok, paused"
elsif ARGV[0] == "resume"
Service.resume(SERVICE_NAME)
# do stuff before resuming
puts "Ok, resumed"
else

if ENV["HOMEDRIVE"]!=nil
puts "No option provided.  You must provide an option.  Exiting..."
exit
end

## SERVICE BODY START
class Daemon
logger = Logger.new("c:/myprocess.log")

def service_stop
logger.info "Service stopped"
end

def service_pause
logger.info "Service paused"
end

def service_resume
logger.info "Service resumed"
end

def service_init
logger.info "Service initializing"
# some initialization code for your process
end

## worker function
def service_main
begin
while state == RUNNING || state == PAUSED
while state == RUNNING

# --- start processing code
messages = Message.find :all,
:conditions => ['sent = (?)', 0], # check if the message has been sent
:limit => 20 # retrieve and process 20 at a time

# array of threads
threads = []

# iterate through each message
for message in messages do
# start a new thread to process the message
threads < < Thread.new(message) do |message|
# process the message here ...
message.sent = 1
message.save
end

# don't finish until all threads are done
threads.each do |t|
begin
# join the threads when it's done
t.join
rescue RuntimeError => e
# do some rescuing
puts “Failed: #{e.message}”
end
end
end

# — end processing code

end
if state == PAUSED
# if you want do something when the process is paused
end
end
rescue StandardError, Interrupt => e
logger.error “Service error : #{e}”
end
end
end

d = Daemon.new
d.mainloop

end #if

Important to note that you need to put in the absolute path in the require as the service wouldn’t be starting at the Rails app.

Now you can install and start the Windows service (assuming the code is written in a file called ‘message_service.rb’:

c:/>ruby message_service.rb install
c:/>ruby messag_service.rb start

You can also control it from your Windows Services MMC console. What you have now is a Windows service that loops around until there is a message record in your database that is not sent (sent = 0). If there are, it will retrieve up to 20 messages at a go and process them with a thread each (parallelizing the processing to make it faster). Once it is processed, it will indicate the meesage has been sent (sent = 1) and loop again. Now you can happily create messages from your Rails app and stuff them into the database, while your message processor will process them separately.

Related Posts with Thumbnails
Wordpressapi is developer code book.
wordpressapi on Facebook

Who am I?

Sony Kumari founded Wordpressapi in Feb 2010. She started writing since Aug 2006 in wordpress blog. Later on She moved her blog to wordpressapi.com.

Sony Kumari is dubble gradute and earned M.C.A. in Computers. Sony Kumari handled the so many projects in many different technology. She worked on Java, PHP, Ruby on Rails, Javascript, Web services, Social applications, Ad campaigns.

Mahesh is the Author of Wordpressapi, as well as a serial web entrepreneur, sci-fi author, and aspiring world changer. He has been writing for Wordpressapi since Dec 2009. His previous experience includes Photoshop Design, CSS design, Web design and wordpress themes development.

Mahesh is a graduate and earned a B.E. in Electronics. He is having three years of experience in Web design and Wordpress application development.

Rahul is the Author of Wordpressapi, as well as a web designer and photoshop artist. His previous experience includes Photoshop Design, CSS design, Web design and wordpress themes development.

Rahul is a graduate and earned a B.A. in History. He is having Five years of experience in Web design and Wordpress application development.

© 2010 Wordpressapi. All Rights Reserved. Reproduction without explicit permission is prohibited.