Skip to content

Instantly share code, notes, and snippets.

View vinibaggio's full-sized avatar

Vinicius Baggio Fuentes vinibaggio

View GitHub Profile
// OO-ish
function Car(manufacturer, model) {
this.manufacturer = manufacturer;
this.model = model;
}
var porsche = new Car('Porsche', 'Carrera');
var ferrari = new Car('Ferrari', 'Enzo');
@vinibaggio
vinibaggio / blobsizecomparator.java
Created April 17, 2011 20:05
Código processing do básico
import hypermedia.video.Blob;
import java.awt.Rectangle;
public class BlobSizeComparator implements java.util.Comparator<Blob> {
public int compare(Blob a, Blob b) {
Rectangle boundingA = a.rectangle;
Rectangle boundingB = b.rectangle;
double areaA = boundingA.getHeight() * boundingA.getWidth();
double areaB = boundingB.getHeight() * boundingB.getWidth();
@vinibaggio
vinibaggio / gist:921055
Created April 15, 2011 03:06
hack malandro
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
@vinibaggio
vinibaggio / gist:902906
Created April 5, 2011 02:22
Fixture weird behavior
# fixtures/organizations.yml
my_organization:
name: My Organization
subdomain: myorganization
# spec
organization = organizations(:my_organization)
Factory(:site, :organization => organization)
#
Module.class_eval do
def redefine_instance_method(name, &block)
old_instance_method = instance_method(name)
define_method(name) do
block.call(self, old_instance_method)
end
end
def redefine_class_method(name, &block)
old_method = method(name)
# coding: utf-8
FB_APP_ID = 'insert_me'
FB_APP_SECRET = 'insert_me'
class AuthApp < Sinatra::Base
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :facebook, FB_APP_ID, FB_APP_SECRET
@vinibaggio
vinibaggio / call4paperz api
Created March 2, 2011 01:24
Api do call 4 paperz
# Index
http://www.call4paperz.com/events.json
# Show do evento
http://www.call4paperz.com/events/1.json
# Show da proposta
http://www.call4paperz.com/events/1/proposals/1.json
# Evento com JSONP (preste atenção no p no formato)
@vinibaggio
vinibaggio / optimalperf.rb
Created January 22, 2011 03:01
A few changes over igrigorik's autoperf to support a few more things
#--
# Copyright (C)2008 Ilya Grigorik
# You can redistribute this under the terms of the Ruby license
#
# Modifications by Vinicius B. Fuentes
#++
require 'rubygems'
require 'optparse'
require 'ruport'
@vinibaggio
vinibaggio / gist:705464
Created November 18, 2010 19:29
Recursos do vim que vem com MacVim
Huge version with MacVim GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv -cscope +cursorbind +cursorshape +dialog_con_gui +diff
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi
+file_in_path +find_in_path +float +folding -footer +fork() +fullscreen
-gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap
+libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession
+modify_fname +mouse +mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm
+mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme
def sign_in_with(user = Factory(:user))
visit '/users/sign_in'
fill_in "Email", :with => user.email
fill_in "Password", :with => user.password
click_button 'Sign in'
end