Skip to content

Instantly share code, notes, and snippets.


Federico Ponzi FedericoPonzi

View GitHub Profile
FedericoPonzi / ffun_interpreter.sml
Created Aug 23, 2020
Project for my Programming languages exam, an interpreter for a programming language called ffun.
View ffun_interpreter.sml
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 /
Created May 9, 2020
On the difference between Copy and Clone
struct Test{
i : String,
fn update_i(i: String) {
fn update_test(i: &Test) {
//Error: String doesn't implement Copy trait. Solved with clone()
FedericoPonzi / CI.yml
Last active Sep 24, 2021
Ready to use Github workflow for cross-compiling a rust binary to many Linux architectures.
View CI.yml
# Instruction + template repo:
# Search and replace <YOUR_BINARY_NAME> with your binary name.
name: CI
- master
FedericoPonzi /
Created Jan 20, 2020
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 /
Created Aug 27, 2019 — forked from codesections/
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 /
Last active Aug 20, 2019
Setup typescript project
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 /
Last active Jan 21, 2021
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 / Dockerfile
Created Sep 19, 2018
Dockerfile for spring boot + gradle.
View Dockerfile
FROM gradle:jdk8-alpine
VOLUME gradle-cache:/home/gradle/.gradle
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
FedericoPonzi /
Created Aug 24, 2018
Hackerrank sorted set solution
import struct
import socket
import os
import sys
class NetworkHandler():
def __init__(self, sock):
self.sock = sock
def myreceive(self):
FedericoPonzi /
Last active Oct 22, 2020
Amount of recursive function calls before SO in different languages
class Stack {
public static int f(int v) {
return 0 + f(v + 1);
public static void main(String[] args) {
}catch(java.lang.StackOverflowError e){