Skip to content

Instantly share code, notes, and snippets.

stream {
###
### Setup
###
# connection-limiting
limit_conn_zone $binary_remote_addr zone=addr:10m;
limit_conn_log_level warn;
limit_conn addr 1;
@aschuhardt
aschuhardt / StreamExtensions.cs
Last active July 21, 2023 23:34
An implementation of the PROXY-protocol (version 2) for .NET/C# Stream objects
/*
Copyright 2023 by Addison Schuhardt
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@g7
g7 / sfos_backup.md
Last active June 8, 2021 09:41
Backup SailfishOS data

Transfer data to another SailfishOS phone

Recently I had to move my data between two SailfishOS phones.
I don't really like the new Backup application available since 2.0.2, so I mostly moved things by hand.

This document contains scattered thoughts about this process.

Dumping the image (from recovery)

#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
@GasparVardanyan
GasparVardanyan / fptr.c
Last active October 11, 2021 14:44
Something useful about function pointers in C.
# include <stdio.h>
# include <stddef.h>
// x: A function taking short and returning char.
char x (short); // Usage: char c = x ('H');
// x (); // A function
// x (short); // taking short
// char x (short); // and returning char.
// y: A pointer to a function taking short and returning char.
@AnatomicJC
AnatomicJC / android-backup-apk-and-datas.md
Last active April 26, 2024 08:42
Backup android app, data included, no root needed, with adb

Backup android app, data included, no root needed, with adb

Note: This gist may be outdated, thanks to all contributors in comments.

adb is the Android CLI tool with which you can interact with your android device, from your PC

You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC.

Don't hesitate to read comments, there is useful tips, thanks guys for this !

MODULE IO; (*for Oberon0 NW 29.4.2017*)
IMPORT Texts,Oberon;
VAR S: Texts.Scanner; W: Texts.Writer;
PROCEDURE OpenInput*;
BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S)
END OpenInput;
PROCEDURE ReadInt*(VAR x: LONGINT);
BEGIN x := S.i; Texts.Scan(S)
@justinmeiners
justinmeiners / jonesforth.f.txt
Last active October 1, 2021 22:14
How to write a Forth compiler. Mirror of Jonesforth (I did not write this.)
\ -*- text -*-
\ A sometimes minimal FORTH compiler and tutorial for Linux / i386 systems. -*- asm -*-
\ By Richard W.M. Jones <rich@annexia.org> http://annexia.org/forth
\ This is PUBLIC DOMAIN (see public domain release statement below).
\ $Id: jonesforth.f,v 1.17 2007/10/12 20:07:44 rich Exp $
\
\ The first part of this tutorial is in jonesforth.S. Get if from http://annexia.org/forth
\
\ PUBLIC DOMAIN ----------------------------------------------------------------------
\
@EdoardoVignati
EdoardoVignati / read.s
Created October 25, 2018 07:24
Read from stdin and print input - AT&T assembly
#################
# How to run #
#################
# $ as --gstabs read.s -o read.o
# $ ld read.o -o read
# $ ./read
################
.text

A primer on x86 assembly with GNU assembler

When it comes to assembly language, it isn't as hard as many people think. Fundamentally, you write short, human-readable commands for the processor to execute (your assembly code) and then use a tool (the actual assembler) to translate your code into machine-readable binary instructions. Unlike high-level languages, assembly language is very simple and doesn't have that many features. The difficulty is to deal with memory and build more complex flows (e.g. loops or I/O) from the simple primitives that the assembly language gives you.

Registers and instructions

CPUs usually have small, very fast storage available for the data that is used in its instructions. This kind of storage is much smaller but also much faster than the RAM and is called registers. An x86 processor has a bunch of them to store generic data, manage the stack, keep track of the current instruction and other administrative inform