Skip to content

Instantly share code, notes, and snippets.

View andersonleite's full-sized avatar
🎯
Focusing

Anderson Leite andersonleite

🎯
Focusing
View GitHub Profile
class Relatorio
attr_reader :titulo, :texto
attr_accessor :formatter
def initialize(&formatter)
@titulo = 'Relatorio Mensal'
@texto = [ 'Gastos do mês', 'contas, e mais contas.' ]
@formatter = formatter
end
@andersonleite
andersonleite / observer.rb
Created October 25, 2009 15:01
Observer em Ruby
module Subject
def initialize
@observers=[]
end
def add_observer(&observer)
@observers << observer
end
def delete_observer(observer)
@observers.delete(observer)
end
$(document).ready(function() {
/* =Reflection -------------------------------------------------------------------------- */
$("#nav-reflection li").append("<span></span>");
$("#nav-reflection a").hover(function() {
$(this).stop().animate({ marginTop: "-10px" }, 200);
$(this).parent().find("span").stop().animate({ marginTop: "18px", opacity: 0.25 }, 200);
gem install haml sass will_paginate memcache-client rufus-scheduler javan-whenever sinatra mysql2 devise nifty-generators restfulie thinking-sphinx simplecov factory_girl_rails capybara database_cleaner cucumber-rails cucumber spork launchy rspec-rails ZenTest test_notifier autotest-notification --pre
gem install haml sass will_paginate memcache-client rufus-scheduler javan-whenever sinatra mysql2 devise nifty-generators restfulie thinking-sphinx simplecov factory_girl_rails capybara database_cleaner cucumber-rails cucumber spork launchy rspec-rails ZenTest test_notifier autotest-notification hpricot paperclip
@andersonleite
andersonleite / twimages.rb
Created December 28, 2010 17:14
download twitter picture
require 'rubygems'
gem 'twitter'
require 'twitter'
require 'open-uri'
require 'find'
user_name = "anderson_leite"
image_url = Twitter.user(user_name).profile_image_url
require 'omniauth/oauth'
require 'multi_json'
module OmniAuth
module Strategies
#
# Authenticate to orkut via OAuth and retrieve basic user info.
#
# Usage:
#
// Retrofit Interface
@GET("/group/{id}/users")
List<User> groupList(@Path("id") int groupId);
// Chamada ao Endpoint com retorno em JSON
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("https://api.github.com")
.setRequestInterceptor(requestInterceptor)
.build();
@GET("/user/{id}/photo")
Observable<Photo> getUserPhoto(@Path("id") int id);
@andersonleite
andersonleite / House.java
Last active August 29, 2015 14:23
Parcelable
public class House implements Parcelable {
private Integer rooms;
private String color;
protected House(Parcel in) {
rooms = in.readByte() == 0x00 ? null : in.readInt();
color = in.readString();
}
def myVar = {String str, int num -> println "$str : $num" }
//execute closure
myVar('age', 30)
#output: age : 30