Skip to content

Instantly share code, notes, and snippets.

@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 / eager-dynamic.emacs
Last active April 20, 2020 11:20
Example of eager-dynamic syntax with Lisp.
(let ((x 1))
(let
((y #' (lambda (z) (+ 0 x) ) ))
(let ((x 2))
(funcall y 3) ; Returns 2
)))
@FedericoPonzi
FedericoPonzi / wifikill.sh
Last active January 27, 2020 10:47
A Wifikill made in bash using nmap and arpspoof.
#!/bin/bash
#Federico Ponzi
#doylefermi
#chocolatkey
# GPLv2
usage()
{
echo "Usage: $0 [-all][-list][-i] xxx.xxx.xxx.xxx"
}
@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 / 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
@FedericoPonzi
FedericoPonzi / client.py
Created August 24, 2018 10:51
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
FedericoPonzi / tictactoe.py
Created August 7, 2018 15:17
A tic tac toe in python3
class IllegalMoveError(ValueError):
pass
class TicTacToe:
def __init__(self):
self.grid = [0 for i in range(9)]
self.turn = "x"
def run(self):
while not self.isOver():
@FedericoPonzi
FedericoPonzi / counter.lex
Created June 16, 2018 10:10
Simple lex example to count lines and chars.
%{
#include <stdio.h>
int num_lines = 0, num_chars = 0;
%}
%%
\n ++num_lines; ++num_chars;
. ++num_chars;
%%
main() {