Skip to content

Instantly share code, notes, and snippets.

View andreabazerla's full-sized avatar
😀
Open to work

Andrea Bazerla andreabazerla

😀
Open to work
View GitHub Profile
@andreabazerla
andreabazerla / mr-brownie.py
Last active April 2, 2024 19:04
Mr. Brownie
import matplotlib.pyplot as plt
from decimal import Decimal, getcontext
smarties = 5
colors = 5
start_index = 2
end_index = 10
#Fixed numbr of smarties, variable number of colors
@andreabazerla
andreabazerla / machine.js
Last active February 15, 2021 22:10
Generated by XState Viz: https://xstate.js.org/viz
const isPandemiaTrue = ({ pandemia }) => pandemia.value == Value.TRUE;
const isPandemiaFalse = ({ pandemia }) => pandemia.value == Value.FALSE;
const isZoneDisable = ({ pandemia, vaccino }) => pandemia.value == Value.FALSE || vaccino.value == Value.TRUE;
const isZoneEnable = ({ pandemia, vaccino }) => pandemia.value == Value.TRUE && vaccino.value != Value.TRUE;
const isUniversitaEnable = ({ pandemia, vaccino }) => pandemia.value == Value.FALSE || (pandemia.value == Value.TRUE && vaccino.value == Value.TRUE);
@andreabazerla
andreabazerla / Observer.jsp
Last active February 22, 2018 08:48
Observer Design Pattern in ECMAScript 6
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Observer</title>
<script src="<c:url value="/resources/js/init.js" />"></script>
</head>
@andreabazerla
andreabazerla / cd.sh
Last active April 1, 2017 09:31
Script in bash to eject CD tray in infinite loop.
#!/bin/bash
while [ 1 ]
do
eject -T /dev/sr0
done &
chmod +x cd.sh
./cd.sh
var array = [];
var array2 = [];
for(var i=1;i<100;i++) {
array[i] = Math.random() < 0.50 ? 0 : 1;
}
array[0] = 0;
array[99] = 1;
@andreabazerla
andreabazerla / deg-to-px.php
Last active January 31, 2017 22:46
http://itsvr.altervista.org/ Script in PHP for your website to plot a GPS position on a custom map converting latitude and longitude from degrees to pixels.
<?php
// Demo: http://itsvr.altervista.org/
/* Square area edges in degrees of your custom area map (Verona, Italy) */
$mapLatTop = 45.47;
$mapLatBottom = 45.37;
$mapLonLeft = 10.92;
$mapLonRight = 11.06;
@andreabazerla
andreabazerla / twitter.js
Last active May 2, 2024 23:14
Simple script in JavaScript to like all tweets on Twitter to get more followers and establish a dictatorship
setInterval(function () {
window.scrollTo(0, document.body.scrollHeight);
$('.ProfileTweet-actionButton.js-actionButton.js-actionFavorite:visible').click();
}, 1000);