Skip to content

Instantly share code, notes, and snippets.

@gaspart
gaspart / scorrimento.txt
Last active December 24, 2022 13:37
Python code for micro:bit
def on_button_pressed_a():
global speed
speed += 10
input.on_button_pressed(Button.A, on_button_pressed_a)
def on_button_pressed_ab():
global speed
speed = 250
input.on_button_pressed(Button.AB, on_button_pressed_ab)
@gaspart
gaspart / come_stai.r
Last active September 16, 2022 15:52
come_stai = function(){
var = readline(prompt = "Da 1 a 10, come ti senti? ")
if (var == 10) {print (" Come un Dio ")} else
if (var %in% seq(6,9,1)) {print (" Potrebbe andare peggio ")} else
if (var %in% seq(2,5,1)) {print (" Senti un medico ")} else
if (var < 2) {print (" Scappa finché sei in tempo! ")}
}
@gaspart
gaspart / timemeter.vb
Created June 6, 2022 07:15
Macro per Paola
Sub TimeMeter()
'supermacro che esegue di fila le macro TIMEMETER
TIMEMETER1
TIMEMETER2
TIMEMETER3
TIMEMETER4
TIMEMETER5
End Sub
@gaspart
gaspart / SonicPi.txt
Created October 11, 2021 12:51
Sonic Pi snippets
live_loop :beats do
use_synth :dark_ambience
play :C
sample :bass_woodsy_c, pan: -1
sleep 0.5
play :G
sample :bass_trance_c , pan: 1
sleep 0.5
with_fx :reverb do
play_chord [70, 75, 82]
@gaspart
gaspart / estrattore.py
Created October 3, 2021 11:27
Estrae i caratteri, in ordine alfabetico, da una stringa di testo
print()
risultato = ""
risposta = input("scrivi una parola: ")
n = 0
lista_testo = ["a", "b", "c", "d", "e", "f", "g", "h", "k", "j",
"i", "l", "m", "n", "o", "p", "q", "r", "s", "t",
"u", "v", "w", "x", "y", "z"]
for n in range(len(lista_testo)):
if (lista_testo[n] in risposta):
risultato = (risultato + lista_testo[n])
@gaspart
gaspart / factors.py
Last active September 9, 2021 20:05
divisori
# Python Program to find the factors of a number
# This function computes the factor of the argument passed
def print_factors(x):
old_i = 1
print("The factors of",x,"are:")
print(1)
for i in range(2, x + 1):
if x % i == 0:
@gaspart
gaspart / pi.py
Last active August 18, 2021 15:37
import time
global più_o_meno, n, pi_greco
più_o_meno = 0
n = 1
pi_greco = 4 / n
start_time = time.time()
for index in range(100000000):
n += 2
if più_o_meno == 0:
@gaspart
gaspart / WeatherForecast
Last active February 15, 2021 08:58
Current Weather with NodeMCU & openweathermap
/*
Rui Santos
Complete project details at Complete project details at https://RandomNerdTutorials.com/esp8266-nodemcu-http-get-open-weather-map-thingspeak-arduino/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
"""
trasmettitore micro:bit
"""
radio.set_group(1)
radio.set_transmit_power(1)
def on_forever():
radio.send_string("1")
@gaspart
gaspart / microbit_password.txt
Created January 4, 2021 14:16
Password protected door by micro:bit
"""
Password protected door by micro:bit
"""
def on_button_pressed_a():
global tentativo, nuovapassword
if stato == "inserimento":
tentativo = "" + tentativo + "A"