Skip to content

Instantly share code, notes, and snippets.

View otaviocorrea's full-sized avatar
🏠
Working from home

Otavio Corrêa otaviocorrea

🏠
Working from home
  • Porto Alegre, Rio Grande do Sul - Brasil
  • 07:36 (UTC -03:00)
  • LinkedIn in/ocps
View GitHub Profile
var warehouseCapacity = [];
var allWoodTotals = [];
var allClayTotals = [];
var allIronTotals = [];
var availableMerchants = [];
var totalMerchants = [];
var farmSpaceUsed = [];
var farmSpaceTotal = [];
var villagesData = [];
var allWoodObjects, allClayObjects, allIronObjects, allVillages;
// Função para verificar se os pop-ups estão bloqueados
function verifyPopupPermission() {
var popupWindow = window.open("", "_blank", "width=1,height=1");
if (!popupWindow || popupWindow.closed || typeof popupWindow.closed == 'undefined') {
alert("Pop-ups estão bloqueados neste navegador.");
} else {
popupWindow.close();
}
}
@otaviocorrea
otaviocorrea / docker_setup.sh
Created December 26, 2022 14:18
Setup to docker on Linux (Tested on Linux Mint)
# instal dependencies
sudo apt update
sudo apt -y install apt-transport-https ca-certificates curl software-properties-common
# import docker key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# add docker repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo "$UBUNTU_CODENAME") stable"
sudo apt update
@otaviocorrea
otaviocorrea / validate_cns.rb
Last active December 5, 2022 22:44
Código Ruby para validação do CNS (Cartão Nacional de Saúde)
def valid_cns?(cns) # CNS is a String
return false unless (cns.match('[1-2]\\d{10}00[0-1]\\d') || cns.match('[7-9]\\d{14}'))
return weighted_sum(cns) % 11 == 0;
end
def weighted_sum(cns)
total = 0
cns.chars.each_with_index { |char, index| total += (char.to_i * (15 - index)) }
total
end
<html>
<head>
<title>Netflix logo in HTML + CSS</title>
<style>
body{
display: flex;
align-items: center;
height: 100vh;
margin: 0;
background: black;
@otaviocorrea
otaviocorrea / print_text.js
Created January 19, 2021 16:19
Function for print lines and spaces of texts with javascript, Svelte, React e etc.
const DoWhiteSpace = (text) => {
const spacesRegexp = /\x20/g, newLineRegexp = /\n/g;
return text.replace(spacesRegexp, ' ').replace(newLineRegexp, '<br>');
};
// no41 (Campo de Armia)
// ********************************************
# [ 122]
MinuteGenerate: 1
MaxNumMob: 1
MinGroup: 0
MaxGroup: 0
Leader: Gremlin
Follower: Gremlin
RouteType: 2
@otaviocorrea
otaviocorrea / fatorial.js
Created May 24, 2020 21:19
Sabendo que o fatorial de um número (representado pelo símbolo !) é determinado pela multiplicação deste número por seus antecessores sucessivamente até se chegar a 1, avalie os exemplos de números fatoriais da figura a seguir e crie uma função em Javascript que, recebendo um número inteiro maior ou igual a zero como parâmetro, retorne o fatoria…
function fatorial(numero){
// Define resultado padrão como null.
let resultado = null;
// Se o número digitado atender aos requisitos, altera a variavel resultado.
if(numero === 0 || numero === 1){
// Número digitado é 0 ou 1
resultado = 1;
}else if(numero >= 0){
// Número digitado atende aos requsitos.
@otaviocorrea
otaviocorrea / .htaccess
Last active May 24, 2020 21:49
Utilizar rotas do Build do React em servidor Apache ou IIS
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
@otaviocorrea
otaviocorrea / render-logic.js
Created January 6, 2020 00:11 — forked from markerikson/render-logic.js
React render function organization
class ParentComponent extends Component {
render() {
// My basic render function structure:
// 1) Extract values from props and state
const {a, b, someBoolean, someList} = this.props;
// 2) Render any dependent items into temporary variables, such as conditional components or lists
const conditionalComponent = someBoolean ? <SomeComponent /> : null;
const listItems = someList.map(item => <ListItem item={item} />);