Skip to content

Instantly share code, notes, and snippets.

View frankyston's full-sized avatar
🎯
Ruby on Rails is Fun

Frankyston Lins frankyston

🎯
Ruby on Rails is Fun
View GitHub Profile
@frankyston
frankyston / app.rb
Last active October 4, 2022 09:56
Apurar os resultado da eleições de 2022 para Presidente
require 'net/http'
require 'json'
require 'cgi'
def delimiter(number)
number.reverse.scan(/.{1,3}/).join(',').reverse
end
while (true) do
uri = URI('https://resultados.tse.jus.br/oficial/ele2022/544/dados-simplificados/br/br-c0001-e000544-r.json')
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@frankyston
frankyston / README.md
Created May 18, 2022 17:36 — forked from hopsoft/README.md
Smart Heroku Review Apps managed by GitHub Actions

Smart Heroku Review Apps managed by GitHub Actions

This gist aims to provide a simple solution for managing Heroku Review Apps with GitHub Actions due to the security incident that continues to disrupt Heroku's GitHub integration.

.github
├── workflows
│   ├── heroku_review_app_create.yml
│   └── heroku_review_app_destroy.yml
@frankyston
frankyston / error.js
Last active March 25, 2022 20:07
Error no foundry mesmo com o lessfog e libwrapper instalado e ativado no mundo.
TypeError: canvas.sight.updateFogExplorationColors is not a function
[Detected 2 packages: lessfog, lib-wrapper]
at setUnexploredForPermitted (lib.js:41:26)
at main.js:107:5
at Function._call (eval at <anonymous> (listeners.js:91:22), <anonymous>:4:14)
at Function.callAll (foundry.js:153:12)
at LightingLayer.refresh (foundry.js:38496:11)
at PerceptionManager._update (foundry.js:36533:47)
at foundry.js:36509:54
_call @ VM8869:7
@frankyston
frankyston / sign-pdf.rb
Created March 1, 2022 13:42 — forked from matiaskorhonen/sign-pdf.rb
Quick and dirty PDF signing in Ruby (using Origami)
#!/usr/bin/env ruby
require "openssl"
require "time"
begin
require "origami"
rescue LoadError
abort "origami not installed: gem install origami"
end
FROM ruby:2.6.4
RUN apt-get update
RUN apt-get update -qq && apt-get install -y git-core zlib1g-dev build-essential libv8-dev libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libsodium-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs postgresql-client
RUN rm -rf /var/cache/apk/*
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
ADD . /usr/src/app
COPY ./.env.local /usr/src/app/
COPY ./.env.test /usr/src/app/
RUN gem install bundler -v 2.2.28

Imaginem esse cenário:

tree
.
├── somefolder
└── app
     └── Dockerfile
@frankyston
frankyston / main.rb
Created December 28, 2021 12:41 — forked from leandronsp/main.rb
How to reduce time complexity of nested loops
require 'faker'
require 'benchmark'
def generate_groups
(1..1_000).map do |id|
{ id: id, name: Faker::Educator.primary_school }
end
end
def generate_users(groups_ids)
1. Escreva um algoritmo que armazene o valor 10 em uma variável A e o valor 20 em uma variável B.
A seguir (utilizando apenas atribuições entre variáveis) troque os seus conteúdos fazendo com que o valor que está em A passe para B e vice-versa. Ao final, escrever os valores que ficaram armazenados nas variáveis.
2. Escreva um algoritmo que receba dois valores nas variáveis a e b e processe as seguintes expressões na variável c:
1. c = a + b
2. c = a - b
3. c = a * b
4. c = a / b
3. Escreva um algoritmo para ler um valor e escrever na tela o seu antecessor e o seu sucessor.
4. Escreva um algoritmo para ler as dimensões de um retângulo (base e altura), calcular e escrever a
área do retângulo.