Skip to content

Instantly share code, notes, and snippets.

View HermesPasser's full-sized avatar

Douglas Lacerda HermesPasser

View GitHub Profile
@HermesPasser
HermesPasser / netlify_deploy.yml
Created April 18, 2023 11:56
An action that deploys a node application to netlify.
name: Deploy
on:
push:
branches:
- main
jobs:
build:
name: Build & Deploy app
runs-on: ubuntu-latest
@HermesPasser
HermesPasser / nuke_pip.py
Created April 11, 2023 13:03
Removes every pip package from the running python installation
import sys
import subprocess
def run_pip(*args):
pip_cli = [sys.executable, '-m', 'pip', *args]
with subprocess.Popen(pip_cli, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as process:
out, err = process.communicate()
return process.returncode, out.decode('utf8').strip(), err.decode('utf8').strip()
@HermesPasser
HermesPasser / difffile.rb
Created August 30, 2022 12:55
inputs to a file or str the difference between the list from file a and b
#!/usr/bin/ruby
lines1 = File.readlines(ARGV[0]).uniq
lines2 = File.readlines(ARGV[1]).uniq
diff = lines1.difference(lines2)
if ARGV.length >= 3
open(ARGV[2], 'w') { |file| diff.each { |d| file << d } }
else
puts diff
end
@HermesPasser
HermesPasser / sqlfmt.rb
Last active August 18, 2022 18:45
Naive SQL formatter for scripts with really long subqueries
def next_char(file)
begin
file.readchar
rescue EOFError
nil
end
end
if ARGV.empty?
puts "No SQL file was given"
@HermesPasser
HermesPasser / mal_fetcher.rb
Last active July 21, 2022 12:48
List all related anime to the animes from an user list that is not in the list itself (myanimelist). Yes, there is an api to make the live easier but that's not fun :)
require 'nokogiri'
require 'net/http'
require 'open-uri'
require 'json'
require 'cgi'
def escape url
# since uri.encode/escape was removed and
# CGI.escape escapes chars that should not
temp = url.split '/'
#! /usr/bin/python3
from pathlib import Path
import sys, os
def print_dir(dir : Path, level : 0):
for sub in dir.iterdir():
if sub.is_dir():
print(' ' * level, sub.name)
print_dir(sub, level + 1)
@HermesPasser
HermesPasser / dragsys.js
Created September 25, 2021 17:14
Drag&drop <p> from a div to another. Heavily based on https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_ondrag_all
document.addEventListener("dragstart", (event) => {
event.dataTransfer.setData("Text", event.target.id)
event.target.style.opacity = "0.4
})
document.addEventListener("dragend", (event) => {
event.target.style.opacity = "1"
})
@HermesPasser
HermesPasser / 1005.py
Last active September 15, 2021 01:26
uri, python 4.2
# -- coding: utf-8 --
v1 = float(input())
v2 = float(input())
r = (v1 * 3.5 + v2 * 7.5) / 11
print("MEDIA = " + "{:.5f}".format(r))
@HermesPasser
HermesPasser / proc.sql
Last active November 10, 2020 16:27
the procedure exercise my professor assign me to do (no functions allowed)
use cdmanhafatec2;
DROP PROCEDURE IF EXISTS proc_main;
DROP PROCEDURE IF EXISTS proc_parity;
DROP PROCEDURE IF EXISTS proc_factorial;
DROP PROCEDURE IF EXISTS proc_is_prime;
DROP PROCEDURE IF EXISTS proc_insert_in_mult_table_of;
delimiter end_proc
@HermesPasser
HermesPasser / auto.py
Last active August 30, 2020 20:34
lab db class 2: semi-automatizando a geração de valores para o sql com python
import csv
from random import randrange as rand
# --- gerador estado usando o cvs de https://github.com/kelvins/Municipios-Brasileiros (salvado como cidade.csv)
# --- que tem o as seguintes colunas: codigo_ibge,nome,latitude,longitude,capital,codigo_uf
c = csv.reader(open('cidade.csv'), delimiter=',')
for l in c:
print("({}, '{}', '{}'),".format(l[0], l[2], l[1]))