Skip to content

Instantly share code, notes, and snippets.

View altherlex's full-sized avatar

Alther Alves altherlex

View GitHub Profile
@altherlex
altherlex / dataannotation.py
Created April 20, 2024 18:50
Code assesment for Dataannotation: python
# Script for https://app.dataannotation.tech/workers/starter_assessment_complete
# Instructions: https://github.com/altherlex/firekamp/blob/main/app/assets/dataannotation-assessment.png
# File: https://github.com/altherlex/firekamp/blob/main/app/assets/coding_qual_input.txt
def create_staircase(nums):
step = 1
subsets = []
while len(nums) != 0:
if len(nums) >= step:
subsets.append(nums[0:step])
@altherlex
altherlex / benchmark.rb
Created September 16, 2022 21:43
ruby Benchmark
seconds = Benchmark.realtime do
counted_links = {}
links.each { |e| counted_links[e] = links.count(e) if counted_links[e].nil?}
end
seconds
@altherlex
altherlex / tunnel-gateway.ssh
Created July 6, 2022 16:53
Dump mysql via tunnel
# Create tunnel gateway
$ ssh -L 3306:staging-bastion:3306 tunnel@staging-bastion
# Check the port
$ nc -z localhost 3306
# Dump via tunnel
$ mysqldump -P 3306 -ualther -p '9E@EeM#C)(Ip$n%9Cy6EIr}QyD!ZbFd' staging_myhi > staging_myhi.sql -h staging-myhi.csqfg2d4yaps.ca-central-1.rds.amazonaws.co
# - with gzip
@altherlex
altherlex / main.py
Created June 6, 2022 22:43
First step in Python
from datetime import date
nome=input('Qual é o seu nome? ')
print(f"Olá, {nome}! Prazer em te conhecer!")
dia=input('Qual é o dia do seu nascimento? ')
mes=input('Qual o mês? ')
ano=input('E o ano? ')
int_ano = int(ano)
@altherlex
altherlex / docker-main-cmds.md
Last active June 18, 2022 07:28
Docker main commands
# list of all images on your system
$ docker images

# run a command on image busybox
$ docker run busybox echo "hello from busybox"

# shows containers that are currently running
docker ps 
@altherlex
altherlex / code.md
Created May 26, 2022 06:52
Biggest script in one line only

Bigest script in one line

Show me your biggest code done in one line only.

lib['data'].select{|i| i['cover']['src'].nil? and images.find{|img| img[:q] == i['title']+' '+i['author']}}.each_with_index{|v, i| lib['data'].find{|l| l['book_id'] == v['book_id']}['cover'] = get_it.call(images.find{|img| img[:q] == v['title']+' '+v['author']}[:id]) }
@altherlex
altherlex / rails.rb
Created May 9, 2022 17:59
Catching rails/ruby upgrading errors
# module WarningHandlers
# module Rails
# class Deprecation < StandardError; end
# def self.register_deprecation_handler
# ActiveSupport::Notifications.subscribe('deprecation.rails') do |_name, _start, _finish, _id, payload|
# exception = Deprecation.new(payload[:message])
# Bugsnag.notify(exception) do |report|
# report.severity = 'warning'
@altherlex
altherlex / ebbundle
Last active May 4, 2022 22:18
Prepare Rails app for EB deploy
#!/bin/bash -eu
#
# Usage:
# $ cd $app_repo
# $ $infra_repo/myhi/deploy/ebbundle
#
# TODO: if branch == production, store an extra copy of the artifact (with the assets) in S3
# TODO: lifecycle for this
@altherlex
altherlex / .zshrc
Created April 9, 2022 20:57
My .zshrc customs
# ---- My personal env -----
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"
# starts Mysql
[ $(mysql.server status|awk '{ print $1}') != 'SUCCESS!' ] && mysql.server start
alias s='subl'
alias ll='ls -lah'
@altherlex
altherlex / commands
Last active March 22, 2022 23:13
commands
$ git update-index --no-assume-unchanged .gitignore Gemfile Gemfile.lock
$ git update-index --assume-unchanged .gitignore Gemfile Gemfile.lock
$ mysqldump -u username -R oldDbName > oldDbName.sql
$ mysqladmin -u username create newDbName
$ mysql -u username newDbName < oldDbName.sql
# No ruby output during rspec
$ RUBYOPT="-W0" bundle exec rspec spec --exclude-pattern "spec/system/**/*.rb" --force-colour