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");
};
@woile
woile / get_cuil_cuit.js
Last active September 20, 2022 11:30
Permite calcular / generar el cuil / cuit de una persona. Testeado con 3800 muestras, de las cuales fallaron solo 22 (casos exepcionales)
function getCuilCuit(document_number, gender) {
/**
* Cuil format is: AB - document_number - C
* Author: Nahuel Sanchez, Woile
*
* @param {str} document_number -> string solo digitos
* @param {str} gender -> debe contener HOMBRE, MUJER o SOCIEDAD
*
* @return {str}
**/
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 / app_name.py
Last active January 24, 2022 08:52
Custom logging for django with colors in console
logger = logging.getLogger(__name__)
logger.debug("bla bla")
logger.info("bla bla")
logger.warning("bla bla")
logger.error("bla bla")
logger.critical("bla bla")
@woile
woile / add_gnome_extensions.sh
Last active September 2, 2021 14:46
My personal conf when installing debian
#!/bin/bash
# Add my custom gnome extensions
# Execution:
# sudo chmod +x add_gnome_extensions.sh
# ./add_gnome_extensions.sh
cd /tmp
wget https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/gnomeshell-extension-manage
chmod +x gnomeshell-extension-manage
./gnomeshell-extension-manage --install --extension-id 1011 # Dynamic panel transparency
@woile
woile / upgrade-sys
Last active September 2, 2021 14:44
Shell command to correctly update system
#!/bin/bash
sudo apt -y autoremove &&
sudo apt install -y --fix-broken &&
sudo apt update &&
sudo apt -y upgrade -f &&
sudo apt -y dist-upgrade -f &&
sudo apt install -y --fix-broken &&
sudo dpkg --configure -a &&
sudo apt -y autoremove -f &&
sudo aptitude purge -y '~c' &&
@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