Posts

Building interactive web pages using AJAX and RJS

When we talk about interactive web applications, AJAX is one of the most important technologies. Rails provides an easy way to use Ajax in your web site through RJS. RJS helps you make and ajax request and have several page elements updated correspondingly. Implementing Ajax requests using RJS is a simple matter of doing the following: Include the requried javascript files. Use the right rails tags to launch an ajax request. Declare that your action in the controller can respond to rjs. Define the rjs response (the changes to the DOM). Any rails application has the javascript files (prototype.js, effects.js, dragdrop.js, controls.js, application.js) by default. All you need to do is to include them in your layout file by adding: Rails provide 'remote' alternatives for its link and form tags link_to_remote vs link_to form_remote_for vs form_for and form_remote_tag vs form_tag. Using the remote alternative will cause the html tags generated to have a new AjaxRequest call; so whe...

Which Programming Lanuguage Are You?

Image
Which Programming Language are You?

Rich Text Editors for Radiant CMS 0.6.7

If you are creating a radiant project that will have content edited by non technical people, you'll probably need a rich text editor to be available in your website. There are several Radiant extensions available for that purpose including TinyMCE , Wym Editor , and FckEditor . Well, TinyMCE is a very nice text editor, but it seems it is not yet compatible with Radiant 0.6.7. I managed to installed it successfully following the installation instructions, I can see it listed among the extensions in the administration area, it is there among the filter when editing the page, but the toolbar simply doesn't show up. FckEditor worked very smoothly with me. the Installation inctructions are simple and direct RAILS_ROOT$ git clone git://github.com/djcp/radiant-fckeditor.git vendor/extensions/fckeditor RAILS_ROOT$ rake radiant:extensions:fckeditor:update Fck Editor started just fine after installation and working very smoothly with the new radiant version. As for Wym Editor , i beli...

Traffic Jam Parking Game

There are many flash games online. I liked this one a lot. The idea is simple, move the cars around and unblock your path home to your caring wife. enjoy it

Advanced Configuration in Firefox 3

Image
Everyone can customize a lot of options in Firefox through the "Tools>Options" or "Edit>Preferences" menus. Well the other way is to make customizations through the advanced configuration interface by typing "about:config" in the address bar. You will see the interesting warning message. well, just be careful while you are about changing values. Here you can make a lot of configurations like: browser.download.manager.closeWhenDone set it to true to automatically close the download window when the download is complete browser.download.dir sets your download directory browser.urlbar.maxRichResults sets the number of suggested URLs that appear when you start typing in the address bar zoom.maxPercent and zoom.minPercent to alter the maximum and minimum limits of zooming You can find some configurations explained at ghacks , eriwen's blog and many other locations online. most configurations are self explanatory though. Using the advanced config...

Downloading Rails Casts

Rails casts is hosting Ruby on Rails video tutorials. It explains a lot of tips for development and how different rails components work. I highly recommend it for rails starters. I wanted to download all the previous episodes, that needed me to open the page of each episode, find the link for the mov file, and click save as. So i created a bash script to visit the links of the episodes and do the job automatically get_rails_casts.sh: #!/bin/bash for ((i=$1;i wget http://railscasts.com/episodes/$i -O- | grep -oi 'http://media.railscasts.com/videos/[a-z_0-9]*.mov' >> links done while read LINE ; do wget "$LINE" ; done Now the script can be used to download any range of episodes. below i'm calling it to download episodes from the episode #1 to episode #115 ./get_rails_casts.sh 1 115

Setting Up RubyOnRails Development Environment on Ubuntu 8.04 Hardy

I started a new fresh installation of Ubuntu 8.04 (Hardy).. i needed to prepare my machine for RubyOnRails development. Below are the steps i need to make: Installing Ruby, Rails, MySQL Install MySQL apt-get install mysql-server mysql-client Install Ruby (1.8.6) and gems apt-get install build-essential ruby irb rdoc ri ruby1.8-dev libzlib-ruby libopenssl-ruby1.8 rubygems libmysql-ruby1.8 Update gem gem update --system rm /usr/bin/gem ln -s /usr/bin/gem1.8 /usr/bin/gem Install Rails & Mongrels gem install rails mongrel mongrel_cluster Installing rails 1.2.5 (needed in my project) gem install rails -v 1.2.5 --include-dependencies Move the mongrel_rails, rails and rake to the /bin directory ln -s /var/lib/gems/1.8/bin/mongrel_rails /bin/ ln -s /var/lib/gems/1.8/bin/rake /bin/ ln -s /var/lib/gems/1.8/bin/rails /bin/ This makes us done with the basic ruby and rails installation. Installing RMagick Rmagick is an image processing library that is needed by some rails projects (including m...

Heads Up With Radiant CMS

Radiant is an open source RubyOnRails based Content Management System, designed for relatively small websites. One of the nice things about radiant is that it the templates themselves are stored in the database like ordinary content, making all interactions with the site once it is deployed through the administration interface. In radiant, a page can be composed of several named parts. Parts of the interface that is shared among several layouts (like navigation bar, footer, header) can be stored in snippents . Using snippets, layouts and page parts helps the site creators to elegantly build and maintain their website. Some features that is beyond a CMS, like having a page that sends emails or a form that stores data somewhere, can be obtained through radiant extensions . let's start a new radiant project: first you need to install the radiant gem gem install radiant --include-dependencies then create a new radiant project specifying the database engine used. radiant --database m...

Introducing BDD with RSpec

Behavior Driven Development (BDD) is an approach for software development combining the advantages of Test Driven Development and Domain Driven Design . It helps the team of the project focus on the exact requirements of the client in a verifiable manner. In TDD, we had acceptance tests that verify the correctness and completeness of the feature once they pass. Those tests are written by the developers at the beginning of an iteration. A weak point though is that those tests were written in a programming language (java, ruby, ..) nothing that the customer can understand. BDD introduces a common vocabulary among all people, that is simple text, something that even the customer can understand and write. RSpec is a ruby framework that helps with the implementation of BDD. It is really an interesting project. RSpec started with what they call now the "spec framework", this framework describes pieces of the application model through by specifying characteristics and actions th...

Posting Messages Using Jaiku API through Ruby console

Jaiku is considered a nice communication method among a group of friends or colleagues in a small company or so. One major strength of jaiku is that it has a lot of notification methods about updates. users can receive notifications through sms, IM or throught jaiku website. I wanted to take a look at jaiku API . so i can use it in any application to send notifications to the rest of my colleagues. the user uses his username and API key to authenticate operations through the API Jaiku provides two interfaces that can be used to read/write jaikus. the XML-RPC and the JSON interface. xmlrpc behaved little strangly always responding with "XML-RPC server accepts POST requests only." even when i'm sending POST requests. i managed to use the json interface though just send a post request to api.jaiku.com/json with the parameters(username, api key, method, message) throught Ruby's irb i can send a note by typing: irb(main)> require 'net/http' irb(main)> da...

Overriding input components in active scaffold

One of the wonderful facts about Rails is that most stuff you need is already created for you, keeping you free to customize as you want. ActiveScaffold is one of the most powerful and widely used plugins in rails projects because it simply provide you with a complete CRUD for your model with minimum coding. The default view of the active scaffold is adequate for some applications, but not the most pretty. so is the input types used for the model attributes. Active Scaffold team helps us by providing and easy way to customize by overriding active scaffold defaults . In my application i had a boolean attribute "admin" in my model "user". that was showed as a drop down list having the values of true & false. Pretty ugly. I used partial form overrides to make it the more logical check box by adding app/views/users/_admin_form_column.rhtml with the following content:         is admin ?            'record[admin]'%> ...

A glimpse of fizo

Sitting there at the tram on my way to work, when i saw fizo.. a 70 years old fizo. Well, it wasn't our own fizo himself. It was an old man who seemed to be like a future image of fizo. He was thin, had a white mustache and mixed (white, gray) mid long hair on the sides of his head, wore black framed glasses and clean tidy outfit, and moreover, his fingure nails looked something close to those of foze. just wondering how would i look like if i was to reach that age..

16 Ways to Keep A Razor- Sharp Focus at Work

I came across this nice post about focusing at work, i'd like to share.. Focus is something of a novelty these days. We’ve got cellphones for texting and calls, IM, Twitter, Email, RSS feeds, Facebook, Myspace… the list goes on and on. If you don’t have ADD before you start working online, it seems it’s almost inevitable thanks to these inputs. If you’re a web worker who uses the Internet for the majority of the day, you’re especially at risk for losing focus. Focus is something that must be fought for. It’s not something that automatically switches on when you want to. You have to make sure your surroundings are perfect for working if you want to be focused. Here’s a few ways I’ve found this to work: Use offline tools . Paper products, pens, and other physical tools are a Godsend for those of us who have a hard time focusing throughout the work day. They’re so simple that we can use them quickly, without having to worry about becoming distracted. Take more breaks . More breaks ...

Prime Numbers Generator

Image
did u know that 34136029 is a prime number?!! well.. that's what i recently realized :) I thought of writing a piece of code for that purpose.. wondering how far i can get. The idea of the code is simple We know that 2 and 3 are prime numbers the code checks every following odd numbers to be prime or not. To verify a prime number, the number divisibility by the prime numbers generated so far is checked. (29 is a prime number.. because it id not divisible by 2, 3, 5, 7, 11, 13, 17, 19 nor 23) We only need to verify divisibility against the numbers smaller than or equal to the root of the number in hand. (We needn't check the divisibility of 33 with 11, as we already must have found out it is divisible by 3).. I did not want to go with the mathematical root evaluation as i am not sure about its load. I used bits handling instead. the root of a number uses at most half of the number of bits that the original number uses. i only made a naive java implementation so far. downloa...

MeOwns

"Expressing yourself through your belongings" This is the main idea of eSpace new product, meowns . It is still currently a beta version. The main part of MeOwns is the widget. you can see that in the right side of the my blog. well.. simply, that's me; owner of those books, that mobile device, that nice FZ3 digital camera and those cats. does that tell u anything about me. well, i guess yes. at least an impression. You can ask me about my experience with this stuff too. We can share ideas, thoughts and wishlists. i can find other FZ3 owners or other cat owners, maybe we can be friends. It is much interesting. i believe the meowns team did a great work here. You currently need to be invited to make your meowns account, so leave me a note with your email if u want to try.

Firebug on Firefox 3.0b4

i had installed the beta firefox 3 . it seems nice.. and less starving for memory so far (the thing i really hated in FF). One issue i had is that most addons aren't yet compatible with the new FireFox. including firebug . As a Web Developer, i cannot imagine being with no FireBug available. Firefox 3 couldn't not find a compatible update. and when u search for the addon manually on mozilla addons . u get the old one that is compatible with FF2. Fortunately. i was able to locate FireBug 1.1 beta that is compatible with FireFox 3. i guess it was not added to the addons list because it is still a beta...

find a website value with dnScoop

I came across dnScoop , an online tool to determine the estimated value of a website depending on several factors. Factors include Domain Age, Page Rank, Inbound Links, Traffic Rank and others. The power of dnScoop is that it interacts with several other domain lookup tools out there. u only need to provide the domain that you are interested in. unlike other website value calculators like websitebroker calculator and glurk that requires u to enter some data (monthly traffic, and Alexa Page Rank,....) according to dnScoop this is the estimated value for some websites www.yahoo.com worth $1,884,000,000 www.google.com worth $1,740,000,000 www.sun.com worth $29,056,000 (22 years old) www.facebook.com worth $263,900,000 www.microsoft.com worth $397,440,000 www.cnn.com worth $29,440,000 www.masrawy.com worth $96,900 (8 years old)

God's Greatest gift...

102 days Ago Allah gave me the greatest gift i ever had... my young Hazem.. i like it when i sit with the 3 month old fellow... talking to him and watching his responses... the best of all.. is that i can see he is totally focused with me in the conversation... his smile is priceless.. i'm really amazed how he made me feel

Using maven with eclipse

As i first started using maven for my projects, I used to add the maven plugin to eclipse. The plugin makes you able to mark a project as "maven enabled". This adds the library maven dependencies to the classpath of the project so the dependency libraries can be visible to your classes. As i moved further, I found a better way dealing with maven projects using eclipse; maven eclipse:clean and eclipse:eclipse goals. the goals enables you to make all the configuration and settings through command line which is more powerful and stable. Actually i now never created a new project inside eclipse. It is better to created it outside using maven. Then through eclipse:eclipse u create eclipse project settings files that is ready to be imported to any running eclipse instance. M2_REPO variable that points to the local maven repository. The pretty thing is that you can add that variable to an eclipse workspace through mvn -Declipse.workspace={workspace-path} eclipse:add-maven-re...

Troy Quotes

"If they ever tell my story, Let them say that i walked with giants. Men rise and fall like the winter wheat, But these names will never die. Let them say i lived in the time of Hector, Tamer of Forces. Let them say i lived in the time of Achiles." Odysseus