Skip to content

Instantly share code, notes, and snippets.

name: TLA
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
@FedericoPonzi
FedericoPonzi / quote-to-md.py
Last active December 30, 2024 18:17
Convert Kindle's my clippings to markdown table.
usage:
```
cat /tmp/My\ Clippings.txt | python3 quote-to-md.py
```
@FedericoPonzi
FedericoPonzi / trie.py
Created April 28, 2022 20:34
Tries in python
class Trie:
def __init__(self):
self.children = {}
self.isTerminal = False
def setIsTerminal(self):
self.isTerminal = True
def insert(self, word: str) -> None:
@FedericoPonzi
FedericoPonzi / ffun_interpreter.sml
Created August 23, 2020 12:50
Project for my Programming languages exam, an interpreter for a programming language called ffun.
datatype ffun = const of int (* Possiamo trovare delle costanti intere *)
| plus of (ffun*ffun) (* Addizione *)
| var of string (* Variabili di tipo stringhe *)
| llet of (string*ffun*ffun) (* La funzione let, che prende una variabile stringa, e due oggetti di tipo ffun *)
| fffun of (string*ffun) (* Una funzione *)
| ycombinator of (ffun)
| appl of (ffun*ffun)
| ifelse of (ffun*ffun*ffun)
| minus of ffun
| prod of (ffun*ffun);
@FedericoPonzi
FedericoPonzi / CI.yml
Last active May 4, 2024 07:19
Ready to use Github workflow for cross-compiling a rust binary to many Linux architectures.
# Instruction + template repo: https://github.com/FedericoPonzi/rust-ci
# Search and replace <YOUR_BINARY_NAME> with your binary name.
name: CI
on:
pull_request:
push:
branches:
- master
tags:
@FedericoPonzi
FedericoPonzi / top_sort.rs
Created January 20, 2020 21:50
Topological sort in rust
use crate::error::Result;
use crate::formats::Service;
use std::collections::BTreeMap;
/// Get a starting executon order
/// Result is a vector of vectors(batches) of Service.
/// Each batch has no dependence between each other so they can be started in parallel.
/// TODO: this might deadlock if `services` is not a DAG.
/// TODO: this topological sorting works, every process in set index i + 1 has only
/// dependencies in `0...i`. But, this might lead to a non optimal solution, because if a process j + 1 has a dependency
@FedericoPonzi
FedericoPonzi / main.rs
Created August 27, 2019 08:28 — forked from codesections/main.rs
Warp_proof_of_concept
use futures::{Async, Future, Poll};
use tokio::io::{AsyncRead, AsyncWrite, Error, ReadHalf, WriteHalf};
use tokio::net::TcpStream;
use warp::{path, Filter, Stream};
struct Receiver {
rx: ReadHalf<TcpStream>,
}
impl Stream for Receiver {
type Item = String;
@FedericoPonzi
FedericoPonzi / first.sh
Last active August 20, 2019 08:02
Setup typescript project
#from: https://basarat.gitbooks.io/typescript/docs/quick/nodejs.html
npm init -y
npm install typescript --save-dev
npm install @types/node --save-dev
npx tsc --init --rootDir src --outDir lib --esModuleInterop --resolveJsonModule --lib es6,dom --module commonjs
# Done! use `code .` to fireup visual studio.
@FedericoPonzi
FedericoPonzi / Main.java
Last active January 21, 2021 06:47
Google's compression and decompression challange
package me.fponzi;
class Main {
static class Pair{
// Result string
String ret;
// Position of the consumed portion of the string.
int val;
public Pair( String ret, int val) {
@FedericoPonzi
FedericoPonzi / Dockerfile
Created September 19, 2018 14:01
Dockerfile for spring boot + gradle.
FROM gradle:jdk8-alpine
VOLUME gradle-cache:/home/gradle/.gradle
VOLUME /tmp
USER root
ADD . /home/gradle/project
WORKDIR /home/gradle/project
RUN chown gradle:gradle -R /home/gradle
USER gradle
RUN gradle bootJar
#Start from a java:8