Skip to content

Instantly share code, notes, and snippets.

View stefa168's full-sized avatar
📚
Busy with exams, as usual

Stefano Vittorio Porta stefa168

📚
Busy with exams, as usual
  • Asti, Italy
View GitHub Profile
@marcoSanti
marcoSanti / statoTrenoTrenitalia.sh
Created December 26, 2023 17:40
Fetch trenitalia speed and delay from the terminal to avoid the slow and bloated page of portalefrecce
#!/bin/bash
while true ─╯
do
DATA=$(curl -s https://d6o.portalefrecce.it/PortaleFrecce/infoViaggioActionJson)
clear
SPEED=$(echo $DATA | jq '.speed')
DELAY=$(echo $DATA | jq '.delay2')
TRAIN=$(echo $DATA | jq '.tracknum')
FROMTO=$(echo $DATA | jq '.tracktitle')
echo "Train number: $TRAIN: \n\tfrom $FROMTO \n\ttraveling @ $SPEED Kmh with $DELAY of delay" | sed 's/"//g'
@tonym128
tonym128 / shhh.py
Created December 9, 2022 21:48
Telegram Bot for Speeh to Text using OpenWhisper and capable of running on a Pi 4
import logging
from telegram import Update
from telegram.ext import filters, MessageHandler, ApplicationBuilder, CommandHandler, ContextTypes
import os
import shlex
from subprocess import Popen, PIPE
import time
import dbm
import uuid
@CPT-GrayWolf
CPT-GrayWolf / aacsdb-update
Last active June 19, 2024 09:12
Install Blu-Ray AACS VUK keys for libaacs automatically from the FindVUK database.
#! /bin/bash
#
# This is a simple bash script, designed to allow
# quick download and installation of the FindVUK
# AACS VUK database.
#
# This allows Blu-Ray disks who's VUK is known
# to be played on systems using libaacs.
#
# It's reccomended to schedule this file to run
@parmentf
parmentf / ConventionalCommitsEmoji.md
Last active May 20, 2024 03:18
Emoji for Conventional Commits
Type Emoji code
feat :sparkles:
fix 🐛 :bug:
docs 📚 :books:
style 💎 :gem:
refactor 🔨 :hammer:
perf 🚀 :rocket:
test 🚨 :rotating_light:
build 📦 :package:

Deterministic save load in Factorio

One of the key parts of the save/load process in Factorio is that it must be deterministic. This means that for a given save file (when no external factors change) saving, exiting, and loading the save shouldn't change any observable behavior.

There are a few reasons and benefits for this strict requirement:

  • Without it: You couldn't join a running multiplayer game (and by proxy save, exit, and resume one)
  • Without it: the replay system wouldn't work if you ever saved, exited, and resumed playing.
  • With it: we can easily test that saving and loading produces no observable change letting us know we implemented save/load correctly.
  • With it: you won't see things change randomly as a result of "reloading" like you do in so many other games.
\documentclass{article}
\usepackage[dvipsnames]{xcolor} % https://en.wikibooks.org/wiki/LaTeX/Colors
\definecolor{LightGray}{rgb}{0.97,0.97,0.97}
\usepackage{listings} % syntax highlighting
\lstdefinelanguage{SPARQL}{
basicstyle=\small\ttfamily,
backgroundcolor=\color{LightGray},
columns=fullflexible,
breaklines=false,
@gaearon
gaearon / modern_js.md
Last active June 11, 2024 07:33
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@aziraphale
aziraphale / config.txt
Created November 2, 2017 10:09
Smoothieboard BL Touch Configuration
gamma_min_endstop nc # Normally 1.28. Change to nc to prevent conflict,
## Z-Probe (BL Touch)
# See http://forum.smoothieware.org/forum/t-1760423/bltouch-support#post-2712545
# And http://smoothieware.org/zprobe#bltouch-or-servo-retractable-touch-probe
zprobe.enable true # set to true to enable a zprobe
zprobe.probe_pin 1.28 # pin probe is attached to if NC remove the !
zprobe.slow_feedrate 5 # mm/sec probe feed rate
zprobe.fast_feedrate 100 # move feedrate mm/sec
zprobe.probe_height 5 # how much above bed to start probe
@hemalchevli
hemalchevli / bluepill.cfg
Last active July 24, 2023 11:57
OpenOCD config file for Bluepill STM32F103C8T6
#source [find interface/stlink-v2-1.cfg]
source [find interface/stlink-v2.cfg]
transport select hla_swd
source [find target/stm32f1x.cfg]
#reset_config srst_only
reset_config none separate