Raramorph is a Ruby 1.9 gem for an intelligent port of Aramorph based on Buckwalter Arabic Morphological Analyzer Version 1.0 , Released By eSpace Technologies.

The first Release of Raramorph full morphological analyzer tools , provided with an executable or a library can be included in the code , with basic developer tools , to be extended in the next version.

Due to algorithmic and data structures optimization in Raramorph , we enhanced the performance of the library reaching an average of 4 – 5 seconds in loading the dictionaries  which was the main bottleneck in the java raramorph reaching to 10-11 seconds and average of 2-3 seconds in parsing meduim sized files and printing the output file.

Installing Raramorph :

gem install raramorph  ( note that raramorph requires Ruby1.9 )

Usage :

for exectuable :

raramorph input_file_name output_file_name  -v -a
  -v verbose mode ( optional )
  -a arabic output ( optional )

In Coding

require ‘raramorph’

For analyzing a file

Raramorph.execute(input_filename, output_filename ,verbose = false, not_arabic = true)

You can use functions like analyze_token , tokenize , segement_word all as static methods in Raramorph class , In the next Release developer tools will be more stable including more features for analysis and finding the morphological solutions , which can be used in searching and mining engines.

Also Raramorph -ferret adapter is to be released soon , for helping in the morphological analysis in search engines.

Raramorph Source Code is avaliable at :

http://github.com/espace/raramorph/tree/master

Raramorph Documentation is availabe here.

SystemVIPC is a Ruby 1.8  module for System V Inter-Process Communication: message queues, semaphores, and shared memory.

eSpace Has released a version from SystemVIPC-0.8 RC1 that is compatible and works fine for Ruby 1.8 and Ruby 1.9

It’s really nice to work with SysVIPC with its simple used APIs , Here I’ll provide a simple tutorial for using SysVIPC Shared Memory.

Downloading and Installing

  • Download SysVIPC  Compatible Release for Ruby 1.8 , Ruby 1.9 at :  http://github.com/espace/sysvipc-0.8-rc1.git
  • Extract the Source , then run : ruby1.9 extconf.rb ( note : run with the ruby version you want ) then :  make install Makefile
  • You will have the sysvipc.so file appearing now
  • In all cases you have to put these lines of code :

require ‘sysvipc.so’

include SystemVIPC

Shared Memroy Example

## Testing Shared Memory

  1. $key = ftok ‘/tmp/shm’ , IPC_CREAT
  2. $sh = SharedMemory.new($key, 33554432, IPC_CREAT | 0660)
  3. $sh.attach
  4. child = open(“|-“,”w+”)
  5. if child.nil?
  6. $sh.write(‘In Shared Memory’)
  7. sleep 2
  8. $sh.write(‘now showing you the world!’)
  9. else
  10. sleep 1
  11. puts $sh.read(100)
  12. sleep 3
  13. puts $sh.read(100)
  14. end

Lines 1 ,  2 , 3  we convert the path name into as SysVIPC key , then we initiate if necessary 8 MegaBytes shared Memory Segment associated with key , then finally we attach the shared memory segment.

lines 4 , 5 we for a child for the process

At lines 6 , 8 we use the SharedMemory method write to write two data items to the shared memory segment

lines 11 , 13 the forked child process reads the data written by the parent process in the shared Memory segment and prints it.

sleep call is used for synchronizing the events..

Hope this is helpful….

View The SystemVIPC documentation at : http://sysvipc.rubyforge.org/

If you are one of the Ruby On Rails developers , and  trying to make a complex has_many relation , you have one option .. the :finder_sql and :count_sql options.

these options allows you to write a custom query for your relation maintaining the remaining association options.

So if you were quering using the instance variables of the object like this ,

:finder_sql => “select * from attendance_items a where a.employee_id = #{id}”

This will give you wrong results , even more if your query was like this

:finder_sql => “select * from attendance_items a, where a.email = #{email}”

where email is an attribute in Employee… you will get a syntax error !!!

Cause : writing variables in the query between double quotes , makes the variable to be expanded once it was parsed , so in the first case the returned  id will be the object id in the memory not the active record id and in the second case , it will find that no attribute is name email as the object was not loaded.

Solution : Simply replace the double quotes with single quotes , this cause rails to skip expanding the variables.

:finder_sql => ‘select * from attendance_items a ‘+
‘where a.employee_id = #{self.hr_id}’

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

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

One of my friends sent me a link a couple of days for a youtube video showing some friends using their cell phones radiations to cook the kernel of popcorn (Video is in the bottom of the post ) , and actually they’ve done it !!!!! But What ? Is this possible?

The answer is no as i read in Wierd Blog;. They interviewed the University of Virginia physics professor Louis Bloomfield and this was his comment.

“[The videos] are cute,” said Bloomfield in a phone conversation . “But that’s never gonna happen.”

In a microwave oven, energy excites the water inside popcorn kernels until it turns into highly pressurized gas, causing the kernels to pop. If mobile phones emitted that much energy, the water in the fingers of people holding them would heat up.

“It would hurt like crazy,” Bloomfield said. “Cellphones probably warm your tissues, but studies indicate that’s not injurious.”

Bloomfield, author of How Everything Works: Making Physics Out of the Ordinary, dismissed theories bubbling up in comment threads about the videos that suggest harmonious vibrations are heating the corn.

“Ringing the phones doesn’t help because they’re interfering with each other and receiving a signal [from a cellphone tower] — not transmitting it,” he said. Furthermore, while it is possible to heat with sound, it’s not likely to happen at the low volume emitted by a mobile phone. “It would be like gathering opera singers together to sing, and trying to make the corn pop,” Bloomfield said.

He also said that the trick in the video they may had put a boiler below the table or stuff like this , but this is still weired …

I guess the guys weren’t doing this just as a trick or fun … May Be its a simple message about how HARMFUL the CELL PHONES  are .. and how we are living in an electromagnetic field of waves …. living with us 🙂

May be some days with the more evolution in radio magnetic waves these side effects disappear .. OR may be cooking popcorn with cell phones will be true for our electromagnetic world we live IN ……

Here is the Video Watch And Enjoy 🙂