Skip to content

Instantly share code, notes, and snippets.

@pnegri
pnegri / gist:1925913
Created February 27, 2012 18:08
Developing an Approach to Javascript Spaghetti - First Candidate
Fs = require 'fs'
Path = require 'path'
Async = require 'async'
class Tasks
@do: ( methods ) ->
that_methods = methods
new (
() ->
methods_array = []
@pnegri
pnegri / boiler_model_funcionality.rb
Created April 16, 2012 15:41
Modelo de Lib para ActiveRecord
# Nao esquecer que para cada modulo voce precisa criar um initializer em config/initializers e fazer o require
# Ex:
# config/initializer/act_as_boiler.rb:
# require 'boiler_model_funcionality'
module BoilerModelFuncionality
# Detectar quando eh feito um include e executar o seguinte abaixo...
# Para usar, incluir manualmente no model que quiser a feature
# Ex: include BoilerModelFuncionality
def self.included(base)
@pnegri
pnegri / gist:2634426
Created May 8, 2012 11:48
GTD Workflow in Things
1. Review last two weeks on ical (Catch follow-up tasks, and add them to the inbox).
2. Review the next six weeks on ical (Look for prep tasks/projects, and put them into the inbox).
3. Process email inboxes (a. Process email, adding tasks to inbox; b. File project support documents)
4. Process physical inbox (a. Process physical docs, adding tasks to inbox; b. File project support docs in physical reference system)
5. Process Things inbox (a. Define next actions; b. Apply tags; c. Move tasks to appropriate project/area; d. Create projects as needed)
6. Review Next tasks/projects in each area (a. Adjust, tag, move and delete tasks as needed).
7. Review Projects that aren't assigned to areas (Adjust, tag, move and delete tasks as needed).
8. Review Tasks that aren't assigned to an Area (Adjust, tag, move and delete tasks as needed).
9. Review Someday (Adjust, tag, move and delete tasks as needed)
10. Review items in Scheduled for next few days (Move items to Next, Scheduled as needed).
@pnegri
pnegri / Capfile.rb
Created May 10, 2012 19:14
Capistrano Deploy Recipe for Pure PHP Projects
require 'rubygems'
require 'railsless-deploy'
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
set :application, "PROJECT NAME"
set :repository, "GITHUB REPO URL"
default_run_options[:pty] = true
set :normalize_asset_timestamps, false
@pnegri
pnegri / Gemfile
Created May 28, 2012 14:59
Visão de uma App de Notas com IUGU SDK
gem 'iugusdk'
@pnegri
pnegri / chef-bootstrap.sh
Created June 4, 2012 19:46
Basic Chef Pre-Setup for Server
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install
def self.find_or_create_by_social(auth)
social_account = SocialAccount.where("provider = ? AND social_id = ?", auth["provider"], auth["uid"]).first
update_token = true
unless user = social_account.try(:user)
user = User.new
if auth["extra"]["raw_info"]["email"]
return false if !User.where(:email => auth["extra"]["raw_info"]["email"]).empty?
user.email = auth["extra"]["raw_info"]["email"]
end
# user.skip_confirmation!
@pnegri
pnegri / bootstrap-ubuntu.sh
Created July 8, 2012 09:49
Testing a Ubuntu Bootstrap
sudo apt-get -y update
sudo apt-get -y install gcc g++ build-essential libssl-dev libreadline-gplv2-dev zlib1g-dev linux-headers-generic libsqlite3-dev libxslt-dev libxml2-dev imagemagick libmysqlclient-dev graphicsmagick-libmagick-dev-compat git-core wkhtmltopdf git bison openssl curl zlib1g autoconf
mkdir -p /tmp/bootstrap/ruby && cd /tmp/bootstrap/ruby
sudo wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
tar -xvzf ruby-1.9.2-p290.tar.gz
cd ruby-1.9.2-p290/
sudo ./configure --prefix=/usr/local/ruby && sudo make && sudo make install
sudo sh -c 'echo \'PATH="/usr/local/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"\\' > /etc/environment'
require 'test_helper'
# describe "Feature: Mockup Index" do
# it "must display mockup on index" do
# visit mockup_path
# page.text.must_include "Mockup"
# end
# end
describe "Feature: Search on Google" do
require 'test_helper'
describe "Feature: Search on Google" do
before do
Capybara.run_server = false
Capybara.current_driver = :selenium
Capybara.app_host = 'http://www.google.com/'
end
it "must return results for futebol" do