you are here: codestackercodes [RSS] → tag google [RSS]

google-like css 3 button

http://www.zurb.com/playground/google-buttons

button.g-button, a.g-button, input[type=submit].g-button {
padding: 6px 10px;
-webkit-border-radius: 2px 2px;
border: solid 1px rgb(153, 153, 153);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(255, 255, 255)), to(rgb(221, 221, 221)));
color: #333;
text-decoration: none;
cursor: pointer;
display: inline-block;
text-align: center;
text-shadow: 0px 1px 1px rgba(255,255,255,1);
line-height: 1;
}

Google::Translate, A Simple API In Ruby

install:
sudo gem install google_translate

require 'rubygems'
require 'google_translate'

tr = Google::Translate.new

# from English to Spanish

tr.translate :from => "en", :to => "es", :text => "Hello, World!"
 => Hola, Mundo!

[funny] google pagerank code

function getPagerank(url) {
	// start off with a random low PR

	pagerank = randomNumber(0, 3);

	if ( pageHostedOn(url, 'google.com') ) {
		pagerank++;
	}
	else if ( pageHostedOn(url, 'microsoft.com') ) {
		pagerank–;
	}
	
	if ( pageValidates(url) ) {
		pagerank *= .5;
	}
	
	tag_value['b'] = 1;
	tag_value['h2'] = 2;
	tag_value['h1'] = 3;
	tag_value['strong'] = -1; // W3C sux!

	pagerank = calculateTagsPr(tag_value, pagerank);
	
	// Sergey said good news sites have

	// lots of nested tables

	tablesOnPage = getTagCount('table');
	if (tablesOnPage >= 50) {
		pagerank += 2;
	}
	if (pagerank >= 5) {
		pagerank = 4; // helps selling AdWords

	}
	if ( linksFrom('mattcutts.com', url) >= 4 ) {
		// I link to “clean” sites only

		// – Matt, Feb 2006

		pagerank += 2;
	}
	
	pagerank += countBacklinks(url) / 10000;
	blacklist1 = getList('government.cn/censored.txt');
	blacklist2 = getList('c:\larry-page-hatelist.txt');
	
	if ( inArray(blacklist1, url) || inArray(blacklist2, url) ) {
		pagerank = 0;
	}
	
	d = dashesInUrl(url);
	pagerank = (d >= 3) ? pagerank -1 : pagerank + 1;

	if ( inString(url, “how to build a bomb”) ) {
		// added on request. 2004-12-01.

		recipient = “peter@homelandsecurity.gov”;
		subject = “You might wanna check this…”;
		sendMailTo(recipient, subject, url);
		// page might still be relevant

		pagerank++;
	}

	if ( month() == "June" || month() == "October" ) {
		// makes people talk about

		// PR updates, good publicity

		pagerank -= randomNumber(1,3);
	} 

	if ( linkCol(url) == WHITE &&
		pageCol(url) == WHITE ) {
		// spammer!! Googleaxe it!!

		pagerank = 0;
	}

	if (url == “http://www.nytimes.com”) {

		// just testing, pls remove tomorrow

		// – Frank, June 2003

		pagerank = 10;
	}
	return pagerank;
}

Traduz textos usando o google

Traduz palavras/frases/textos usando a API do Google, usei aqui http://github.com/rafaelss/shoes-translator

require 'rest_client'
require 'json'
require 'cgi'

word = CGI.escape("hello world")
response = RestClient.get "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=#{word}&langpair=en%7Cpt"
json = JSON.parse(response)
status = json['responseStatus']
if status == 200
    puts json['responseData']['translatedText']
else
    puts "(#{responseStatus}) erro ao traduzir #{word}"
end
Displaying all 4 Code