Skip to content

Instantly share code, notes, and snippets.

View xdougx's full-sized avatar

Douglas Rossignolli xdougx

View GitHub Profile
@xdougx
xdougx / searching.rb
Last active July 20, 2016 14:47
A intenção era só simplificar e ganhar todos os métodos sem precisar fazer muito, é muito simples fazer em uma classe desprendida do ActiveRecord
module Searchable
included do
scope :gender, ->(gender) { where(:gender => gender) }
scope :birth_on, ->(date) { where(:birthdate =>date) }
scope :birth_before_than, ->(date) { where("#{quoted_table_name}.birthdate < ?", date) }
scope :birth_after_than, ->(date) { where("#{quoted_table_name}.birthdate > ?", date) }
scope :profile, ->(profile){ where(:profile => profile) }
end
module ClassMethods
module Import
class Base
attr_accessor :type, :path, :file, :file_type
def initialize(params)
self.type = params[:type]
self.file = params[:file]
self.file_type = params[:file_type]
self.path = File.join(Rails.root, "public", self.file.original_filename)
end
source 'https://rubygems.org'
gem 'rails', '4.2.5'
gem 'pg'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'bcrypt'
gem 'awesome_print'
gem 'mini_magick'
gem 'exceptions-resource', github: 'xdougx/exceptions-resource', require: 'exceptions'
class ApplicationController < ActionController::Base
layout 'application'
end
class CategoriesController < ApplicationController
# app/views/categories/show.html.erb
def show
@category = Category.find(params[:id])
end
end
# Depende da gem exceptions-resource, só procurar no meu git que você encontra
module Statusable
extend ActiveSupport::Concern
included do
available_statuses.each do |status|
scope status, -> { where(status: status) }
end
end
@xdougx
xdougx / git_cmd.markdown
Last active December 19, 2015 19:49
comandos para o git

GIT

Commitar uma feature

git add . => Adiciona todas as mudanças
git commit -a -m "<mensagem do commit>"
git push origin staging

Sincronizar

var IApp = (function() {
var InterfaceApp = function() {
this.run = function(obj, vars) {
if(obj == null) { obj = this.modules; }
if(vars !== undefined) { this.addGlobals(vars); }
this.callEvents(obj);
};
def search_city(city = "")
until hashcity.include?(city) do
city = gets.chomp
end
end
Error in ./boot.cr:12: instantiating 'Importation::Base#import()'
Importation::Base.new(App.new).import
^~~~~~
in ./app/importation/base.cr:31: instantiating 'Importation::Runner#run()'
Importation::Runner.new(self, path).run
^~~
@xdougx
xdougx / database.yml
Last active October 21, 2015 13:31
build an database connection with PG
development:
encoding: utf8
port: 5432
database: development
username: username
password:
host: localhost
---
test:
encoding: utf8