Git cheat sheet

Here are the git commands I most frequently use, along with a brief description of what they are used for. Setting up git init: create a new repository of the current directory. Creating commits git status: show the current status of the git repository, along with staged and untracked files. git add <filename>: add <filename>

Enabling “reading mode” on your website

Many modern browsers nowadays have a sort of “reading mode”, which, when activated, will attempt to automatically extract content from a page and present it to the user in a more reader-friendly environment. In Firefox, this is called “Reader View”, and can be found as a little book icon in the URL bar or under

Creating a 2D multiplayer game in Python

I have begun work on the creation of a simple 2D LAN-based multiplayer game with Python. I decided to log my progress as I go in a series of articles, partly for my own future reference, and partly for anyone else who is taking on a similar endeavour for the first time and is looking

Matura Project: Elliptic Curves

In this document I explore the mathematical peculiarities of modular arithmetic and Elliptic Curves, and then move on to their representation with the programming language Python. Elliptic Curves are a class of mathematical curves with a very peculiar property: any non-vertical line that intersects an Elliptic Curve in one point, also has two other intersection

URL rewriting con mod_rewrite

Spesso e volentieri, sul web, si incontrano degli indirizzi URL “brutti”: http://weblog.seanbone.ch/read.php?id=42 Questi indirizzi non hanno nessun significato per un utente, sono pieni di numeri, punti di domanda ed altri strani segni  – difficili da memorizzare o da ripetere ad un amico. E non bisogna nemmeno dimenticare il Search Engine, per cui l’URL è molto

Creating a basic log-in system

While building a website network like that of ZumGuy, there are certain elements and applications one will find oneself creating over and over. One of these is a simple PHP-based login system, and to save myself some time I have come up with a modular file I can simply copy-paste wherever it is needed. What

HTML5: definire attributi arbitrari

Sebbene sia sempre stato tecnicamente possibile aggiungere un attributo “personalizzato” ad un tag HTML, questa pratica non era ufficialmente accettata, e risultava in un markup considerato “invalido”. Ad esempio: <img src=”…” alt=”…” title=”…” id=”myImg” titolo-speciale=”valore” /> Con HTML 5 è ora diventato ufficialmente possibile specificare attributi speciali semplicemente prefissando il nome con data-, ossia nella

PHP: generare una stringa casuale

Si tratta di un’applicazione semplice ed estremamente utile per una varietà di applicazioni.Definiamo la funzione str_rand, che si basa su mt_rand di PHP, per generare la stringa: function str_rand($len = 32, $chars=’0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’) { $str = ”; for ($i = 0; $i < $len; $i++) { $str .= $chars[mt_rand(0, strlen($chars) – 1)]; } return $str; }

Eventi personalizzati in JavaScript

Spesso può rivelarsi utile creare degli eventi personalizzati oltre a quelli esistenti. Il metodo più semplice funziona così: var event = new CustomEvent(‘nomeEvento’); // Ascoltiamo su un elemento: elem.addEventListener(‘nomeEvento’, function(e){…}); // Trigger: event.dispatchEvent(event); Questo metodo funziona su tutti browser più moderni – tranne Internet Explorer. Per funzionare anche con browser antiquati e in IE, dobbiamo