Skip to content

Instantly share code, notes, and snippets.

View guipdutra's full-sized avatar

Guilherme Dutra guipdutra

View GitHub Profile
@guipdutra
guipdutra / gist:5272679
Last active February 11, 2022 15:41
Installing Phantom JS 1.9.0 on Ubuntu 32bit or 64bit.
For 32-bit system
use phantomjs-1.9.0-linux-i686.tar.bz2
For 64-bit system
use phantomjs-1.9.0-linux-x86_64.tar.bz2
Go to the SHARE directory
cd /usr/local/share
@guipdutra
guipdutra / postgres-cheatsheet.md
Created May 14, 2019 19:34 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
# encoding: utf-8
require 'spec_helper'
describe "Filters", :subdomain => 'city1-st' do
let(:city_hall) { city_halls(:main) }
before do
@mapping = lc116_cnae_mapping()
@cnae = cnae()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link href="/apple-touch-icon.png" rel="apple-touch-icon" />
<link href="/apple-touch-icon-72x72.png" rel="apple-touch-icon" sizes="72x72" />
<link href="/apple-touch-icon-114x114.png" rel="apple-touch-icon" sizes="114x114" />
<link href="/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144" />
<title>atos6.com</title>
<%= stylesheet_link_tag "base", :media => "all" %>
A fortaleza do patriarca
Sua personalidade sempre foi forte
Gostava de ser ouvido e atendido
Às vezes parecia até sisudo demais...
...apesar daqueles olhinhos tão azuis!
Mas isso era pra ter o respeito de todos,
Afinal, assim deve ser um patriarca.
A fortaleza em pessoa.
class CellSupervisionNameFunctionsBusiness
def initialize(options)
@functions = options.fetch(:functions)
end
def save!
functions.each do |function|
if function[:id] == CellSupervisionFunctionItem::NEW
new_function_name(function)
else
require 'spec_helper_lite'
require 'app/business/cell_supervision_name_functions_business'
describe CellSupervisionNameFunctionsBusiness do
let(:function_one) { 1 }
let(:find_result) { double }
let(:functions) {
[
require "spec_helper_active_record"
require 'app/validations/email_template_common_validations'
require 'app/models/email_template'
describe EmailTemplate do
context 'validations' do
before do
stub_const("EmailTemplate::ImageUploader", Class.new)
end
class HomeController < ApplicationController
def index
if current_user and current_user.current_organization
if current_user_is_cells_leader
redirect_to organization_cell_weekly_reports_not_sent_last_week_index_path(current_user.current_organization)
else
redirect_to organization_path(current_user.current_organization)
end
elsif current_user
redirect_to profile_path
class Organizations::CellWeeklyReportsNotSent::CellWeeklyReportsNotSentIndexController < ApplicationController
#método repetido em vários controllers
def current_user_organization_connection
@current_user_organization_connection ||= UserOrganizationConnection.where(:user_id => current_user, :organization_id => params[:organization_id]).first!
end
end
class ApplicationController < ActionController::Base
#caso o métododo repetido for uma permissão, recomendo que extrai para um módulo para ficar mais organizado.
include CellsPermission