Skip to content

Instantly share code, notes, and snippets.

View roooodcastro's full-sized avatar

Rodrigo Castro roooodcastro

View GitHub Profile
@roooodcastro
roooodcastro / debounce.ino
Last active August 24, 2020 17:29
PIU game controller tutorial
#include <Arduino.h>
#define DEBOUNCE_INTERVAL 40 // This is in milliseconds
#define INPUT_PIN 2
bool buttonPressed;
unsigned long lastChangeTimestamp;
void setup() {
lastChangeTimestamp = 0;
@roooodcastro
roooodcastro / card_helper.html.erb
Created January 10, 2018 18:18
Protótipo de helper de card para Bootstrap 4 em RoR
<%= bs_card do |card| %>
<%= card.header('Título do Card', header: { class: 'bg-primary' },
title: { tag: 'h4', class: 'text-white' }) %>
<%= card.header(header: { class: 'bg-primary' }) do %>
<h4 class="text-white">Título do Card</h4>
<% end %>
<%= card.body do %>
<div>
@roooodcastro
roooodcastro / .bash_aliases
Last active April 6, 2017 17:25
Scripts Ubuntu STI
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias "abrir-rails"="~/.open_tabs.sh"
alias "preparar-deploy"="~/preparar-deploy.sh"
alias gpm='git push origin master'
alias gphlog='git push origin homologacao'
alias gpp='git push origin producao'
alias gphfix='git push origin hotfix'
@roooodcastro
roooodcastro / preserve_on_blur.js
Created March 22, 2017 16:05
Selectize plugin - Select or preserve onBlur
/**
* Plugin: "preserve_on_blur" (selectize.js)
* Copyright (c) 2016 Eric M. Klingensmith
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
@roooodcastro
roooodcastro / oracle.rb
Last active October 6, 2016 20:27
Fixes Arel's pagination issue for Oracle https://github.com/rails/arel/issues/438
if o.limit && o.offset
o = o.dup
limit = o.limit.expr
offset = o.offset
o.offset = nil
offset_bind = nil
collector << "
SELECT * FROM (
SELECT raw_sql_.*, rownum raw_rnum_
@roooodcastro
roooodcastro / validacoes_aa.rb
Created September 19, 2016 20:08
Boolean Oveload
def anosemestre?
!anosemestre.blank? ? true : false
end
def cargahoraria?
!numhorasdisc.blank? ? true : false
end
@roooodcastro
roooodcastro / .bash_aliases
Created July 28, 2016 17:57
Atalhos workspace Ruby on Rails & Git
alias "preparar-deploy"="~/preparar-deploy.sh"
alias gpm='git push origin master'
alias gphlog='git push origin homologacao'
alias gpp='git push origin producao'
alias gphfix='git push origin hotfix'
alias gplm='git pull origin master'
alias gplhlog='git pull origin homologacao'
alias gplp='git pull origin producao'
@roooodcastro
roooodcastro / .open_tabs.sh
Created July 6, 2016 18:33
Workspace setup scripts for Ruby on Rails
#!/bin/sh
type_command() {
xdotool type --delay 50 --clearmodifiers "$1"; xdotool key Return
}
new_tab() {
sleep 0.5
type_command "cd ~/workspace/$1"
sleep 0.5
@roooodcastro
roooodcastro / arvore.txt
Created July 5, 2016 14:26
Árvore derivação exemplo 1 CUP
Sentença analizada corretamente. Sem erro.
└── PROG
├── MAIN
│ ├── class
│ ├── Factorial
│ ├── {
│ ├── public
│ ├── static
│ ├── void
│ ├── main
@roooodcastro
roooodcastro / insertion_sort.c
Created June 2, 2016 23:47
Trabalho 2 APA - Rodrigo Castro Azevedo
#include "sort.h"
void insertionSort(int *vector, int vectorSize) {
int currentNumber, prevNumber, index, subIndex;
// Para cada índice, posicioná-lo corretamente
for (index = 1; index < vectorSize; index++) {
subIndex = index;
currentNumber = vector[subIndex];
prevNumber = vector[subIndex - 1];