Thursday, December 28, 2006

ExampleDesignPatternsInRuby (Ruby)

Almost all of these examples are correct Ruby programs. If example output is shown, you should be able to copy code from the web page, run it in a Ruby interpreter and get the documented output.

Patterns

Source:http://wiki.rubygarden.org/Ruby/page/show/ExampleDesignPatternsInRuby

Design Patterns in Ruby : Observer

The key ideas around the Ruby implementation of the Observer pattern are:
  1. Require the observer library
  2. Mixin the Observable module to your class which can be observed
  3. In the class that does the observing, implement the update method

That’s it.

Of course, an example would be nice. Here’s a small one.

require 'observer'  # Key step 1

class MyObservableClass
include Observable # Key step 2

def blah
changed # note that our state has changed
notify_observers( 5 )
end
end

class MyObserverClass
def update(new_data) # Key step 3
puts "The new data is #{new_data}"
end
end

watcher = MyObservableClass.new
watcher.add_observer(MyObserverClass.new)

Now, any time that MyObservableClass#blah is called, the observing classes will get notified. In this example, we aren’t dynamically changing the data (in fact, it always stays constant), but I think you can see that if in fact the data DID change, the observers would all get notified of that change.

Design Patterns in Ruby : Singleton

Singleton pattern in Ruby just simple. Only thing is you need to include singleton module. Lets look at sample ruby program.

require 'singleton'
class MyClass
include Singleton
end

sing Ruby’s powerful Mixin functionality, we bring the singleton code into our class definition. This automatically makes our class’s new method private, and give us an instance method we can use to get our object:

irb(main):005:0> a = MyClass.new
NoMethodError: private method `new' called for MyClass:Class
from (irb):5
irb(main):006:0> a = MyClass.instance
=> #

Wednesday, December 13, 2006

Ajax Stories Using Microsoft ATLAS


Video: Using Microsoft Atlas 01



Video: Using Microsoft Atlas 02





Video: Using Microsoft Atlas 03

Building a Blog with Rails


Video: Building a Blog with Rails

What is Chrome URL ?

You can get XUL files like regular HTTP URL or like HTML files.
URL types can automatically handle mulitple themes and locales.
The basic syntax of a chrome URL is as follows:

chrome:////

The text is the package name, such as messenger or editor. The is either 'content', 'skin' or 'locale' depending on which part you want. 'file.xul' is simply the filename.

Example: chrome://messenger/content/messenger.xul

When you select a chrome URL, Mozilla looks down its list of installed packages and tries to locate the JAR file or directory that matches the package name and part.

The mapping between chrome URLs and JAR files are specified in the manifest files stored in the chrome directory.

If you were to move the file messenger.jar somewhere else and update the manifest file accordingly, Thunderbird will still work since it doesn't rely on its specific installed location. By using chrome URLs we can leave details like this to Mozilla. Similarly, if the user changes their theme, the 'skin' part of the chrome URL translates to a different set of files, yet the XUL and scripts don't need to change.

Here are some more examples. Note how none of the URLs specify which theme or locale is used and none specify a specific directory.

chrome://messenger/content/messenger.xul
chrome://messenger/content/attach.js
chrome://messenger/skin/icons/folder-inbox.png
chrome://messenger/locale/messenger.dtd

Tuesday, December 12, 2006

Why should I upgrade to windows Vista

Last week i bought laptop with all latest configuration. Due to vistas late release i have to satisfy with XP professional SP2. AS far I know XP with SP2 provides lot of security than the latest Vista as it has already been tested for long years. Suppose if i need to upgrade to vista.. My printer will not work... may be some installations will not work.

The only reason looking for Vista is Aero glassy features and security. It requires high quality PC components.

According to Itwire ,Many know that the software cost of upgrading from Windows XP to Windows Vista Business is US$199 but they might not know that the Vista upgrade carries a hardware cost as well, with about US$100 in new or additional PC components required to make the jump to Microsoft's newest operating system, according to research firm iSuppli.

However, Vista allows users the option of disabling the 3D interface, eliminating the need for a new graphics card or a more powerful integrated graphics chip. Whether or not to pay the additional costs required to obtain the 3D functionality is a choice that individual users or companies must make.

why a business user, small or large, have to upgrade to Vista just becuase Windows XP has finally matured? We can't think of a single reason other than the fact is that from January 30, 2007, Microsoft will stop selling Windows XP and eventually we'll be forced to move to Vista - or something else. They wanna capture the market by forcing the users or businesses to get vista


7-day Free trial of Napster!

Friday, December 08, 2006

What is XUL and Its role in Mozilla/Firefox browser

What is XUL and why was it created?

XUL is developed to make firefox/mozilla browser easily and faster.
It follows XML structure and schemantics.
Even MathML or SVG can be inserted within it.

WE can make the following elements:
* Input controls such as textboxes and checkboxes
* Toolbars with buttons or other content
* Menus on a menu bar or pop up menus
* Tabbed dialogs
* Trees for hierarchical or tabular information
* Keyboard shortcuts


The created applications can be used as :
Firefox extension
Standalone XULRunner application
XUL package
Remote XUL application

Before learning XUL u need to know the following:
XML(DOM),
HTML,
CSS,
JavaScript and latest firefox browser

You can use same CSS properties in XUL just like HTML CSS.

THe XUL can be accessed from Browser using Chrome URL.
'chrome://' Your URL -> refers installed packages and extensions.


if you are going to use XUL on a web site, you can just put the XUL file on the web site as you would an HTML file, and then load its URL in a browser. Ensure that your web server is configured to send XUL files with the content type of 'application/vnd.mozilla.xul+xml'. This content type is how Mozilla knows the difference between HTML and XUL.

Mozilla does not use the file extension, unless reading files from the file system, but you should use the .xul extension for all XUL files. You can load XUL files from your own machine by opening them in the browser, or by double-clicking the file in your file manager. Remember that remote XUL will have significant restrictions on what it can do.

Firefox uses different documents types for :HTML, XML and XUL
Naturally, the HTML document is used for HTML documents, the XUL document is used for XUL documents, and the XML document is used for other types of XML documents. Since XUL is also XML, the XUL document is a subtype of the more generic XML document.

To summarize the points made above:

* Mozilla renders both HTML and XUL using the same underlying engine and uses CSS to specify their presentation.
* XUL may be loaded from a remote site, the local file system, or installed as a package and accessed using a chrome URL. This is what browser extensions do.
* Chrome URLs may be used to access installed packages and open them with enhanced privileges.
* HTML, XML and XUL each have a different document type. Some features may be used in any document type whereas some features are specific to one kind of document.

Example of buttons:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
id="findfile-window"
title="Find Files"
orient="horizontal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<button id="find-button" label="Find"/>
<button id="cancel-button" label="Cancel"/>

</window>

Friday, December 01, 2006

Ruby books :

Programming Ruby: A Pragmatic Guide2nd edition.

Making Use of Ruby by Suresh MahadevanWiley; ISBN 0-471-21972-X (2002)

Teach Yourself Ruby in 21 Daysby Mark SlagellSams; ISBN: 0672322528 (March, 2002)

Ruby Developer's Guideby Michael Neumann, Robert Feldt, Lyle JohnsonPublishers Group West; ISBN: 1928994644 (February, 2002)

The Ruby Wayby Hal FultonSams; ISBN: 0672320835 (December, 2001)

Ruby In A Nutshellby Yukihiro MatsumotoO'Reilly & Associates; ISBN: 0596002149 (November, 2001)

Programming Ruby: A Pragmatic Guideby Dave Thomas and Andrew HuntAddison Wesley; ISBN: 0201710897 (2000)(As of Sept 2004, there is a second edition. It is not open- sourced at this time.) Online version(Note that this is a legal first edition.)
Download Errata

What is Ruby?

What is Ruby?
Ruby is a very high level, fully OO programming language. Indeed, Ruby is one of the relatively few pure OO languages. Yet despite its conceptual simplicity, Ruby is still a powerful and practical "industrial strength" development language.

Ruby selectively integrates many good ideas taken from Perl, Python, Smalltalk, Eiffel, ADA, CLU, and LISP. Ruby combines these ideas in a natural, well-coordinated system that embodies the principles of least effort and least surprise to a substantially greater extent than most comparable languages — i.e., you get more bang for your buck, and what you write is more likely to give you what you expected to get. Ruby is thus a relatively easy to learn, easy to read, and easy to maintain language; yet it is very powerful and sophisticated.

In addition to common OO features, Ruby also has threads, singleton methods, mixins, fully integrated closures and iterators, plus proper meta-classes. Ruby has a true mark-and-sweep garbage collector, which makes code more reliable and simplifies writing extensions. In summary, Ruby provides a very powerful and very easy to deploy "standing on the shoulders of giants" OO scaffolding/framework so that you can more quickly and easily build what you want to build, to do what you want to do.

You will find many former (and current) Perl, Python, Java, and C++ users on comp.lang.ruby that can help you get up to speed in Ruby.

Finally, Ruby is an "open source" development programming language.