Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Thiago Ribeiro thiagovsk

🏠
Working from home
View GitHub Profile
View gist:8fcfb8d80464674f94a3e9edb83aa3a5
vim.diagnostic.config({
virtual_text = false
})
-- Show line diagnostics automatically in hover window
vim.o.updatetime = 250
vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
View concern_with_all.rb
require "active_support/concern"
module M
extend ActiveSupport::Concern
included do
has_many :things
scope :disabled, -> { where(disabled: true) }
after_commit :send_email
validates :email, length: { maximum: 255 }, email: true
View module_class_methods.rb
module Formatter
def self.included base
base.extend ClassMethods
end
module ClassMethods
def class_method
"yahy"
end
end
@thiagovsk
thiagovsk / classes_2.rb
Last active Mar 16, 2022
using inheritance
View classes_2.rb
class Formatter
def formatted_phone(phone)
phone.delete("^0-9")
end
end
class Payment < Formatter
def phone(phone)
formatted_phone(phone)
end
@thiagovsk
thiagovsk / classes.rb
Last active Mar 16, 2022
bad modules example
View classes.rb
class Payment
def formatted_phone(phone)
phone.delete("^0-9")
end
end
class Contact
def formatted_phone(phone)
phone.gsub(/[^0-9]/, '')
end
View semantic-commit-messages.md

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

We couldn’t find that file to show.
@thiagovsk
thiagovsk / rails http status codes
Created Feb 4, 2019 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
View rails http status codes
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@thiagovsk
thiagovsk / Dockerfile
Created Oct 15, 2018
ruby 2.5 with jemalloc
View Dockerfile
ROM buildpack-deps:stretch
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bzip2 \
ca-certificates \
libffi-dev \
libgdbm3 \
libssl-dev \
libyaml-dev \
View produtos.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have column, instead of 2. in line 1.
CÛdigo do Produto Nome do Produto NCM CEST CFOP CSOSN COFINS PIS Origem Unidade PreÁo de Venda
900005253 #CART MASC 19081 CAFE 42023200 00.000.00 5102 101 4 4 2 - Importado UND R$ 34,62
900005219 #CART MASC 19081 PRETO 42023200 00.000.00 5102 101 4 4 2 - Importado UND R$ 34,62
900004953 #CART MASC 19089 CAFE 42023200 00.000.00 5102 101 4 4 2 - Importado UND R$ 64,12
900004919 #CART MASC 19089 PRETO 42023200 00.000.00 5102 101 4 4 2 - Importado UND R$ 64,12
901901553 #CARTEIRA PCOURO CAFE 42023200 00.000.00 5102 101 4 4 2 - Importado UND R$ 37,67
901906753 #CARTEIRA PCOURO CAFE 42023200 00.000.00 5102 101 4 4 2 - Importado UND R$ 50,09
901901519 #CARTEIRA PCOURO PRETO 42023200 00.000.00 5102 101 4 4 2 - Importado UND R$ 37,67
901906719 #CARTEIRA PCOURO PRETO 42023200 00.000.00 5102 101 4 4 2 - Importado UND R$ 50,09
226007001 &amp;BOLSA COURO XCBD60-070-01 42022100 00.000.00 5102 101 4 4 2 - Importado UND R$ 151,34