For an application that requires communication and interactive communication between the users , chatting is one of the most suitable to make you achieve this aspect . A lot of chatting programs are availiable , alot of chatting sites are availiable , but if you want to make a browser based chatting through your application , this might seem to be a little bit complicated.

The main problem is that , Our traditional browsers pulls the page from the server using requests and the server replies with a response , this model is not applicable to use in a browser based chatting application , as what is supposed to happen when client X send the data to client Y ? Client  X sends the data to the server then the server pushs this data to client Y , In our traditional model the server can’t send the data to the browser without a request from the client , this puts to us limited choices to implement this  , as periodically asking the server for new data which is not efficent and highly costing.

So what is the solution … ? PUSH SERVERS TECHNOLOGY

Push technology, or server push, describes a style of Internet-based communication where the request for a given transaction originates with the publisher or central server. It is contrasted with pull technology, where the request for the transmission of information originates with the receiver or client. A lot of Push Servers have been introduced ..  I looked at most of them the most exceptional one , was the   Flash Media Server But its not free for more than 10 connected users , and simply you can look at its price to know why its not feasible to be used by startups 🙂 …

So as working with Ruby On Rails , I searched for a neat Ruby On Rails solution , this was the result …  Juggernaut Push Server Plugin . This was an excellent solution for me… However let’s take a look at Juggernaut.

Juggernaut is a push server written in Ruby , that can make your application interactively communicate with the server. Juggernaut uses flash objects , javascripts , rails code .

How does Juggernaut work ?

Juggernaut uses a flash object in the browser with a server socket , which makes juggernaut work on almost 90 % of the current browsers , as it only requires flash 8.

Juggernaut Consists of three main parts

  1. in-browser/client side elements
  2. a stand alone push server and
  3. Rails elements to tie everything together.

So this is a simple chat scenario….

  • Browser connects to rails server , recieves the required javascripts , SWFs files   ( Element 1 )
  • The browser creates a flashXML socket with the push server ( used for listening )  ( Element 1 )
  • The Client sends the data using AJAX method to a controller.  ( Element 3 )
  • Rails send the data to the push server using the Juggernaut plugin methods  ( Element 3 )
  • Juggernaut push server broadcasts the data to the channels  ( Element 2 )
  • Clients receive the new data using the flashXML socket and updates the dom elements with Javascript ( Element 1)

Juggernaut has different modes of operation , the data can be sent to a certain channel ( no. of users ) Or to a specific user .

Advantages of Juggernaut

  • Allows a real time connection with a client – Rails can literally push javascript in real time to the client which is then evaluated.
  • Using flash sockets allows us to use different port other than the rails application port , which helps us not to overload the application server with requests which may lead to crash the application , thats why we need a stand alone application server
  • Push server – written in Ruby using EventMachine. EventMachine has a non-blocking IO so scales very well
  • Integrated, as a plugin, into Rails.
  • Subscribers can subscribe to multiple channels, and broadcasters can broadcast to multiple channels.
  • Broadcasts can be made to channels, or to a specific client.
  • Connect/Disconnect triggers.
  • Authentication support.
  • Uses Flash 8 – installed on more than 95% of computers.
  • Supports all the major browsers (uses ExternalInterface): Firefox 1+, IE 6+ and Safari 2+

My friends and I made juggernaut plugin to add a secured chatting sessions to juggernaut using RSA or DES encryption algorithms , I’ll write  a blog post about it soon.

So How can I use juggernaut..

This is a very good tutorial about installing and using Juggernaut in your application , it is quite straight forward in linux , but it has some problems in installation with windows and it solved here

Hope this was helpful

Advertisements

Radiant is a cool tool for managing the contents of a website , however many times you will feel that you need to need to customize things in Radiant , but its hard to do because of the radiant structure  which makes the radiant code not visible directly to you , lack of documentation in creating extensions , but we can overcome by a simple way , which is trying to control the Radiant Page without editing the main Radiant gem Code through some Radiant and Rails Facilities.

I was working in a project where I needed to edit the ( pre-created add page ) view for the admin , to add in certain cases some buttons , links , page parts with new actions to be added . The solution is quite simple…

It is assumed that you have a fair knowledge with Radiant extensions to complete through the steps.

Steps :

1 – Appending code to a written action in the radiant controllers

  • In the activate method in the x_extension.rb file in your extension folder , Open the controller you want to add the functions in , use the rails call back functions ( after_filter , before_filter ) to append the code to the required action

Admin::PageController.class_eval do

after_filter :this_is_a_function  , :only => [:new , :edit ,:update]

private
def
this_is_a_function

# do your code
end

end

2- After adding the back end code we need to put the display to this code in the Radiant page  , we can use the radiant ( admin.page.edit , admin.tabs )  to append objects to specific regions in the page , this is the attributes the admin.page.edit object has , these attributes defines certain regions in the page , where Radiant uses these regions to divide the page . You are able to edit in any of these regions , under any conditions without affecting the existing Radiant gem

@regions={:form=>[“edit_title”, “edit_extended_metadata”, “edit_page_parts”],     :form_bottom=>[“edit_buttons”], :parts_bottom=>[“edit_layout_and_type”, “edit_timestamp”],  :main=>[“edit_header”, “edit_form”, “edit_popups”]}>
(  admin.page.edit ) attributes

Example :

Add a button to the bottom of the form in case the page is having a certain page  type (  Archive , normal , not found …) , Add a select list for the user to choose an element  in the bottom part of the page

  • Just add the following lines  in your activate method in the x_extension.rb file

admin.page.edit.form_bottom << “add_button”

admin.page.edit.parts_bottom << “select”

In these two lines , we tell the radiant to add  partials in the named regions ( form_bottom  , parts_bottom )  to be render , as the regions are arrays of partials and the radiant renders the partials in the regions.

  • The only remaining thing is to create the partials

A.  create folder called admin and inside it add the page ( As we write the partials in the admin namespace )

B.  Add the html code you want in the partials you want , you can add conditions inside the partials to make it rendered in some specific page claasses

3. You can add specific page parts to a certain class of pages by the same way of adding actions to controller , you can use the after_save call back and add some code to add a page parts to the page as follows :

Admin::Page.class_eval do

after_save :add_parts

def_add_parts

if this.class_name == “X”

this.parts << PagePart.new(:name=> “x” , :filter_id => “y” , :page_id=>this.id  )

end

end

end

This will add a part for the class of pages you choose ..

Hope this will be helpful

During my final days as an undergraduate student , our  computational theory professor assigned to us an open project which is  discussing any interesting area for each one  in the computational theory …

It was a hard choice , alot of difficult topics , you may know nothing about each of them  .. just interesting names..

I was studying space complexity classes , when I found a topic seemed to be interesting .. ( Undirected ST connectivity in log-space ) proving that the class L ( log space ) equivalent to the class SL ( symmetric log space ).

Really I didn’t understand anything…Although my project’s buddy mahmoud and I , decided to take this as a challenge. and make it our major project..

Symmetric log space .. What is this .. Expanders WoW ..  Rotational Maps .. ZigZag products.

What the hell is this! .. however, we started working and we found it really interesting..

Let’s talk seriously now..

ST-connectivity known as ( ST-CON ) is one of the most famous problems in space computational complexity .. It is the problem of deciding whether there is a path between node S and node T in a graph . This problem is complete under NL (Non- deterministic logarithmic space complexity ) . So solving this problem in log space complexity is a major riddle .. The result will be proving that L = NL equivalent in time complexity that P = NP .

The Undirected ST-connectivity is the version of ST-connectivity where the graph is undirected. known as

( U-STCON)

Scientists saw (U-STCON) is mainly simpler than the directed version .. It was an area of interest for researchers for more than 2 decades.

(U-STCON ) defines a turning machine , called Symmetric turing machine .. defining the symmetric log space class ( SL )
SL was first defined in 1982 by Lewis and Papadimitriou1, who were looking for a class
in which to place USTCON, which until this time could, at best, be placed only in NL,
despite seeming not to require nondeterminism. They defined the symmetric Turing
machine, used it to define SL. Symmetric Turing  machines are kind of Turing machines
with limited nondeterministic power. Informally Symmetric computations are reversible
in an approximate manner. A symmetric computation is divided into locally
deterministic sub computation ( segments ) between special configuration , where
nondeterminism takes place , such that the only special configuration reached from   a
backward computation is the special configuration started the segment. Thus the
segments are locally deterministic in its forward direction and have limited
nondeterminism in its backward direction . Also if there is a way from special
configuration A1 to special configuration A2 , there must be a way back from A2  to A1.

undirected connectivity was one of the most appealing examples of the  computa tional power of randomness. Whereas every graph (e.g., a planar graph representing a maze)  can be efficiently traversed by a deterministic algorithm, the classical   deterministic algorithms required an extensive use of (extra) memory (i.e., linear in            the size of the graph). On the other hand, it was known that, with high probability, a random walk (of polynomial length) visits all vertices in the corresponding connected component. Thus, the randomized algorithm requires a minimal amount of auxiliary memory (i.e., logarithmic in the size of the graph). Even after more than a decade of focused attension at the issue, a significant gap remained between the space complexity of randomized and deterministic polynomial­time algorithms for this natural and ubiquitous problem. Undirected connectivity became the most famous example where randomized computations seemed more powerful than de­terministic ones.
Omer Reingold presented his recent breakthrough result as­ serting that any graph can be traversed by a deterministic polynomial­time algo­ rithm that only uses a logarithmic amount of auxiliary memory. His algorithm is based on a novel approach that departs from previous attempts, where the latter tried to derandomize the random­walk algorithm. Instead, Reingold’s algorithm traverses a virtual graph, which (being an “expander”) is easy to traverse (in deterministic logarithmic­space), and maps the virtual traversal of the virtual graph to a real
traversal of the actual input graph. The virtual graph is constructed in (logarithmically many iterations, where in each iteration the graph becomes easier to traverse.
Here We will Present the USTCON problem and overview of the efforts done in solving it , and we will present Omer Reingold Deterministic Logarithmic Space Algorithm , Proving That
L = SL

Attached is the rest of the research made about this topic , and and explaining presentation

Here is the  Report Docuement

Here is the  Explaining presentation

Hope this will be helpful