Skip to content

Instantly share code, notes, and snippets.

View alexandreprates's full-sized avatar
💻

Alexandre Prates alexandreprates

💻
View GitHub Profile
#!/bin/bash
OUTPUTFILE=.response.json.tmp
function fetch_data() {
echo "$1"
curl -s -H "Authorization: Bearer $(cat .civitai_token)" $1 -o $OUTPUTFILE || rm $OUTPUTFILE
}
function parse() {
cat $OUTPUTFILE | jq -r '.items[] | [ .type, (.modelVersions[0].files[].name | gsub(" "; "-")), .modelVersions[0].files[].downloadUrl] | @csv'
@alexandreprates
alexandreprates / trocadilhos.json
Created December 2, 2022 16:46 — forked from henrycunh/trocadilhos.json
Dataset com trocadilhos/charadas, extraídos do site https://osvigaristas.com.br
[
{
"pergunta" : "Quais heróis se preocupam mais com as poses para fotos do que com salvar o seu planeta?",
"resposta" : "Os TumblrCats"
},{
"pergunta" : "Qual é a profissão do Homem Aranha?",
"resposta" : "Desenvolvedor Web"
},{
"pergunta" : "Qual é o estado dos EUA que te eletrifica?",
"resposta" : "Ohio."
@alexandreprates
alexandreprates / Checklist pré apresentação.md
Last active October 28, 2021 21:42
Checklist pré apresentação

Checklist pré apresentação

  • Ir ao banheiro
  • Garrafa com água para tomar na apresentação
  • Testar audio
  • Testar compartilhamento de tela
  • Testar slides (repassar todos, verificar animações e vídeos)
  • Fechar qualquer outra coisa que não for usar na apresentação
@alexandreprates
alexandreprates / end g-code
Created June 3, 2020 16:11
Cura Tevo Tarantula Pro Settings
M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more
G90 ;absolute positioning
G1 X0 Y0 F3600 ;move extruder out of the way by moving the baseplate to the front for easier access to printed object
M84 ;steppers off
M300 S300 P1000 ;alert beep
M82 ;absolute extrusion mode
@alexandreprates
alexandreprates / euclidean_distance.rb
Last active January 9, 2020 19:00
Euclidean distance between two arrays
# Calculate the euclidean distance between two arrays
# Example:
# euclidean_distance([1,2], [3,4]) #=> 2.8284271247461903
# euclidean_distance([1,2,3], [4,5,6]) #=> 5.196152422706632
def euclidean_distance(vector1, vector2)
Math.sqrt(vector1.zip(vector2).collect { |a,b| (a - b)**2 }.sum)
end
docker stop $(docker ps -q) && docker rm $(docker ps -aq) && docker volume ls --format '{{.Name}}' | grep -v 'database' | xargs docker volume rm
docker stop $(docker ps -q) && docker rm $(docker ps -aq) && docker volume ls --format '{{.Name}}' | grep -v 'database' | xargs docker volume rm
@alexandreprates
alexandreprates / README.md
Last active October 8, 2019 12:55
Base64 Editor Script

Base64 Editor

Dependencies

  • vipe
  • xclip

sudo apt-get -y moreutils xclip

Usage

@alexandreprates
alexandreprates / factory.rb
Created March 6, 2019 10:20
Ruby factory example
class Driver
class << self
def list
@list ||= {}
end
def add_subclass(subclass_name, subclass)
list.store subclass_name, subclass
puts "Added subclass #{subclass_name} -> #{subclass}"
@alexandreprates
alexandreprates / gist:a615f57f98eb44ec619e2ff39478cccf
Created January 17, 2019 20:57
Change Docker default network to 192.168.1.5/24
cat <<EOS > /etc/docker/daemon.json
{
"bip": "192.168.1.5/24",
"fixed-cidr": "192.168.1.5/25",
"fixed-cidr-v6": "2001:db8::/64",
"mtu": 1500
}
EOS
systemctl restart docker