Skip to content

Instantly share code, notes, and snippets.

View passalini's full-sized avatar

Pedro Henrique Passalini passalini

  • Campos dos Goytacazes
View GitHub Profile
@passalini
passalini / pair.md
Last active December 13, 2018 11:23
Pair programming com Visual Studio Code

Pair programming com Visual Studio Code:

  • Baixe a ultima versão aqui)
  • Baixe a extensão live share aqui
@passalini
passalini / importacao_em_massa.md
Created December 19, 2017 14:00 — forked from nandooliveira/importacao_em_massa.md
Importação de Alunos em Massa

Existem duas formas de enviar um convite em massa.

1. O convite em massa é feito através de um arquivo .csv que deve conter as informações obedecendo a seguinte sequência:

  • Nome
  • Sobrenome
  • ID do Produto
  • E-mail do aluno

Exemplo:

@passalini
passalini / lets split build guide.md
Last active July 28, 2017 16:17 — forked from nicinabox/lets split build guide.md
This guide covers building a Let's Split v2.

An Overly Verbose Guide to Building a Let's Split Keyboard

This guide covers building a Let's Split v2. Order your parts and read over this guide while you wait.

  • I2C isn't covered in this guide (yet), mostly because I didn't do it for my build.

Helpful references

@passalini
passalini / wait_for_ajax.rb
Last active April 7, 2017 14:08
Rspec/Capybara configuration to wait ajax
# Ajax testing with ruby and capybara
#
# Add this to spec/support
#
# When a link or button starts an ajax request, instead of use Capybara
# click_link, click_button and click_link_or_button methods use click_ajax_link,
# click_ajax_button and click_ajax_link_or_button methods. You can still use
# capybara methods and right after it, call wait_for_ajax method.
#
# This methods will wait until Capybara.default_wait_time for the ajax request
@passalini
passalini / foo.rb
Created November 26, 2013 17:38
Multiple assertions with rspec change
class Foo
attr_reader :bar, :buzz
def initialize
@bar = 1
@buzz = 1
end
def add
@bar += 1
@passalini
passalini / gist:6614466
Last active December 23, 2015 09:29
test chosen (ajax) with capybara
within('.chzn-search') do
find('input').set element_name
end
sleep(1)
within(".chzn-results") do
find('li.active-result').click
end
@passalini
passalini / object_controller.rb
Last active August 29, 2015 14:27
RailsAdmin aasm
def change_state
object = Object.find(params[:object_id])
object.send(params[:event] + '!')
redirect_to params[:redirect_to]
end
@passalini
passalini / changin_ending_char.rb
Created November 13, 2014 18:19
Using gsub with strings and hash
def changing_ending_char(string)
ending_chars = {
'!' => :_dangerous,
'?' => :_question
}
string.gsub(/(?<char>[\?|\!])/, ending_chars)
end
changing_ending_char('asd') # => 'asd'
@passalini
passalini / to_timestamp.rb
Created October 24, 2014 12:43
Milliseconds to timestamp
# based in http://stackoverflow.com/a/10874157
def to_timestamp(x)
y = 60*60*1000
h = x/y
m = (x-(h*y))/(y/60)
s = (x-(h*y)-(m*(y/60)))/1000
mi = x-(h*y)-(m*(y/60))-(s*1000)
string = "#{h.to_s.rjust(2, '0')}:#{m.to_s.rjust(2, '0')}:#{s.to_s.rjust(2, '0')},#{mi.to_s.rjust(3, '0')}"
end
@passalini
passalini / upload_to_upl_io.sh
Last active August 29, 2015 14:04
Upload files to upl.io through command line
# This command receives a file as param, upload it to upl.io and copy the url to the clipboard
#
# install: copy this code to your .bashrc or .zshrc
# dependencies: curl and xclip
# example: $ upload ~/Images/image.png
upload_file() {
echo 'Uploading...'
url=`curl http://upl.io -F file=@$1 -s -f`
curl_response=$?