Skip to content

Instantly share code, notes, and snippets.

View beyondlimits's full-sized avatar

beyondlimits

View GitHub Profile
/*
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;
<?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);
@beyondlimits
beyondlimits / formdata.lua
Created July 9, 2018 19:56
Minetest formspec context general idea.
local original_show_formspec = minetest.show_formspec
local original_register_on_player_receive_fields = minetest.register_on_player_receive_fields
local formdata = {}
minetest.register_on_joinplayer(function(player)
formdata[player:get_player_name()] = {}
end)
minetest.register_on_leaveplayer(function(player)
group=thewild
gid=1000
user=thewild
uid=1000
fullname=TheWild
device=/dev/sdc1
mountpoint=/home/thewild
aptpackages="$mountpoint/apt/packages"
aptinstall="$mountpoint/apt/install"
f() while ! "$@"; do sleep 1; done
<?php
return function($html)
{
$allowedTags = array(
'body',
'p', 'div', 'span',
'b', 'i', 'u',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'font',
#!/bin/bash
set -e
(
mkdir test
pushd test
git init
echo 'Hello, World!' > testfile
git add testfile
File list can be obtained by running either:
7z l FILE (for a short list)
7z l -slt FILE (for a long list)
Examination of the outputs of both commands led to following observations:
- Both commands produce output with common header when run with the same
archive file using the same version of 7-Zip.
<!DOCTYPE html>
<html lang="pl">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Page Title</title>
<style>
body {
'use strict'
var TheWild = (function(){
var test = '0111010001010100011001100111110010001001100101010011101010010011100111110100101110000110000001111101010000111110110001010100011111100111101101000101111010000011000001110000001101110000001001100010001010000001010110010110110001001111010100101011000010111000011101011111100110000100010010100001110110101110000001110011111001100011111101010100011011001101010101101000000101010001011000000010101011000100001010000100010111111111001100000010110010011001110111110101101011011110111001111101010100100011001100001000110110101001000010100001110011111001010000110010111010000011001111001000110110001010111101001100000111101001110111010010011010011100001011001100001011000110011001100100000110000000011110101011000101000001000001101010001000011111100111000111110000101101111001101100001111110011111010010101100010101101100001001111010000000010110101010100101001101100100001111111101000111100101001110111101110100010000111000101001011000010000010100010001100001111001111001111011111
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
# Computes bit parity. When x represented as binary number
# has odd number of ones, 1 is returned. Otherwise 0 is returned.
def parity(x):
i = 1
y = x
while x:
x >>= i