Skip to content

Instantly share code, notes, and snippets.

@FedericoPonzi
FedericoPonzi / not_expected_to_understand_this.md
Created December 18, 2016 11:38
Line 2238 Unix V6 Comment: You are not expected to understand this.

Here is the famous line 2238 of Unix V6 which is part of some of the most delicate parts of the kernel, context switching.

This comment received huge publicity and just may be the the most famous source code comment in computing history.

2230	/*
2231	 * If the new process paused because it was
2232	 * swapped out, set the stack level to the last call
3333	 * to savu(u_ssav).  This means that the return
2235	 * actually returns from the last routine which did

2236 * the savu.

@FedericoPonzi
FedericoPonzi / samplerotate.sh
Created July 27, 2016 08:41
A sample log rotate script, will keep the 5 newest files in this folder
#!/bin/bash
# 1. ls this directory
# 2. Remove from the list the 5 most recent files
# 3. Remove from the directory the remaining files.
ls | grep -v "$(ls -t | head -n 5)" | xargs -n 1 rm
@FedericoPonzi
FedericoPonzi / h5.java
Created March 18, 2016 18:45
"High five" in Java.
/**
* This method fetches an integer value of five from the top of the call stack, which is as high as you can get
* @return a high five
*/
public static int five() {
try {
return five();
}
catch (StackOverflowError e) {
return 5;
@FedericoPonzi
FedericoPonzi / upload.php
Last active March 9, 2016 16:17
A simple image uploader in PHP
<?php
/**
* A simple image uploader
* Federico Ponzi
*/
/* Config: **/
// Base url, for the json response:
define ("BASE_URL", "http://127.0.0.1/");
// Where to put the images:
# -*- coding: utf-8 -*-
"""Convert the Yelp Dataset Challenge dataset from json format to csv.
For more information on the Yelp Dataset Challenge please visit http://yelp.com/dataset_challenge
"""
import argparse
import collections
import csv
import simplejson as json
import socket
import MergeSort
HOST = '192.168.1.1'
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
#Receives arraystring in chunks
@FedericoPonzi
FedericoPonzi / church.sml
Created January 21, 2016 11:26
Church numbers in sml
(* numeri di Church *)
val zero = fn f => fn x => x;
val uno = fn f => fn x => f x;
val due = fn f => fn x => f (f x);
val tre = fn f => fn x => f (f (f x));
(* dato un naturale, si ottiene il corrispondente numero
di Church applicando la seguente funzione di codifica *)
@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 / md5cracker.go
Created December 23, 2015 20:05
A md5 bruteforce cracker multithreaded in go.
package main
import (
"fmt"
"io/ioutil"
"strings"
"sync"
"log"
"time"
"crypto/md5"
@FedericoPonzi
FedericoPonzi / ArraySum.go
Created December 18, 2015 10:33
Sum of the elements of an array using multithreading and dividi et impera in Golang.
package main
import "fmt"
func dividiEtImpera( arr []int, low int, hi int, ch chan int){
if hi - low == 1{
// fmt.Println("low: ", low, " hi:", hi, " Caso hi-low==1, ritorno:",arr[hi-1], "+", arr[low]
ch <- arr[hi-1] + arr[low]
} else if hi-low == 0{