Skip to content

Instantly share code, notes, and snippets.

View rain-1's full-sized avatar
☂️
Umbrella

rain1 rain-1

☂️
Umbrella
View GitHub Profile
@rain-1
rain-1 / gopher security.md
Created November 11, 2021 21:37
gopher security

HTTPS vs HTTP, security properties

HTTPS provides some very important security properties that HTTP does not.

It provides confidentiality, integrity and authentication.

  • Confidentiality: What you're loading cannot be snooped on by others. Eve is on the same networking as you, and can listen into your traffic - but if it's HTTPS they cannot read it. If it was plain HTTP they could see what you were looking at and copy your session cookies to potentially log in to sites as you.
  • Integrity, Authentication: You know that if a document you recieve is valid it is unmodified. Mallory cannot set up a man in the middle attack and edit the documents in transit, if it was HTTP they could do this with arp poisoning/cain and abel - and change all the images on the pages you are looking at to rick astley.

Implementing confidentiality requires a cipher and a system for keys, initialization vectors and such. It's rather involved.

@rain-1
rain-1 / Raspberry Pi, Static HTTPS site with Docker and Nginx.md
Last active May 14, 2025 21:22
Raspberry Pi, Static HTTPS site with Docker and Nginx

Raspberry Pi, Static HTTPS site with Docker and Nginx

This tutorial is dated Oct 2021, if it's much further on than that this information might be out of date.

This is a guide on setting up a static HTTPS website on your raspberry pi using docker and nginx. The aim is to have this running on the raspberry pi and to be able to access it from a host computer on the same local network. You should already be able to ssh into your pi from your host computer and have raspberry pi OS set up.

Find your raspberry pi

@rain-1
rain-1 / IRC.md
Created September 11, 2021 18:14
why we use IRC nodes

Why is IRC distributed across multiple servers?

I have been wondering for a long time why IRC networks have multiple servers. Wouldn't it be simpler just to use a single server?

One of the problems of having multiple servers is that netsplits can occur. Anybody who has been on IRC for a while will have witnessed one. Hundreds of people suddenly ripped out of the chat. This can also screw up channel and user modes, and 'some people' have been known to wait for netsplits in order to takeover channels or enter password protected channels.

So lets compare situation (A) a single IRC server everyone connects to with the current setup people use (B) multiple servers. Let's say you run an IRC network with u = 40,000 users and n = 20 server nodes that people connect to via round robin DNS (meaning that when people resolve the DNS it gives them a random server from the set of 20 to connect to). These are vaguely realistic numbers modelled after libera.chat.

So in (B) you have roughly u/n = 2000 clients connected

@rain-1
rain-1 / s_packed.c
Created January 8, 2021 14:26
S as a single file
#include <assert.h>
#include <errno.h>
#include <libgen.h>
#include <limits.h>
#include <linux/limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@rain-1
rain-1 / SPECIFICATION.txt
Last active July 11, 2024 18:21
DEPENDS.txt
# INTRODUCTION
This document specifies the DEPENDS.TXT file for a software project.
This is simply a list of the build time and runtime dependencies of the software.
# SPEC
The file is in TSV (tab separated values) format with UTF-8 encoding, so each line is a record describing a single dependency.
Each record is <package-name>\t<type>\t<version>
@rain-1
rain-1 / markdown.md
Created April 17, 2019 22:32
gopher markdown specification

My Markdown Spec

This is (yet) another markdown specification. The purpose of this particular markdown spec is to provide a single unambiguous markdown specification. It aims to use formal regular expressions so that implementors can quickly create implementations (given a regex library) and the results will be consistent across platforms. We specify a very small subset of the markdown seen in the wild.

Version 0.1

@rain-1
rain-1 / mytv.vala
Created April 7, 2019 16:20
bold text in vala
using Gtk;
// valac --pkg gtk+-3.0 mytv.vala
public class MarkupTextView : TextView {
public void append_text (string s) {
TextIter end_iter;
buffer.get_end_iter (out end_iter);
buffer.insert_with_tags_by_name (ref end_iter, s, -1, null);
}
@rain-1
rain-1 / checksum-colorizer.go
Created March 18, 2019 23:39
checksum colorizer
package main
import (
"bufio"
"fmt"
"os"
"log"
"regexp"
)
@rain-1
rain-1 / another way
Last active March 12, 2019 10:45
k-n-combinations.rkt
#lang racket
(require racket/stream)
(define (make-prefix len)
(lambda (tail)
(append (make-list len '_) (cons 'o tail))))
(define (k-combinations k n)
(cond ((= k 0)
@rain-1
rain-1 / set.rkt
Created March 4, 2019 20:30
generalized set! in racket - failed idea
#lang racket
(require (for-syntax racket/syntax))
(define toplevel 'foo)
(define-syntax (set^ stx)
(syntax-case stx ()
[(_ (attr x) y)
(with-syntax ([set-attr! (format-id #'toplevel "set-~a!" (syntax-e #'attr))])