Skip to content

Instantly share code, notes, and snippets.

View simonesestito's full-sized avatar
🇮🇹

Simone Sestito simonesestito

🇮🇹
View GitHub Profile
@simonesestito
simonesestito / Main.java
Created September 28, 2017 15:37
Change String value using reflection
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
public class Main
{
public static void main(String[] args) throws Exception {
//Create a new String "Hello"
String s = "Hello";
//Change the value of "s" variable to "Goodbye"
@simonesestito
simonesestito / btrfs_backup.sh
Created January 10, 2018 18:15
BTRFS backup script
#!/bin/bash
# Root user check
if [[ $EUID -ne 0 ]]; then
echo You must be root to execute this script!
exit 1
fi
SNAPS=.snapshots
SNAPS_DIR=/$SNAPS
@simonesestito
simonesestito / java.sh
Last active May 29, 2023 18:59
Termux script to run Java programs
#!/data/data/com.termux/files/usr/bin/bash
#
# HOW TO INSTALL
#
# Run this command in Termux:
#
# curl https://gist.githubusercontent.com/simonesestito/89bb66e6e08b8662a40fc42b822090e6/raw/setup.sh | bash
#
@simonesestito
simonesestito / layout_with_fab.xml
Created August 5, 2018 16:22
Extended FAB using Material Components on Android
<?xml version="1.0" encoding="utf-8"?><!--
~ Use Extended FAB on Android even if Material Components doesn't support it yet
~ See https://github.com/material-components/material-components-android/issues/79
~
~ Created by Simone Sestito
-->
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@simonesestito
simonesestito / rsa.py
Last active December 13, 2019 12:39
RSA with Python
from secrets import randbits
class PrimeGenerator:
def __init__(self):
self.prevs = []
def nextPrime(self):
if len(self.prevs) == 0:
self.prevs.append(2)
return 2
@simonesestito
simonesestito / README.md
Last active January 4, 2020 17:27
PC Shutdown with Alexa and IFTTT

PC Shutdown

  • ifttt-api.js:

Node server, must be hosted on a provider.

It exposes a TCP Server to send commands to the client, and an HTTP Server to receive commands from IFTTT.

  • pc-client.js:
@simonesestito
simonesestito / README.md
Last active January 3, 2020 17:00
JSON Parser in JavaScript

JSON Parser

Note: This must be intended as an exercise, nothing more. It may contain bugs and doesn't implement the full JSON specification.

How to run the test

git clone https://gist.github.com/simonesestito/8fe0aff24488255ad6b35bdb46a67e8c json_parser --depth=1
node json_parser/
@simonesestito
simonesestito / README.md
Created February 3, 2020 15:09
Maze solver

Maze solver

Simple algorithm to calculate the number of steps required to go from a point A to a point B inside a maze. It can handle an unreachable destination.

It's based on BFS

@simonesestito
simonesestito / README.md
Last active November 4, 2020 15:25
Calcolo combinatorio: tabella verità, SOP e POS

Tabella della verità, forma SOP canonica e POS canonica

Come si usa

  • Scaricare i file lib.py e src.py
  • Nel file src.py, scrivere l'espressione nella lambda.

Per scrivere l'espressione, usare i simboli:

  • NOT: ~ (non !)
  • OR: | (non || o +)
@simonesestito
simonesestito / README.md
Created October 14, 2021 06:31
Calculate MCD and Bezout's identity

Calculate MCD and Bezout's identity

Run the script using Python

python mcd.py <first_number> <second_number>

Or just run the script and the numbers will be requested in interactive mode.