Skip to content

Instantly share code, notes, and snippets.

@phstc
phstc / happy_oop.rb
Created October 26, 2010 22:39
Happy OOP examples using Ruby
#These Ruby OOP examples, are based on the Rails 3 presentation by @guilhermecaelum
class Person
#the attribute name is immutable
def initialize(name)
@name = name
end
def name
@name
end
end
@phstc
phstc / ItemQueryRqSoapImpl.java
Created November 17, 2010 19:22
QuickBooks Web Connector QWC implementation in Java
package com.cantero.quickbooks.ws;
import java.util.ArrayList;
import javax.jws.WebService;
/*
* http://developer.intuit.com/qbsdk-current/doc/pdf/qbwc_proguide.pdf
*/
@WebService(endpointInterface = "com.cantero.ws.client.QBWebConnectorSvcSoap")
@phstc
phstc / geokit_monkey_patch.rb
Created November 23, 2010 21:07
Geokit monkey patch to work with rails 3.0.3, ruby 1.9.2p0
#Apply this monkey patch in your application.rb
#See: https://github.com/andre/geokit-gem/issues#issue/7
module Geokit
require 'uri'
module Geocoders
class Geocoder
def self.logger()
if Geokit::Geocoders::logger.nil?
Geokit::Geocoders::logger = Logger.new(STDOUT)
Geokit::Geocoders::logger.level=Logger::DEBUG
public interface Dao {}
public class JpaDao implements Dao {}
public class ProductService {
private Dao dao;
public ProductService(Dao dao){
this.dao = dao;
}
}
@phstc
phstc / isFollowing.js
Created December 17, 2010 00:38
isFollowing Bookmarklet – Who is following who?
javascript:(function(){
/*@author Pablo Cantero - http://pablocantero.com/blog/2010/12/20/isfollowing-bookmarklet-who-is-following-who*/
var isFollowing = function(twitterScreenNameA, twitterScreenNameB){
jQuery.getJSON('http://twitter.com/statuses/followers.json?screen_name=' + twitterScreenNameA + '&callback=?', function(data){
for(var i = 0; i < data.length; i++){
if(data[i].screen_name === twitterScreenNameB.replace('@', '')){
alert(twitterScreenNameB + ' is following ' + twitterScreenNameA);
return;
}
}
@phstc
phstc / pageChangesNotifier.js
Created December 22, 2010 14:36
Use this Bookmarklet to start monitoring a page for changes. When a page change is detected you will receive an alert notifying the changes
javascript:(function(){
/*@author Pablo Cantero - http://pablocantero.com/blog/2010/09/15/javascript-para-notificar-se-o-site-teve-alteracoes*/
var xmlHttp = getXMLHttpObj();
if(xmlHttp == null){
alert('Failed to load XMLHTTP');
return;
}
var actual = getPageContent(xmlHttp, window.location.href);
var intervalId = window.setInterval(function(){
var current = getPageContent(xmlHttp, window.location.href);
/*
@pablocantero
http://pablocantero.com
https://github.com/phstc/jquery-twitter/
*/
(function(){
/*
Customized callback to show an error message on the tweets's lookup
This callback is optional, the default error callback shows an alert(errorMessage)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="https://github.com/phstc/jquery-twitter/raw/master/src/jquery.twitter.js"></script>
<script>
/*
@pablocantero
http://pablocantero.com
require 'rubygems'
require 'rake'
require 'rake/testtask'
require File.expand_path('../lib/mongomapper_id2/version', __FILE__)
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/{functional,unit}/**/*_test.rb'
end
pt-BR:
errors:
messages:
not_found: 'não encontrado'
already_confirmed: 'já foi confirmado'
not_locked: 'não foi bloqueado'
not_saved:
one: '1 erro impediu que %{resource} fosse gravado:'
other: '%{count} erros impediram que %{resource} fosse gravado:'