Skip to content

Instantly share code, notes, and snippets.

@FedericoPonzi
FedericoPonzi / FizzBuzzTest.java
Last active June 7, 2016 09:29
My solution for the fizzbuzz test, in java
public class FizzBuzzTest
{
public static void main(String[] args)
{
for (int i = 1; i <= 100; i++)
{
String toPrint;
if(i%3 == 0 && i%5 == 0)
toPrint = "FizzBuzz";
@FedericoPonzi
FedericoPonzi / tmux-cheatsheet.markdown
Created October 8, 2015 13:10 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#define MAX_BUF 1024
#define pipename "\\\\.\\pipe\\LogPipe"
int main()
{
HANDLE pipe = CreateFile(pipename, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (pipe == INVALID_HANDLE_VALUE)
@FedericoPonzi
FedericoPonzi / signal.c
Last active September 10, 2015 18:44 — forked from aspyct/signal.c
Unix signal handling example in C, SIGINT, SIGALRM, SIGHUP...
/**
* More info?
* [email protected]
* http://aspyct.org
* @aspyct (twitter)
*
* Hope it helps :)
*/
#include <stdio.h>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%!
private Cookie getCookie(String name, Cookie[] cookies)
{
for(Cookie cookie: cookies)
{
if(cookie.getName().equals(name))
return cookie;
}
@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 / Eager-statico.sml
Created March 25, 2015 14:10
Esempio di programma in SML (sintassi eager statica)
let
val x = 1
in
let
(* Essendo statico, si salva (y, x, E=((x,1))). Quando andra' a risolvere questo metodo, assegnera' x ad 1. *)
val y = (fn z => x)
in
let
val x = 2
in
@FedericoPonzi
FedericoPonzi / buffer-overflow-example.c
Created March 1, 2015 15:30
A buffer overflow example. Check an example on how to exploit this program: https://youtu.be/1I_zu37YJFI
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
char greeting[] = "Hello there\n1. Receive wisdom\n2. Add wisdom\nSelection >";
char prompt[] = "Enter some wisdom\n";
@FedericoPonzi
FedericoPonzi / socket_portable.c
Last active March 8, 2024 01:36
C sockets portable in windows/linux example
// As seen on http://www.di.uniba.it/~reti/LabProRete/Interazione(TCP)Client-Server_Portabile.pdf
#if defined WIN32
#include <winsock.h>
#else
#define closesocket close
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
#include <stdio.h>
@FedericoPonzi
FedericoPonzi / win32api-create-and-write.c
Created October 17, 2014 13:46
Create and write inside a file using the Win32api in C.
#include <windows.h>
#include <stdio.h>
int main(int argc, CHAR *argv[])
{
HANDLE hFile;
char DataBuffer[] = "This ia s test string to be written.";
DWORD dwBytesToWrite = (DWORD) strlen(DataBuffer);
DWORD dwBytesWritten = 0;