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 / 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 / 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 / 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=$?
@passalini
passalini / directive.js
Created July 14, 2014 19:51
check passwords with angularjs's directive
.directive('equals', function() {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelController
link: function(scope, elem, attrs, ngModel) {
if(!ngModel) return; // do nothing if no ng-model
// watch own value and re-validate on change
scope.$watch(attrs.ngModel, function() {
validate();
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;