Skip to content

Instantly share code, notes, and snippets.

View EduardoOliveira's full-sized avatar
💭
MMP'ing

Eduardo Oliveira EduardoOliveira

💭
MMP'ing
View GitHub Profile
func getImageAspectRatio(height, width int) string {
var distance float64
var ratio string
r := float64(width) / float64(height)
distance = math.Abs(r - (16.0 / 9.0))
ratio = "16by9"
if r == 1.0 {
ratio = "1by1"
return ratio
@EduardoOliveira
EduardoOliveira / macros.cfg
Created February 3, 2022 09:32
klipper screen over wifi
Download XServer XSDL for android https://m.apkpure.com/xserver-xsdl/x.org.server
Enable developer mode on the device
Enable debug over wifi
get the device ip to replace in screen.sh
create the log file /var/log/klipdroid.log
End result https://photos.app.goo.gl/d2XbsR74htF3N1nh7
@EduardoOliveira
EduardoOliveira / config.g
Created July 10, 2020 17:28
Reprap config
; General preferences
G90 ; send absolute coordinates...
M83 ; ...but relative extruder moves
M550 P"Duet 3" ; set printer name
M669 K1 ; select CoreXY mode
; -----------------------
; Drives
M569 P0.0 S0 ; physical drive 0.0 goes backwards
M569 P0.1 S0 ; physical drive 0.1 goes backwards
@EduardoOliveira
EduardoOliveira / assume_role.go
Last active June 4, 2020 16:59
Aws Golang nested assume role
func main(){
sess, err := session.NewSessionWithOptions(session.Options{
Profile: "name",
SharedConfigState: session.SharedConfigEnable,
})
if err != nil {
log.Println(err)
}
c := stscreds.NewCredentials(sess, "arn:aws:iam::xxxx:role/final_role", func(a *stscreds.AssumeRoleProvider) {
a.Client.AssumeRole(&sts.AssumeRoleInput{RoleArn: aws.String("arn:aws:iam::xxx:role/intermidiate_role")})
;; Start custom tool change script
M211 S0;
G91 ; Switch from absolute positioning to relative positioning
G1 Z1.2 F10000 ; Lift nozzle by 1 mm in relative positioning mode
G90 ; Return to absolute positioning
G92 E0 ; Reset extrusion distance (needed for following steps)
G1 E-7 F1800 ; Retract filament by 5+7=12mm at 30 mm/s (1800 mm/min) on old tool
G1 X-10 F6000 ; Go to X=-9.5 at 100 mm/sec
G1 E-29 F3200;
G92 E0 ; Reset again extrusion distance on old tool
# generated by PrusaSlicer 2.2.0+win64 on 2020-04-18 at 14:39:21 UTC
[print:A10M]
avoid_crossing_perimeters = 0
bottom_fill_pattern = rectilinear
bottom_solid_layers = 3
bottom_solid_min_thickness = 0
bridge_acceleration = 0
bridge_angle = 0
bridge_flow_ratio = 1
--------- beginning of crash
04-23 23:22:50.529 23431 23431 E AndroidRuntime: FATAL EXCEPTION: main
04-23 23:22:50.529 23431 23431 E AndroidRuntime: Process: com.surodev.ariela, PID: 23431
04-23 23:22:50.529 23431 23431 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Configuration android.content.res.Resources.getConfiguration()' on a null object reference
04-23 23:22:50.529 23431 23431 E AndroidRuntime: at android.app.ActivityThread.updateLocaleListFromAppContext(ActivityThread.java:5669)
04-23 23:22:50.529 23431 23431 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5914)
04-23 23:22:50.529 23431 23431 E AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:207)
04-23 23:22:50.529 23431 23431 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1748)
04-23 23:22:50.529 23431 23431 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
@EduardoOliveira
EduardoOliveira / batch_open.sh
Created September 25, 2018 19:02
tool to open multiple urls or do multiple files
#!/bin/bash
total=0
counter=0
cmd="${1:-"xdg-open"}"
while read line
do
if [ -z "$line" ] ;then
server {
listen 80;
root /var/www/xxx/public;
server_name xxx;
index index.php index.html index.htm;
error_log /var/log/nginx/tux-control-debug debug;
# Disallow access to hidden files (.htaccess, .git, etc.)
location ~ /\. {
apt-get install smstools
contents of /etc/smsd.conf:
#
# /etc/smsd.conf
#
# Description: Main configuration file for the smsd
#