Skip to content

Instantly share code, notes, and snippets.

Avatar

Felipe Rodrigues felipero

View GitHub Profile
View array_tools.rb
class ArrayTools
def self.flat_array(array = [])
array.each_with_object([]) do |item, flat_array|
next if item.kind_of? String
flat_array.push *(item.kind_of?(Array) ? flat_array(item) : item)
end
end
end
@felipero
felipero / short-version.rb
Last active Sep 11, 2017
Crafters Behavior For Team Member
View short-version.rb
while true
# ...
faça um comentário no cartão com link para o PR
mova o cartão para a coluna `PR Ready`
while ninguém revisou seu código
notifique
end
while seu PR não foi aprovado
tire_duvidas
while você não está satisfeito com o seu trabalho
View README.markdown

This is a fork of a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

  • Ability to disable autoselect of first matched element.
  • Ability to automatically set the width of the dropdown to that of the text input.
  • Ability to fetch source element via AJAX
  • Ability to have a comma separated list of tags.

For the proper source, and other examples, please see the original gist.

Example showing off all the above features

@felipero
felipero / gist:1084997
Created Jul 15, 2011 — forked from juanplopes/gist:1084911
Sugestão de refactoring
View gist:1084997
# adapter = ConnectionAdapter.new(connection
# request = Request.new(registration, card)
# transaction = request.execute_at!(adapter)
module Integration
class Transaction
def initialize(data)
@data = data
end
@felipero
felipero / transaction.rb
Created Jul 15, 2011
Bad Single Responsibility Principle Example
View transaction.rb
module Integration
class Transaction
def initialize
@connection = Integration::Connection.new
end
def create!(registration, card)
message = xml_builder("requisicao-transacao") do |xml|
xml.numero registration.id
xml.valor registration.training_class.price.to_i * 100
xml.moeda "986"
@felipero
felipero / gist:765578
Created Jan 4, 2011
NHibernate Helper ninja fodastico
View gist:765578
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FluentNHibernate;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Context;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
View gist:343673
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName example.com
# ServerAlias *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
View gist:342700
def self.get_top_picks(domain, type, category, level, page = 1)
results = SearchableListing.category(category.id, level).by_type(type).
domain(domain.id).lookup_page(page).
rating_no_less_than(0).star_rating_no_less_than(3).
lvs_not_null.one_per_user_highest_lvs.with_photos.
top_picks_with_join
ids = results.collect(&:listing_id).uniq
results = Listing.find(ids, :order => ids.to_id_sql_order, :include => :user)
results.reject! { |l| l.get_availability == AdvisorStatus::Status::AWAY || l.user.busy_on_call? }
View gist:341503
def remote_setup
if branch.eql? "master"
checkout = ""
else
checkout = "&& $(git branch | grep -vq #{branch}) && git checkout -f -b #{branch} origin/#{branch}"
end
remote_run "cd #{path} && #{@sudo}git clone --depth 1 #{repository} #{application} && cd #{application} #{checkout}"
install_gems
remote_run "#{@sudo}rake inploy:setup environment=#{environment}"
end
View gist:341343
[master] felipe:/workspaces/wave20/sehabitat$ rake inploy:remote:setup
(in /data/workspaces/wave20/sehabitat)
Inploy => ssh rails@sehabitat.fratech.net 'cd /srv/sehabitat && git clone --depth 1 git@github.com:felipero/sehabitat.git release && cd release && rake inploy:local:setup environment=production'
rails@sehabitat.fratech.net's password:
Initialized empty Git repository in /srv/sehabitat/release/.git/
rake aborted!
Could not find gem 'mysql (>= 0, runtime)' in any of the sources.
/srv/sehabitat/release/Rakefile:4:in `require'
(See full trace by running task with --trace)
(in /srv/sehabitat/release)
You can’t perform that action at this time.