Skip to content

Instantly share code, notes, and snippets.

Pedro Henrique Passalini passalini

Block or report user

Report or block passalini

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@passalini
passalini / pair.md
Last active Dec 13, 2018
Pair programming com Visual Studio Code
View pair.md

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 Dec 19, 2017 — forked from nandooliveira/importacao_em_massa.md
Importação de Alunos em Massa
View importacao_em_massa.md

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 Jul 28, 2017 — forked from nicinabox/lets split build guide.md
This guide covers building a Let's Split v2.
View lets split build guide.md

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

View object_controller.rb
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 Nov 13, 2014
Using gsub with strings and hash
View changin_ending_char.rb
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 Apr 7, 2017
Rspec/Capybara configuration to wait ajax
View wait_for_ajax.rb
# 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 Oct 24, 2014
Milliseconds to timestamp
View to_timestamp.rb
# 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 Aug 29, 2015
Upload files to upl.io through command line
View upload_to_upl_io.sh
# 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 Jul 14, 2014
check passwords with angularjs's directive
View directive.js
.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();
View designer.html
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
You can’t perform that action at this time.