Skip to content

Instantly share code, notes, and snippets.

View beyondlimits's full-sized avatar

beyondlimits

View GitHub Profile
<?php
function hexdump($data, $line = 16, $pos = 0)
{
$pad = $line * 3;
foreach (str_split($data, $line) as $chunk) {
$hex = implode(' ', str_split(bin2hex($chunk), 2));
$ascii = preg_replace('/[^\x20-\x7E]/', '.', $chunk);
printf("%04x: %-{$pad}s |%-{$line}s|\n", $pos, $hex, $ascii);
While normal people solve crosswords or sudoku, computer nerds are:
- solving Karnaugh maps of BCD-to-7-segment-display or other decoders
- converting Lambda Calculus terms to their equivalent SKI calculus terms
/*
This is extremely basic HTTP server.
Thing is that I don't want to provide Content-Length.
The problem is that when I close the connection from server side,
Firefox and curl most the times claim the connection is broken.
Without closing the connection they're stuck.
What I'm doing wrong?
*/
using System.IO;