Poetry of Programming

Its about Ruby on Rails – Kiran Soumya

By

Notes on using fb:swf in FaceBook

In facebook groups or discussions… I saw plently of developers struggling to embed fb:swf using FBML.

An example for them to make their life easier :)

<fb:swf swfsrc=”SRC_URL” allowscriptaccess=”all”
bgcolor=”#ECECEC” id=”some_id” wmode=”transparent” SWLIVECONNECT=”true”
flashvars=”serverPath=http://dynamic_url?fbid=<%=uid%>&some_params=blahblah” height=”200″ width=”382″
imgsrc=”img_url_at_beginning” />

The other Common Wiki Notes for this to be noted:

  • Currently, Facebook requires Flash version 9.0.0 for all <fb:swf> tags.
  • Make sure that the flashvars parameter is all lowercase. Some sources of embedded links capitalize the V, which does not work on Facebook.
  • Currently, Facebook wraps the resultant Flash object in a <div> tag, so despite the fact that the embed/object tag is not block-level, consecutive <fb:swf> tags will appear one above the other instead of side-by-side.
  • To verify that your Flash object was loaded from a Facebook page, do the following. For security, this technique does not embed your secret key in your Flash app:
  1. Get all the parameters whose names start with fb_sig_. (Do not include the fb_sig parameter itself.) In Flex use Application.application.parameters to do this.
  2. Strip the fb_sig_ prefix from each, and make sure the keys are lowercase.
  3. Create a string of the form param1=value1param2=value2param3=value3, etc., sorted by the names (not the values) of the parameters. Note: Do not use ampersands between the parameters.
  4. Pass this string to your server, where your secret key is stored.
  5. On your server, append your application secret key to the string that was passed in. The following is returned: param1=value1param2=value2param3=value3myappsecret
  6. On your server, create an MD5 hash of this string.
  7. Return the MD5 hash from your server to your Flash object.
  8. In your Flash object, compare the returned hash with the fb_sig parameter that was passed in. If they are equal, then your Flash object was loaded by Facebook. (Or by someone who stole your secret key.)

While the above technique doesn’t embed your secret in the Flash object, what you’re doing is making a public Web service to sign parameter strings with your secret and then embedding its address in your Flash object. This is just as bad as publishing your secret key (except you do the MD5 computation for any malicious clients). What you want to do is send all the parameters to the Web server (including fb_sig) and have it verify the signature internally and respond with either OK or NOT_OK.

By

Import Tool – ScRUBYt

At first I tried String Wrapper tool using open-uri

Then I understood Tree wrappers tools that the HTML document can look very good in a browser, yet still be seriously malformed (unclosed/misused tags). It is a non-trivial problem to parse such a document into a structured format like XML, since XML parsers can work with well-formed documents only

But HTree and REXML is capable to transform the input into the nicest possible XML from our point of view: a REXML Document. ( REXML is Ruby’s standard XML/XPath processing library).

After preprocessing the page content with HTree, we have to unleash the full power of XPath, which is a very powerful XML document querying language, highly suitable for web extraction.

The powerful web scrapping tools in Ruby are mainly Mechanize and Hpricot. Hpricot is “a Faster HTML Parser for Ruby” out of other Rubyful-soup(HTree + XPath),scrAPI,ARIEL

www::Mechanize has the ability to automatically navigate through Web pages as a result of interaction (filling forms etc.) while keeping cookies, automatically following redirects and simulating everything else what a real user (or the browser in response to that) would do.

Mechanize is powerful lib BUT we cannot perfectly interact with JavaScript websites. That is, it cannot handle more than one redirects through javascript.

Using mechanize, attempts to gmail webscrap to get all mails (feed exists to get new mails only) and orkut scraps extraction could go through until there is no complex javascript to break.

At first tried to do google search and extract reditt articles using almost all libs.

Then Using Xpath and scRUBYt, I am able to extract details from finance.google.com in xml format.

To a certain extent scRUBYt which is combination of Hpricot and Mechanize on steriods, seems starting step to me to get finance.google.com portfolio.

Also,scRUBYt is faster than mechanize.

Program:

require 'rubygems'
require 'scrubyt'

google_data = Scrubyt::Extractor.define do
fetch 'http://finance.google.com'
click_link 'Portfolios'
fill_textfield 'Email', '<a href="mailto:kiransoumi@gmail.com">kiransoumi@gmail.com</a>'
fill_textfield 'Passwd', '----'
submit
fetch 'http://finance.google.com/finance/portfolio?action=view&pid=1'
click_link 'Transactions'
#Construct the wrapper
stockinfo "/html/body/div/div/table/tbody/tr" do
   symbol "/td[1]/a[1]"
   qty "/td[5]"
   price "/td[6]"
end

end

google_data.to_xml.write($stdout, 1)
Scrubyt::ResultDumper.print_statistics(google_data)

OUTPUT:
[MODE] Learning
[ACTION] fetching document: <a href="http://finance.google.com">http://finance.google.com</a>
[ACTION] clicking link: Portfolios
[ACTION] fetched <a href="https://www.google.com/accounts/ServiceLogin?hl=en&service=finance&nui=1&continue=http%3A%2F%2Ffinance.google.com%3A80%2Ffinance%2Fportfolio%3Faction%3Dview">https://www.google.com/accounts/ServiceLogin?hl=en&service=finance&nui=1&continue=http%3A%2F%2Ffinance.google.com%3A80%2Ffinance%2Fportfolio%3Faction%3Dview</a>
[ACTION] typing <a href="mailto:kiransoumi@gmail.com">kiransoumi@gmail.com</a> into the textfield named 'Email'
[ACTION] typing ---- into the textfield named 'Passwd'
[ACTION] submitting form...
[ACTION] fetched <a href="https://www.google.com/accounts/CheckCookie?continue=http%3A%2F%2Ffinance.google.com%3A80%2Ffinance%2Fportfolio%3Faction%3Dview&service=finance&hl=en&chtml=LoginDoneHtml">https://www.google.com/accounts/CheckCookie?continue=http%3A%2F%2Ffinance.google.com%3A80%2Ffinance%2Fportfolio%3Faction%3Dview&service=finance&hl=en&chtml=LoginDoneHtml</a>
[ACTION] fetching document: <a href="http://finance.google.com/finance/portfolio?action=view&pid=1">http://finance.google.com/finance/portfolio?action=view&pid=1</a>
[ACTION] clicking link: Transactions
[ACTION] fetched <a href="http://finance.google.com/finance/portfolio?action=viewt&pid=1">http://finance.google.com/finance/portfolio?action=viewt&pid=1</a>
Extraction finished succesfully!
  <root>
    <stockinfo>
      <symbol>IBM</symbol>
      <qty>22.00</qty>
      <price>22.00</price>
    </stockinfo>
    <stockinfo>
      <symbol>GOOG</symbol>
      <qty>10.00</qty>
      <price>270.00</price>
    </stockinfo>
    <stockinfo>
      <symbol>INFY</symbol>
      <qty>12.00</qty>
      <price>80.00</price>
    </stockinfo>
    <stockinfo>
      <symbol>INTC</symbol>
      <qty>4.00</qty>
      <price>18.00</price>
    </stockinfo>
  </root>

stockinfo extracted 4 instances.
symbol extracted 4 instances.
qty extracted 4 instances.
price extracted 4 instances.

By

Syndication of My MarketSimplified Portfolio Chart

Its Simple…
Just go to Google gadget Directory and search for MarketSimplified Portfolio Chart or
Click here

If you can click on "Add to your Webpage" button there, then you can reach a page where you can first configure your Gadget Settings by entering your MarketSimplified Portfolio User name and country. And then do some colouring and adjustment of the gadget size by dragging the ends.

Finally,Click on Priview Changes button below.  If you are confirmed and happy with your colorful changes, then click on "Get the Code" button just below the page.

Finally paste the code on your Weblog like me…

By

Coming up …! Soon rolling down on your hand…!

Increasing Download Rate per day…! Wow!

What happens when the new version of MarketSimplified Mobile App comes up…???

When was the last time you were confronted with a deluge of unnecessary information screaming for Msf_chart
your attention ?

Market Simplified :

1. World’s first totally user customizable Financial Homepage
2. Specialist Financial Search to give one click response to Financial queries
3. Safeguard your portfolio with a dynamic and perpetual alerts on a range of parameters
4. Carry your portfolio with you ; RSS feeds of your portfolio anytime
5. The stock markets in your hands with the MarketSimplified Mobile

Welcome to the world of Market Simplified! Investing simplified.

For users who use Smart Phones and have GPRS enabled, please lo g in to
www.marketsimplified.com/mobile
to download the latest MSF mobile application available ‘Over The Air’.

Yup..! Its Black…!! …its Berry..!!!

By

My Cubicle…

After a long (sick) break…

So far update as of now is… My cubicle… (I like the way it is …!)
My new Dell Xps laptop on left … Robo on right… My work PC in between…
And I am working on digging out the valuable Diamond app :)

By

Rain, Rain Go Away!

Rain, Rain Go Away ..!
I hate you all the way…

Dont come even some other day…
Rain, Rain Go… away .. !!!

By

Five Hot Technologies for 2007

   1. Ruby on Rails
        Faster, easier Web development (link)

   2. NAND drives
        Bye-bye, HDD?

   3. Ultra-Wideband
        200x personal-area networking

   4. Hosted hardware
        Supercomputing for the masses

   5. Advanced CPU architectures
        Penryn, Fusion and more

Further notes here

By

Day Trader’s Dilemma

by Lawrence Andraschko

from WallStreetPoet.com

Should I sell or should I hold?

If I hold there could be trouble,

But if I sell, the stock could double.

Am I weak or am I bold?

Should I sell or should I hold?

My stock keeps going up.

Better pour myself another cup.

All this coffee makes me jitter,

Have I picked another winner?

Am I weak or am I bold?

Should I sell or should I hold?

This indecision is killing me.

The price is falling and I have to pee.

Do I hold my bladder and my stock,

Or do I sell and use the pot?

Am I weak or am I bold?

Should I sell or should I hold?

The stock goes up and I wait no more,

I sell my shares and hit the floor.

A little profit beats a loss,

How I suffer as my own boss.

Am I weak or am I bold?

Should I sell or should I hold?

Nature keeps calling and I need a plan,

Maybe kitty litter or some sand.

Put it right beneath my desk,

Then I wouldn’t make a mess.

Am I weak or am I bold?

Should I sell or should I hold?

By

CSV in Ruby

To Create CSV file in Rails:

    @models = Model.find(:all, :conditions => ['...'])
    rawdata = StringIO.new
    CSV::Writer.generate(rawdata, ',') do |csv|
      csv << %w(Title Total)
      @models.each do |model|
        csv << [model.title, model.total]
      end
    end

    rawdata.rewind
    send_data(rawdata.read,
      :type => 'text/csv; charset=iso-8859-1; header=present',
      :filename => 'rawdata.csv')

To retrieve, here is the lib…

FasterCSV is intended as a
replacement to Ruby‘s standard CSV library. It was designed to
address concerns users of that library had and it has three primary goals:

  1. Be significantly faster than CSV while remaining a pure Ruby library.

  2. Use a smaller and easier to maintain code base. (FasterCSV is larger now, but
    considerably richer in features. The parsing core remains quite small.)

  3. Improve on the CSV interface.
  4. def retrieve_csv
       csv_file = params[:csv_file]
     
      begin
        Record.transaction do
          fastercsv = FasterCSV.new( csv_file )
          while row = fastercsv.readline
            foo, bar = row
            Record.create!( :foo => foo, :bar => bar )
          end
        end
        redirect_to success_action_path
      rescue
        # do something with the error
        flash[:error] = "CSV import failed"
        redirect_to retrieve_path
      end
    end

By

J2 Y-u-m-m-y points to be noted…

Fallacies of J2ME

The list of fallacies, according to Eric, are:

  1. Java programs “will just work” on J2ME
  2. KVM == J2ME
  3. KVM == CLDC and CVM == CDC
  4. J2ME replaces WAP

Fallacy 1: Java programs “will just work” on J2ME

Realistically, don’t expect to be able to run your existing Java applications unchanged on any J2ME platform. Apart from some technical issues (such as the CLDC 1.0 not supporting floating point), there will usually be two barriers: missing classes and resource problems. Not only do J2ME platforms subset the J2SE core classes, but they add some of their own unique classes as well. But even if you write code that only uses classes common to all the platforms you’re interested in, chances are that you’ll still have some work to do to optimize your application so that is uses less memory and has acceptable performance. Good design and modular programming will help a lot in this area.

This isn’t to say that you can’t reuse any code, just don’t expect to reuse it all.

Fallacy 2: KVM == J2ME

Many people use KVM and J2ME synonomously. They’re different things. The KVM is a Java virtual machine. J2ME is a set of specifications. Not every J2ME platform uses the KVM. The CDC, for example, uses the “classic” VM, not the KVM.

Fallacy 3: KVM == CLDC and CVM == CDC

In a similar vein, others use KVM and CLDC synonomously, or the CVM and CDC synonomously. Again, they’re different. The KVM and CVM are Java virtual machines, the CLDC and CDC are J2ME configurations.

The CLDC has specific requirements for its underlying VM, and the KVM can be configured to be that VM. The KVM in fact forms part of the reference implementation of the CLDC. However, there’s nothing preventing a specific CLDC implementation from substituting its own VM not based on the KVM source code. IBM’s J9 VM, used in recent Palm devices, is one such example. So is Research In Motion’s VM for the BlackBerry handhelds.

Similarly, the CDC has specific requirements for its underlying VM, and the CVM can be configured to be that VM. And yes, it too forms part of the reference implementation of the CDC. But CDC implementations can use their own VM, just like IBM uses its J9 VM in its CDC-based J2ME implementations.

Don’t get all worked up about which VM is used. As long as it passes the compatibility tests and meets the appropriate specifications, it generally doesn’t matter to you, the developer. The only time it matters is when performance is an issue and you’d like to switch to a faster VM. That said, remember that most handheld devices are closed platforms and only the platform vendor can actually install a different VM.

Cookie Caching

BES have the ability to handle cookies on behalf of client applications. In other words, any Set-Cookie headers sent back in HTTP responses can be intercepted by the BES (which is acting as a web proxy server) and stripped out of the response sent back down to the client. The cookie is then automatically inserted into subsequent requests by the client app when its request passes through the BES (again, in its capacity as a proxy server).

This cookie handling feature is not a feature but a bug according to Eric’s opinion. The basic problem is this: if a session cookie is used, there’s no way for the application to signal the BES that the “session” is finished. The normal behavior is for the client to clear session cookies when the session terminates. In a browser, this usually means when the browser is exited. In a J2ME application, the application simply stops sending the cookie in subsequent requests.

But since the BES is handling the cookies for you, when exactly does the “session” end? It doesn’t! So what happens is that you get a stale cookie being appended to your app’s requests.

The best solution? Turn off the BES-level cookie handling and let the application do the cookie handling by itself. All you do is set this property in the configuration file:

application.handler.http.CookieSupport = false

You can also set it directly from the BES management console.

Fallacy 4: J2ME replaces WAP

WAP is a set of technologies for wireless communication. It includes a markup language called WML for writing browser-based applications. You can find out more about these technologies at WirelessDevNet.com.

WAP and J2ME are different things, and each has its place when it comes to application creation and deployment. WAP (or really, WML and WMLScript) lets you build browser-based, thin-client applications optimized for wireless delivery. J2ME lets you build “thicker” client applications with more sophisticated logic and the ability to run in an “offline” mode. It’s really like trying to say: “which is better, a page of HTML or a Java applet?” Both are different, and both have their uses. Hopefully, though, J2ME won’t suffer the same problems that caused applets to fall out of grace so quickly. This is why the standardization process, industry support, and compatible implementations are so important for the success of J2ME.

By

MARCH marches on…

Time marches on and on,

And waits for None.

Happiness marches on and on,

With all the fun arouN(d).

Dreams marches on and on,

With all the trust and confidence Lights ON.

Learning marches on and on,

With all the new breaking technologies… go on!

Life in INXS marches on and on,

With a sweet remembrance of joining date on ….

20th March…!

By

… YY…ZZ…AA…GG…

Vizag Beach From Kailashgiri

Some more Good Pics

 
   

   
    

 

By

Why did the Tower of Babel Fail?

Now the whole earth used only one language, with few words. On the occasion of a migration from the east, men discovered a plain in the land of Shinar, and settled there. Then they said to one another, “Come, let us make bricks, burning them well.” So they used bricks for stone, and bitumen for mortar. Then they said, “Come, let us build ourselves a city with a tower whose top shall reach the heavens (thus making a name for ourselves), so that we may not be scattered all over the earth.” Then the Lord came down to look at the city and tower which human beings had built. The Lord said, “They are just one people, and they all have the same language. If this is what they can do as a beginning, then nothing that they resolve to do will be impossible for them. Come, let us go down, and there make such a babble of their language that they will not understand one another’s speech.” Thus the Lord dispersed them from there all over the earth, so that they had to stop building the city.

The Tower of Babel project failed because of lack of communication and of its consequent, organization.

“Schedule disaster, functional misfit, and system bugs all arise because the left hand doesn’t know what the right hand is doing.” Teams drift apart in assumptions.
Teams should communicate with one another in as many ways as possible: informally, by regular project meetings with technical briefings, and via a shared formal project workbook. [Or by electronic mail.]

By

History of Ruby on Rails

Many web-based software systems contain a number of common types of components and functionality.
Calling application code based on HTTP posts, performing database transactions, rendering HTML
responses, and putting all of the system’s functionality into a scalable, extensible architecture are all common concerns in these applications. Because of the prevalence of web applications in today’s world, these problems are faced by many developers worldwide on a daily basis. Clearly, when facing such a task, a prudent software engineer would seek a common framework for web application development that could reduce the need to reinvent existing solutions, create a common base architecture for a number of different applications, and provide a ready-to-go solution for as many of the requirements as possible.

This solution to the problem is not a new one. Frameworks like Microsoft’s .NET or Sun’s Java 2
Enterprise Edition (J2EE) are widely used to satisfy the needs of developers creating large scale service
oriented architectures for web deployment. These systems have been tried and tested many times and are well known for the robust solutions they can provide. Unfortunately, with such a robust architecture seems to come an inherently large amount of overhead in terms of configuration and setup. In addition, there tends to be a large learning curve to understand the architecture and all of its variants. In particular, J2EE has many different technologies that can be glued together within it, including Struts, Hibernate, and Spring.

Enter Ruby on Rails. Ruby on Rails is an open-source web application framework designed to make the
job of the developer easier by providing everything one needs to create web-based, database-driven
applications easily while focusing on the idea, not the technology behind implementing the idea. It is
designed to be a marriage of the “quick-n-dirty” camp of PHP web developers and the “slow-n-clean”
methodologies of the old enterprise architecture crowd. Many proponents of the framework will be quick to tout quotes saying that it can make developing web systems ten times faster than performing similar tasks with competing, more complex frameworks like J2EE.

Rails was developed while its creators were building a real life system with it. This allowed them to test
out their ideas as they were putting them in to production, along with allowing them to drive the
development of the framework based on the actual needs of a real project.

The creator of Ruby on Rails, David Heinemeier Hansson of 37signals, will tell you that some of the
framework’s power comes from the fact that it follows the mantra of “convention over configuration.”
This means that instead of allowing an ultimate amount of flexibility in what a developer can do with a system, there are limits imposed. While this may sound like a bad thing, it actually allows for a much
easier time in creating the types of solutions that it is specifically designed for. In David’s words, “If you
are happy to work along the golden path that I’ve embedded in Rails, you gain an immense reward in
terms of productivity that allows you to do more, sooner, and better at the application level.” Basically,
because assumptions are made on the part of the framework about how the developer will be doing things, the developer doesn’t have to tell the framework how those things will be done. This means less time spent writing configuration files and more time working on the idea of the product.

A high-level view of the Rails architecture makes it look very much like other web application
frameworks. Its architecture is based on MVC, designed to separate concerns and reduce the coupling
between disparate functionality. Part of Rails’ power comes from the fact that this architecture is
connected through an auto-generated code base structure. The developer can set up a project and then
make changes to the model directly and observe the results without a lot of work to set up every part of
getting that data propagated throughout the rest of the system.

The entire benefit of using Ruby on Rails is in many of the small things it does to benefit the developer in
ways that other similar frameworks do not. These little things collectively work together to create a
development experience which overall seems much more agile and less cumbersome than the process
involved in working with other large and robust web development architectures.

In mid-2003, a small web development firm called 37signals was starting development on Basecamp, a
web-based project management tool. For several years, they had been using PHP for their applications
and trying to build up a reusable framework.
Unfortunately, their PHP framework failed to provide maximum productivity, and the programmers were
growing increasingly frustrated with their development experiences. PHP offered a quick and dirty approach to web applications, but 37signals was rapidly pushing the limits of what PHP reasonably
accomplish. On the other end of the spectrum, J2EE offered a slow and clean approach. The approach
was too slow, however, and unreasonably complex. In order to combine the best of both worlds into a
quick and clean approach, a new framework was needed. This framework would facilitate rapid
development with a focus on producing results, while also incorporating design patterns and best
practices.

Basecamp would be 37signals’ first product offering, and the project marked their transition from
consulting to product development. It was clear that if the company wanted to deliver an effective
product line without significantly expanding their resources, they would need a software platform to build on.

As a result, two primary goals emerged. First, 37signals needed an extensible, modifiable web
application framework that could be used to create Basecamp and future products. The framework would
promote code reuse and provide libraries of common functionality. Second, the framework itself needed
to make development enjoyable for the programmers, making the programmers extremely productive.
With increased productivity, 37signals could accomplish more work without hiring more developers.

To achieve the second goal and provide a starting point, Ruby was chosen as the programming language
for the web framework. The dynamic, powerfully expressive nature of Ruby along with its extensive
metaprogramming features ensured an enjoyable, fruitful development experience with plenty of
flexibility. By designing the framework to take advantage of Ruby’s unique traits, a clean productive
development was guaranteed.

Since Ruby was selected and established as a foundation, David could then address his first goal of
creating an extensible web framework. However, he did not build the framework upfront. Instead, he
proceeded to build Basecamp, and the framework that grew out of Basecamp became Ruby on Rails.
Unlike web frameworks like J2EE and .NET, which were developed to specifications designed to suit the
needs of all possible users, Ruby on Rails was extracted from a complete product. As a result, the
framework reflects the real needs of a real project, and contains no extraneous or unnecessary features for the average developer. Thus, when developing a future 37signals product, David could reuse Rails,
without being hindered by unnecessary components, and spend most of his time focusing on application
specific functionality.

Despite the fact that Rails began as a proprietary framework, a decision was made to avoid including
business logic and application-specific features. Originally, the scope was constrained simply to make the framework manageable and to guard against feature creep. When Rails was publicly released as open source, the lack of business logic left the framework as a powerful, general solution that the majority of programmers could reuse.

From its inception, the Rails framework has been driven by pragmatic, minimalist decisions. It uses
proven techniques from real-world applications, meaning that the framework is a reflection of the way
programmers actually work.

By

Best Article in November,2006!

Today I happened to visit a good article, David H. Hansson on the Future of Rails, where the InfoQ editor asks David about the future of rails in enterprises, the scalability and comparision of Java with Rails.

His interview teaches every developer how to really proceed to a project. Implement all ideas without really worrying about performance/scalability. This is like “Concentrate on Application but not bugs at first!” Then sort out pointing exactly where is the bottleneck? Then get that solved… coz every problem has solution.(Nothing is impossible)