by http://webgeektutorials.blogspot.com

Thursday, June 16, 2011

View in Ruby

Use the Ruby command ruby script/generate controller Hello:
ruby script/generate controller Hello

Creating an Action
//Edit hello_controller.rb under \app\controllers

class HelloController < ApplicationController
                 def there...............
end
end

//To establish a view template for the hello controller's there action, you can create a file named there.rhtml and store it in the
//\app\views\hello directory.

Ruby: Unit Testing


Unit Testing is a great way to catch errors early in the development process, if you dedicate time to writing appropriate and useful tests. As in other languages, Ruby provides a framework in its standard library for setting up, organizing, and running tests called Test::Unit.
There are other very popular testing frameworks, rspec and cucumber come to mind.
Specifically, Test::Unit provides three basic functionalities:
  1. A way to define basic pass/fail tests.
  2. A way to gather like tests together and run them as a group.
  3. Tools for running single tests or whole groups of tests.
Writing a UNIT TEST 
require 'test/unit'

class Person
attr_accessor :first_name, :last_name, :age

def initialize(first_name, last_name, age)
raise ArgumentError, "Invalid age: #{age}" unless age > 0
@first_name, @last_name, @age = first_name, last_name, age
end

Facebook google : Wanna chat in Hindi?

Here is a small script you can bookmark in your browser. After it Open facebook and then just clicking on the bookmark will enable you typing in Hindi... To disable typing in Hindi just click on bookmark again.

javascript:(t13nb=window.t13nb||function(l){var t=t13nb,d=document,o=d.body,c="createElement",a="appendChild",w="clientWidth",i=d[c]("span"),s=i.style,x=o[a](d[c]("script"));if(o){if(!t.l){t.l=x.id="t13ns";o[a](i).id="t13n";i.innerHTML="Loading transliteration";s.cssText="z-index:99;font-size:18px;background:#FFF1A8;top:0";s.position=d.all?"absolute":"fixed";s.left=((o[w]-i[w])/2)+"px";x.src="http://t13n.googlecode.com/svn/trunk/blet/rt13n.js?l="+l}}else setTimeout(t,500)})('hi');

Ok , here i'm gonna tell you how to add a bookmark in Chrome and Firefox 4 in 3-4 easy steps.

Wednesday, June 8, 2011

How to add +1 button to Wordpress

Google has made adding the +1 button fairly simple, but we wanted to provide self-hosted WordPress.org users with a quick walkthrough of the process of adding and enabling the +1 button to their site and their blog posts. We’re sure that dozens of +1 plugins will be available in the next few days, but in the meantime, this is what you need to do.

Step 1: Add a Line of JavaScript to Your Theme Files


The +1 button tool page lays out what webmasters need to add to their website. For users who have a standard XHTML website (or are using Tumblr), copying and pasting the following java scriptbefore the </body> tag on a website works just fine.
<script type=”text/javascript” src=”http://apis.google.com/js/plusone.js”></script>
Simply Go to the Appearances section in the WordPress dashboard and select “editor.” Then find the footer.php file in your template listing. Scan through the file until you see the area marked </body>, then paste in the JavaScript line.
Hit update and you’re ready for step two!

Step 2: Add a Button to Your Sidebar


After the JavaScript snippet has been added to your website, users can paste the <g:plusone></g:plusone><g:plusone></g:plusone> wherever they want a button to appear. Using the +1 button tool, you can configure the button size and include other advanced options.
Another common use for the +1 button, besides on individual blog posts, will likely be in sidebar widgets on a homepage. This can act as a nice, generic hub for +1 activity.
To add the +1 button to a sidebar in WordPress (assuming your theme supports sidebars), simply go to the Appearances section in the Dashboard and select “Widgets.”
We’ll assume that you want to create a new widget for the +1 button, but other sidebar widgets can also be customized to display the button.

Now Google +1 for Bloggers

The button, will compete with the likes of the already ubiquitous sharing buttons offered by Facebook and Twitter (and more recently Tumblr and LinkedIn) for web page real estate.

Google is taking its +1 feature beyond search results and launching a button that publishers can include on their own websites.
 
As with most other sharing buttons, setting up the +1 button on your website is straightforward. Google has created a simple tool that lets you choose from a number of sizes and styles, and then provides the appropriate JavaScript code that you can cut and paste into your site.