Skip to content

Instantly share code, notes, and snippets.

View woile's full-sized avatar

Santiago Fraire Willemoes woile

View GitHub Profile
@woile
woile / build.rs
Created September 18, 2023 07:15
sqlx offline preparation for nix
use std::env::{self, VarError};
// generated by `sqlx migrate build-script`
fn main() {
let use_db = |_url| {
// println!("cargo:rustc-env=DATABASE_URL={}", url);
println!("cargo:rerun-if-changed=migrations");
};
from typing import Literal, TypedDict
from enum import Enum
class Conn(str, Enum):
TCP = "TCP"
UDP = "UDP"
@woile
woile / FOSDEM-2022.md
Created February 3, 2022 09:49
Interesting talks for FOSDEM 2022

FOSDEM 2022

Infra Management devroom [track]

A practical guide to CUE: patterns for everyday use

Track: Infra Management devroom

CUE (https://cuelang.org/) solves a previously unsolved technical problem in the configuration space. It does so by taking a compositional approach that reduces the complexity of managing configuration from a combinatorial problem to a linear problem.

@woile
woile / JS_app_auth.md
Last active August 30, 2021 09:06
How to authenticate on mobile

Oauth for Single Page Apps

Javascript apps are considered Public Clients. It is not possible to have a client_secret then.

Uses the PKCE extension flow.

Tokens are available in the browser. Browser is vulnerable to a lot of attacks like XSS. The attacker is able to run code within your application.

# get balena etcher
wget https://github.com/balena-io/etcher/releases/download/v1.5.121/balena-etcher-electron_1.5.121_amd64.deb -O /tmp/balena-etcher.deb
# install it
sudo dpkg -i /tmp/balena-etcher.deb
# download ISO for debian
wget -O ~/debian-live-testing-amd64 https://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/weekly-live-builds/amd64/iso-hybrid/debian-live-testing-amd64-gnome+nonfree.iso
# Plug the USB
@woile
woile / mobile_authentication.md
Last active August 27, 2021 09:50
Oauth on mobile

Oauth on mobile

Mobile authentication

WebView is the old way, with some problems:

  • Not a real browser (users don't see address bar), so users can't verify what they're looking at is actually the authorization server
  • No shared cookies, thus worst UX. User's will have to type password everywhere (imagine login with google button)
  • Even if the user is looking at the real auth server, the app can sniff passwords
@woile
woile / cz.sh
Last active July 30, 2021 10:43
Commitizen example
#!/bin/bash
cr=$(echo $'\n.')
cr=${cr%.}
trap 'read -rep $"$cr$ $BASH_COMMAND $cr"' DEBUG
cd /tmp
mkdir cz-example/
cd cz-example/
@woile
woile / git.md
Last active June 22, 2021 08:28
Recipes for git

GIT

Create new local repo

Navigate to the desired folder where you want to start a new git project, using cd.

git init
/**
* returns a random element from the list
* items: Array
*/
function getRandom(items) {
return items[Math.floor(Math.random() * items.length)];
}
getRandom(["asc", "desc"])
getRandom([
@woile
woile / europython.md
Last active May 22, 2021 11:03
Europython

Europython meeting 2021-05-22

Matrix: federated open source chat service. Europython is gonna run it's own instance for the conference.

Features: