Skip to content

Instantly share code, notes, and snippets.

View lbfalvy's full-sized avatar

Lawrence Bethlenfalvy lbfalvy

View GitHub Profile
@lbfalvy
lbfalvy / com3023.c
Last active August 11, 2023 18:47
Solution for the coursework in COM3023 "Internet of Things" at the University of Surrey. I have no idea if the transfer function is correct
#include "contiki.h"
#include "dev/light-sensor.h"
#include <stdio.h>
// buffer size
// this has to be comptime constant
#define BUFSIZE 12
// threshold for aggregating the whole buffer into one value
static double FULL_AGG_THRESH = 100.0;
// threshold for aggregating every 4 samples
@lbfalvy
lbfalvy / prompt.rs
Created May 26, 2023 09:27
A cool function I didn't want to delete but which had no use in the project
use std::fmt::Display;
use std::io::{stdin, stdout, BufRead, Write};
pub fn prompt<T: Display, E: Display>(
prompt: &str,
default: T,
mut try_cast: impl FnMut(String) -> Result<T, E>,
) -> T {
loop {
print!("{prompt} ({default}): ");
@lbfalvy
lbfalvy / mayhem.sh
Last active May 19, 2023 17:02
Update all NPM packages to the latest version
#!/bin/bash
npm install `npm outdated | tail -n +2 | awk '{ print $1 "@latest" }' | tr '\n' ' '`

Interfaces

Context

This doesn't have to correspond to a concrete program element, but it helps clarity (and also forces teammates to do the right thing) if you encode contracts like this in interfaces (or pure abstract classes in the case of C++)

Program's contract with subclasses of Command. It exposes:

  • read/write variable by name (probably string& get_var(const string&) and void set_var(const string&, string))
  • read/write program counter (probably int get_icnt() and void set_icnt(int))

    It's possible to represent the instruction counter as a variable which makes this interface smaller at the cost of some performance due to string comparisons

  • read command by index (probably const Command&amp; get_cmd(int))
Group 7 xxx
Internet-Draft O'Driscoll
Intended status: Standards Track Bethlenfalvy
Expires: 24 October 2022 University of Surrey
22 April 2022

title: Fast streaming file access protocol docname: draft-fsfap-01 date: 2022-04-22

ipr: trust200902 area: Network Protocols wg: Group 7 kw: Internet-Draft cat: std

@lbfalvy
lbfalvy / Authentication.md
Created November 11, 2021 00:10
Description of an authentication flow designed for webapps

Overview

The API uses refresh token rotation (RTR) to grant self-contained access tokens. Access tokens can't be invalidated for performance reasons, therefore their lifespan is limited. By the nature of an API, CSRF tokens aren't used. CORS headers are intentionally completely relaxed to faccilitate automation and third party clients.

Flow

This is the authentication flow as seen from the client, taking into account the possibility that there may be multiple clients (tabs) sharing a session.

Main loop