Wednesday, November 14, 2007

Moving to http://dwairi.wordpress.com






This blog is now Moved to wordpress

http://dwairi.wordpress.com/

Follow up!




Regargs,
Osama

Saturday, June 16, 2007

Surface Computing

Hi All,


Surface computing is an amazing technology and is a shift to the age of creativeness; where a table surface being an interactive and multiuser screen.

Dreams being real, and I am sure we gonna see much more in next few coming years.

on the other hand, and as a developer, I wish be one of these technologies' developers.

Google it "surface computing" or see it on youtube, metacafe, there are many

OR Have a look at this http://www.microsoft.com/surface/

Cool! ha?


Tuesday, December 19, 2006

TinyMCE + AJAX

I was working on a web application form where I need to use TinyMCE instead of textarea with AJAX request.
but the value of the textarea does not send the new entered value.
ok, what is the problem?

if you viewed the DOM tree of the tinyMCE you will notice that it's actually an IFrame which make it hard to send the data via AJAX request.

what is solution?
on the form's submit button: I added the following:
onclick="tinyMCE.triggerSave(true,true);"

for more details refer to http://www.crossedconnections.org/w/?p=88



Sunday, October 29, 2006

ruby and YAML

this tutorial walk through processing yaml files with ruby, I will not go explain why, which, or what is yaml4r but I will explain how to load, save, update yaml file using ruby (Yaml4r).

first of all you need to include yaml.rb in your class by adding this: require 'yaml.rb'

In the following we add an array object to yaml file

Step one: loading object from yaml file.
obj = YAML::load(File.open('test.yaml'))

Step two: modifying the object (which is an array) and save it back to the file.
obj << 'anything' File.open('test.yaml', 'w+') { |out| YAML::dump(obj, out) }



A complete code that do so would look like the following: require 'yaml.rb'

obj = YAML::load(File.open('test.yaml'))

if obj
obj << 'anything'
else
obj = ['anything']
end

File.open('test.yaml', 'w+') { |out|
YAML::dump(obj, out)
}

Saturday, October 28, 2006

rails text search

This tutorial shows you how to search your data at your Rails application. we will use an easy, and flixible plugin called ferret.

ready? follow up:
  • install ferret gem:
gem install ferret
  • install ferret plugin:
script/plugin install svn://projects.jkraemer.net/acts_as_ferret/tags/stable/acts_as_ferret
  • at your model add the following line:
act_as_ferret or customize your search to only some fields like this: act_as_ferret :fields => [:name, :firstname, :surename]
  • now your database fields are searchable.
to search your data type: .find_by_contents("osama OR dwairi") and walk through them as array

Monday, August 07, 2006

Nutch 0.8.1 howto

The following tutorial explains how to setup nutch 0.8.1 on a clustered environment.

assumptions
  • Machines Layout:
    • we have two machines:
      1. searchCluster1: plays as namenode and datanode
      2. searchCluster2: plays as datanode.
  • Linux FC5.
  • User: root
  • Filesystem layout:
    • /home/search: nutch home
    • /home/filesystem: nutch Distributed File System Home.
  • enable key-based authentication between namenode and all datanodes. with blank phrase so you got to the other machine with no asking for password.
Requirments
it's supposed that you have the following installed
  • JDK 1.5
  • ANT 1.6.5
Step By Step
follow up :)

  • get teh latest release of nutch from http://lucene.apache.org/nutch
  • export JAVA_HOME, ANT_HOME , and NUTCH_HOME (which is in our case: /home/search) to your path - you know how, right? :)
  • untar nutch at /home/ and rename it "search"
  • Configuration: your configuration file shall look like this
    • conf/nutch-site.conf:
      • override properties at conf/nutch-default.conf to suite you needs; don't forget to set http.agent.name since it's can not be empty.
    • conf/hadoop-site.conf: it will look like the following
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->

<configuration>
<property>
<name>fs.default.name</name>
<value>searchCluster1:9000</value>
<description>
The name of the default file system. Either the literal string
"local" or a host:port for NDFS.
</description>
</property>

<property>
<name>mapred.job.tracker</name>
<value>searchCluster1:9001</value>
<description>
The host and port that the MapReduce job tracker runs at. If
"local", then jobs are run in-process as a single map and
reduce task.
</description>
</property>

<property>
<name>mapred.map.tasks</name>
<value>4</value>
<description>
define mapred.map tasks to be number of slave hosts
</description>
</property>

<property>
<name>mapred.reduce.tasks</name>
<value>4</value>
<description>
define mapred.reduce tasks to be number of slave hosts
</description>
</property>

<property>
<name>dfs.name.dir</name>
<value>/home/filesystem/name</value>
</property>

<property>
<name>dfs.data.dir</name>
<value>/home/filesystem/data</value>
</property>
<property>
<name>mapred.system.dir</name>
<value>/home/filesystem/mapreduce/system</value>
</property>

<property>
<name>mapred.local.dir</name>
<value>/home/filesystem/mapreduce/local</value>
</property>

<property>
<name>dfs.replication</name>
<value>3</value>
</property>

</configuration>

    • conf/hadoop-env.sh: it will look like the following:
export HADOOP_HOME=/home/search
export JAVA_HOME=/home/apps/jdk5
export HADOOP_LOG_DIR=${HADOOP_HOME}/logs
export HADOOP_SLAVES=${HADOOP_HOME}/conf/slaves

    • at conf/slaves add the data node hostnames one host by line.
    • edit conf/crawl-urlfiletrs.txt to suit your needs. all necessary instruction are there
  • create the logs directory: {NUTCH_HOME]$ mkdir logs
  • at NUTCH_HOME type ant
  • when everything works fine copy /home/search and /home/apps from the namenode to all datanodes. with the same directory structure.
  • type: ./bin/start-dfs.sh
  • format your DFS by typing: ./bin/hadoop namenode -format
  • if you got a confimrmation that namenode is formatted then you are ready to start.
  • add root text file to your DFS that nutch start crawling from it. OK. follow:
    • mkdir urls
    • echo http://yoursiteaddress/ > urls/urls.txt
    • ./bin/hadoop dfs -put urls urls
  • restart them all by typing: ./bin/stop-dfs.sh then type: ./bin/start-all.sh
  • watch the logs; if you have no exceptions then everything is Ok.
  • start crawler as a test: ./bin/nutch crawl urls -dir crawled -depth 3 -topN 10
  • when it complete successfully then you can move forward to search.
  • get nutch war file: by typing [NUTCH_HOME]$ ant war
  • move nutch-0.8.1.war to [TOMCAT_HOME]/webapps/
  • rename it to search
  • start tomcat.
  • go to webapps/search/WEB-INF/classes/nutch-site.xml and add the following
<property>
<name>fs.default.name</name>
<value>searchCluster1:9000</value>
<description>
The name of the default file system. Either the literal string
"local" or a host:port for NDFS.
</description>
</property>

<property>
<name>searcher.dir</name>
<value>/user/root/crawled</value>
</property>

  • restart tomcat and go to http://searchCluster1:8080/search/

- Nice dreams ;)

Sunday, March 05, 2006

AJAX Frameworks

* DWR - DWR (Direct Web Remoting) is a way of calling Java code on the server directly from Javascript in the browser. DWR consists of two main parts: JavaScript running in the user's browser to communicate with the server and dynamically update the webpage, and a Java Servlet running on the server that processes requests and sends responses back to the browser. DWR takes a novel approach to AJAX by dynamically generating JavaScript code based Java classes. Thus the web developer can use Java code from JavaScript as if it were local to the web-browser; whereas in reality the Java code runs in the web-server and has full access to web-server resources.
* JSON-RPC-Java - JSON-RPC-Java is a dynamic JSON-RPC implementation in Java. It allows you to transparently call server-side Java code from JavaScript with an included lightweight JSON-RPC JavaScript client. It is designed to run in a Servlet container such as Tomcat and can be used with JBoss and other J2EE Application servers to allow calling of plain Java or EJB methods from within a JavaScript DHTML web application.
* AjaxTags - The AJAX Tag Library is a set of JSP tags that simplify the use of Asynchronous JavaScript and XML (AJAX) technology in JavaServer Pages. This tag library fills that need by not forcing J2EE developers to write the necessary JavaScript to implement an AJAX-capable web form. The tag library provides support for live form updates for the following use cases: autocomplete based on character input to an input field, select box population based on selections made from another field, callout or balloon popups for highlighting content, refreshing form fields, and toggling images and form field states on/off.
* Echo 2 - Echo2 is the next-generation of the Echo Web Framework, a platform for developing web-based applications that approach the capabilities of rich clients. The 2.0 version holds true to the core concepts of Echo while providing dramatic performance, capability, and user-experience enhancements made possible by its new Ajax-based rendering engine.
* AjaxAnywhere - AjaxAnywhere is designed to turn any set of existing JSP components into AJAX-aware components without complex JavaScript coding.
* ActiveMQ Ajax Support - Ajax support in ActiveMQ builds on top of the REST connector for ActiveMQ which allows any web capable device to send or receive messages over JMS. All the Ajax examples are currently using OpenRico.
* Tacos - The Tacos library project provides components and ajax behaviour for the Tapestry java web application framework. Most of the library relies almost exclusively on Dojo.
* WebWork 2.2 Awesome AJAX support built on top of DWR and Dojo. Form validation, tabbed panels, remotable forms, and remote divs. More AJAX components will be coming in subsequent releases.
* Simple Web Framework - The Simple Web Framework (SWF) is an event based framework targeting Struts developers who want to build rich Web applications but do not want to migrate to JSF. The SWF is built upon the same Jakarta commons basis as Struts, but uses a different request processor (front controller.) The SWF event model supports XmlHttpRequest (as well as form/submit) based event posting, similar to VB.NET or JSF, with In place Page Updating (IPU) rather than page reloading.
* Wicket 1.1 rc2 - Dojo, Scriptaculous and Wicket integration. The release consists of an Ajax handler, allowing you to create your own custom Wicket Ajax components based on the Dojo toolkit.
* Taconite - The heart of Taconite is a parser that converts normal (X)HTML code into a series of JavaScript commands that dynamically create the content on the browser. This parser allows you, the developer, to write content in way that is natural -- as (X)HTML. You no longer have to crowd your pages with a slew of document.createElement and document.appendChild commands to dynamically create new content. The Taconite custom parser is implemented as a set of JSP custom tags, which can be used in any Java servlet container, or as a client-side JavaScript library, meaning it can be used in conjunction with virtually any server-side technology.
* SWATO - Server side Java library can be deployed in Servlet 2.3+ compatible containers. Client side JavaScript library is base on Prototype. JSON based marshalling. Spring integration. Includes several reusable components like auto-suggest Textbox, Javascript templates and logging.
* Zimbra - Zimbra is an open source server and client technology for AJAX based messaging and collaboration. The collaboration server is built using Java based technologies. The server features file based message storate, a SQL metadata storage, Lucene based search, clustering, replication, archiving and LDAP support.
* Orbeon Presentation Server (OPS) Version 3.0 - OPS 3.0 features an XForms engine much improved over OPS 2.8's, significant improvements in the Page Flow Controller, and more. The XForms engine is now based on Ajax technologies. This makes the XForms engine much more responsive to user interaction than with OPS 2.8. The new Ajax-based XForms engine, present in OPS 3.0 and forward, is refered to as the Next Generation XForms engine or, in short, as XForms NG.
* JsOrb - JsOrb includes code generators that build on demand JavaScript classes for your POJOs and as proxies to your business logic interfaces. The JavaScript classes have the same methods as your POJOs and business logic interfaces, so your JavaScript code ends up looking surprisingly similar to Java.
* ZK - ZK is an event-driven, XUL-based, AJAX-embedded, all Java framework to enable rich user interfaces for Web applications. With ZK, you represent and manipulate RIA in XUL/HTML components all at the server similar to how you developed desktop apps. ZK includes an AJAX-based event-driven engine to automate interactivity, and a rich set of XUL-based components.
* Rialto - Rialto is a cross browser javascript widgets library. It supports pure javascript development and JSP/taglib development. A JSF integration is planned.

original article