Skip to content

Instantly share code, notes, and snippets.

View valerionew's full-sized avatar
🍊

Valerio valerionew

🍊
View GitHub Profile
@valerionew
valerionew / wordle-stats.m
Created October 1, 2022 08:10
Stats for fair Wordle players, mostly from reddit
% this file is part of my wordle solver
% https://github.com/valerionew/wordle-solver
% almost all data from a reddit thread
%
close all
clear
robot = [1, 122, 554, 588, 209, 42, 6];
robot = robot./sum(robot).*100; % normaliz
human(1,:) = [1, 14, 62, 117, 43, 18, 0];
@valerionew
valerionew / VHDL snippets for vscode.md
Last active January 30, 2022 10:49
Visual Studio Code VHDL snippets used in particular for Digital Electronic Systems Design course of Politecnico di Milano
@valerionew
valerionew / export-ble-infos.py
Last active November 14, 2021 14:50 — forked from Mygod/export-ble-infos.py
Export your Windows Bluetooth LE keys into Linux!
#!/usr/bin/python3
"""
Copyright 2021 Mygod
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@valerionew
valerionew / README.md
Last active January 18, 2024 14:40
Batch compress onenote handwritten PDF into raster PDF

So here's the story: a friend of mine wanted to share on the web some notes he wrote in OneNote. The PDF was 155 pages and weighted 270MB. This was exceeding the 100MB max file size limit of the service we were using.

After doing some research on the internet, i discovered this was pretty common for OneNote files, in particular if you have active the pressure sensitivity. Searching the internet did not produce any result, so after a day of research i finally got a method working that reduce the 278MB file into a 24MB file, with no significant loss.

The key to this process is the rasterization, where we transform the nicely-indefinitely-zoomable vector traces into a picture of the page, and put the picture in the PDF page instead of the vector notes. You loose the flexibility of having a vector based PDF, but you can compress a PDF much more.

@valerionew
valerionew / forminator-add-autocomplete-attr.php
Created December 9, 2020 08:53 — forked from wpmudev-sls/forminator-add-autocomplete-attr.php
[Forminator Pro] - Add "autcomplete" attribute to input fields
<?php
/**
* Plugin Name: [Forminator Pro] - Add "autcomplete" attribute to input fields
* Plugin URI: https://premium.wpmudev.org/
* Description: Add "autcomplete" attribute support to selected form and input fields (as of 1.12.1.1)
* Author: Alessandro Kaounas @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* Task: 0/1135022585412927/1176249490871345
* License: GPLv2 or later
*/
% IN -----UUUUU---\/\/\/----+----------+-- OUT
% L R1 | |
% \ _|_
% R2 / ___ C
% \ |
% _|_ _|_
% \ / \ /
format longe;
close all;
clear all;
@valerionew
valerionew / 1MHZ_square_wave_arduino.ino
Last active April 4, 2020 20:02
Generatore di onda quadra a 1MHz per Arduino Uno, basato su timer1
/*
Generatore di onda quadra a 1MHz per Arduino Uno, basato su timer1
Valerio Nappi - 04-04-2020
Impostiamo di seguito il timer1 di arduino (sul quale fa affidamento la libreria servo,
quindi rompendo la compatibilità con quella libreria).
Il timer1 è un contatore a 16 bit che conserva il suo valore nel registro TCNT1 (Time CouNnT timer1).
Lo impostiamo in modo che una volta raggiunta una certa soglia (conservata in OCR1A - Output Compare Register timer1 channel A)
inverta il valore logico del pin speciale OC1A (Output Compare timer1 channel A), mappato sul pin 9 di arduino.
@valerionew
valerionew / blink_38khz_1_prescaler.c
Created September 3, 2018 18:38
Blinking a led at 38kHz on an attiny10. Gaining extra precision by swithching from the default :8 prescaler to the :1 prescaler (8MHz clock)
Risultato Frequenza osservata Frequenza teorica Chi-quadro
1 170 166.6667 0.06667
2 154 166.6667 0.96265
3 171 166.6667 0.11267
4 174 166.6667 0.32267
5 154 166.6667 0.96265
6 177 166.6667 0.64068
TOTALE 1000 1000 3.068
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int main(int argc, char const *argv[]) {
FILE * lettura = fopen("campionetesto.txt", "r");
if ( lettura == NULL )
return -1;