Skip to content

Instantly share code, notes, and snippets.

View lmansur's full-sized avatar

Lucas Mansur lmansur

View GitHub Profile
@lmansur
lmansur / .rb
Created November 16, 2016 04:33
### author.rb
class Author < ApplicationRecord
has_many :books
validates :name, presence: true
end
### authors_controllers.rb
@lmansur
lmansur / .rb
Created October 29, 2016 08:24
require 'rails_helper'
describe CsvHandler::TotalRevenue do
describe '#total_revenue' do
before do
@import = CsvHandler::ImportData.new('public', 'purchases.csv')
@import.import
@revenue = CsvHandler::TotalRevenue.new('public', 'purchases.csv')
end
@lmansur
lmansur / .rb
Last active October 28, 2016 00:47
def create
file_importer = FileImporter::FileImporter.new(params[:purchase][:file])
if file_importer.run
redirect_to(import_path(Import.last),
notice: 'Purchases successfully added to database.')
else
redirect_to(new_purchase_path, alert: file_importer.errors_full)
end
end
@lmansur
lmansur / fixes.md
Last active October 26, 2016 09:09
Hello!

Bugs / Not Implemented

Messages

  • Deletar mensagem não impede de acessar o url dela
  • Procurar o user em New Message não funciona

Trades

  • Não permitir valor negativo na hora de trocar Money
  • O valor de Money não faz diferença na trade, não tem nada mostrando.
  • End Trade
    • Tem uma opção blank. Ela não é aceita pelo sistema.
@lmansur
lmansur / .rb
Created October 24, 2016 00:40
def user_params
user = UserFromTempUserSession.new(session[:temp_user])
if session[:temp_user]
params[:user][:uid] = user.uid
params[:user][:provider] = user.provider
params[:user][:remote_avatar_url] = user.remote_avatar_url
params[:user][:platform] = user.platform
end
params[:user]
end
@lmansur
lmansur / .rb
Created October 23, 2016 03:15
Rails.application.routes.draw do
# Root route
root 'static_pages#home'
# Static Pages routes
get '/about', to: 'static_pages#about'
get '/help', to: 'static_pages#help'
get '/contact', to: 'static_pages#contact'
# Users routes
get '/signup', to: 'users#new'
post '/signup', to: 'users#create'

Logs while not able to access router's config page

enp2s0    Link encap:Ethernet  HWaddr #MAC_ADRESS_N1_HIDDEN  
          inet addr:192.168.1.137  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::e87b:5643:7495:47f2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14757 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8761 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
body:after{
content: "beta";
position: fixed;
width: 80px;
height: 25px;
background: #EE8E4A;
top: 7px;
left: -20px;
text-align: center;
font-size: 13px;
(2.1ms) COMMIT
ItemCategory Load (0.2ms) SELECT "item_categories".* FROM "item_categories" WHERE "item_categories"."name" = $1 LIMIT $2 [["name", "Antennas"], ["LIMIT", 1]]
Item Load (0.2ms) SELECT "items".* FROM "items" WHERE "items"."name" = $1 AND "items"."item_category_id" = $2 LIMIT $3 [["name", "Wakeup Ship"], ["item_category_id", 4], ["LIMIT", 1]]
(0.2ms) BEGIN
SQL (0.7ms) INSERT INTO "items" ("item_category_id", "name", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["item_category_id", 4], ["name", "Wakeup Ship"], ["created_at", 2016-09-15 06:26:18 UTC], ["updated_at", 2016-09-15 06:26:18 UTC]]
(3.3ms) COMMIT
(1.9ms) BEGIN
Item Load (0.3ms) SELECT "items".* FROM "items" WHERE "items"."id" = $1 LIMIT $2 [["id", 256], ["LIMIT", 1]]
SQL (0.5ms) UPDATE "items" SET "rarity" = $1, "picture" = $2, "updated_at" = $3 WHERE "items"."id" = $4 [["rarity", "Common"], ["picture", "0e83dbdac91473422296.png"], ["updated_at", 2016-09-15 06:26:18 UTC], ["id", 25
require 'mechanize'
# Adiciona items ao array
def addItem(item, items, category)
image = item.at('img').attr('src')
name = item.at('h2').text.strip
rarity = item.at('.rlg-items-item-rarity').text.strip
items << { name: name, category: category.to_s, rarity: rarity, image: 'https://rocket-league.com'+image }
end