Skip to content

Instantly share code, notes, and snippets.

View alexandreprates's full-sized avatar
💻

Alexandre Prates alexandreprates

💻
View GitHub Profile
@alexandreprates
alexandreprates / poke
Last active April 4, 2018 14:17
Force touch on docker-machine shared volume when file is changed
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Missing container name parameter"
echo " Using:"
echo " poke <running_container_name>"
exit(1)
fi
CONTAINER_NAME=$1
#!/usr/bin/env sh
echo Checking if the service port is available
until nc -z <service> <port>; do
printf '.'
sleep 5
done
echo Service available starting app
exec $@
@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
@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 / README.md
Last active October 8, 2019 12:55
Base64 Editor Script

Base64 Editor

Dependencies

  • vipe
  • xclip

sudo apt-get -y moreutils xclip

Usage

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 / 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
@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 / 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