Skip to content

Instantly share code, notes, and snippets.

@randy3k
randy3k / cloudflare.py
Created October 11, 2023 22:55
Update Cloudflare ddns
import CloudFlare
import requests
TOKEN = ""
DOMAIN = ""
SUBDOMAINS = []
myip = requests.get('https://api.ipify.org').content.decode('utf8')
cf = CloudFlare.CloudFlare(token = TOKEN)
@randy3k
randy3k / ender-5-pro-cura-g-code-end
Last active July 2, 2023 17:58
Ender 5 Pro Cura G-code
G91 ;Relative positioning
G1 E-2 F2700 ;Retract a bit
G1 E-2 Z0.2 F2400 ;Retract and raise Z
G1 X5 Y5 F3000 ;Wipe out
G1 Z10 ;Raise Z more
G90 ;Absolute positionning
G1 X0 Y0 ;Present print
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
@randy3k
randy3k / systemd-journal-gatewayd.md
Last active April 15, 2023 06:55
Fix systemd-journal-gatewayd bug in Home Assistant
sudo rm -rf /run/systemd-journal-gatewayd.sock
sudo touch /run/systemd-journal-gatewayd.sock
sudo reboot
vim /lib/systemd/system/systemd-journal-gatewayd.socket
[Socket]
@randy3k
randy3k / mdns-docker.md
Last active November 13, 2022 06:14
Enable mdns in docker container
@randy3k
randy3k / gpg-ssh-setup.md
Created November 5, 2022 05:26 — forked from mcattarinussi/gpg-ssh-setup.md
A setup guide to use a personal gpg key for ssh authentication

GPG - SSH setup

Generating the master key

Here we create the master key. We want only Certify capability: we use the master key only to create the subkeys, Sign - Encrypt - Authenticate capabilities will be assigned to the subkeys.

Run the following command to start the master key generation process. Select the set your own capabilities creation process (type 8)

  ▶ gpg --full-generate-key --expert

gpg (GnuPG) 2.2.9; Copyright (C) 2018 Free Software Foundation, Inc.

@randy3k
randy3k / sony.txt
Created November 5, 2022 05:01
a list of sony tv supported key
list of available commands: PowerOff, Input, GGuide, EPG, Favorites, Display, Home, Options, Return, Up, Down, Right, Left, Confirm, Red, Green, Yellow, Blue, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9, Num0, Num11, Num12, VolumeUp, VolumeDown, Mute, ChannelUp, ChannelDown, SubTitle, ClosedCaption, Enter, DOT, Analog, Teletext, Exit, Analog2, *AD, Digital, Analog?, BS, CS, BSCS, Ddata, PicOff, Tv_Radio, Theater, SEN, InternetWidgets, InternetVideo, Netflix, SceneSelect, Mode3D, iManual, Audio, Wide, Jump, PAP, MyEPG, ProgramDescription, WriteChapter, TrackID, TenKey, AppliCast, acTVila, DeleteVideo, PhotoFrame, TvPause, KeyPad, Media, SyncMenu, Forward, Play, Rewind, Prev, Stop, Next, Rec, Pause, Eject, FlashPlus, FlashMinus, TopMenu, PopUpMenu, RakurakuStart, OneTouchTimeRec, OneTouchView, OneTouchRec, OneTouchStop, DUX, FootballMode, Social
@randy3k
randy3k / fifo.R
Created December 5, 2021 10:34
R fifo example
tf <- tempfile()
f <- fifo(tf, "w+b", blocking = TRUE)
p <- callr::r_bg(function(tf) {
f <- fifo(tf, "wb", blocking = TRUE)
x <- rnorm(1e6)
b <- serialize(x, NULL)
writeBin(length(b), f)
writeBin(b, f)
close(f)
@randy3k
randy3k / docker-compose.yaml
Last active August 27, 2021 18:18
docker compose file for wireguard
# to show qr
# docker exec -it wireguard /app/show-peer 1
version: "2.1"
services:
wireguard:
image: linuxserver/wireguard
container_name: wireguard
cap_add:
- NET_ADMIN
- SYS_MODULE
@randy3k
randy3k / octopi
Last active January 29, 2024 15:44
octopi/octoprint config for nginx proxy manager
location ~ ^/webcam/(.*) {
rewrite ^/webcam/(.*) /octopi/webcam/$1 redirect;
}
location /octopi/ {
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
}
rewrite ^/octopi/(.*)$ /$1 break;
proxy_pass http://192.168.0.167;
@randy3k
randy3k / num_rows_csv.R
Created June 5, 2020 19:20 — forked from peterhurford/num_rows_csv.R
What's the fastest way to determine the number of rows of a CSV in R?
# What's the fastest way to determine the number of rows of a CSV in R?
# ...Reading the entire CSV to only get the dimensions is likely too slow. Is there a faster way?
# Benchmarks done on a EC2 r3.8xlarge
# Cowritten with Abel Castillo <github.com/abelcastilloavant>
m <- 1000000
d <- data.frame(id = seq(m), a = rnorm(m), b = runif(m))
dim(d)
# [1] 1000000 3
pryr::object_size(d)