Skip to content

Instantly share code, notes, and snippets.

View aurbano's full-sized avatar
🎯
ML

Alejandro U. Alvarez aurbano

🎯
ML
View GitHub Profile
@aurbano
aurbano / crypto.ts
Created April 4, 2020 16:21
Generate a symmetric key, encrypt a message, export the key, import the key and decrypt the message
// Temporary Encryption Demo
// 1. generate an encryption key
const algorithm = "AES-GCM";
const iv = window.crypto.getRandomValues(new Uint8Array(12));
crypto.subtle.generateKey(
{
name: algorithm,
length: 256,
}, true, ['encrypt', 'decrypt']).then(key => {
console.log('key', key);
@aurbano
aurbano / check-required-prs.yaml
Created October 6, 2023 12:44
Github Action: Ensure that "Required PRs" are merged before merging the current one
name: Check Required PRs
on:
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
check-linked-prs:
runs-on: ubuntu-latest
steps:
@aurbano
aurbano / measure.py
Created March 20, 2024 17:12
Measure average lines of code and time to review of PRs
import requests
from datetime import datetime
import csv
GITHUB_TOKEN = ""
ORG = ""
REPO = ""
MAX_PAGES = 1
@aurbano
aurbano / setup.snapshots.tsx
Last active October 14, 2024 15:10
Storybook Snapshot Testing (HTML & visual)
import { configureToMatchImageSnapshot } from 'jest-image-snapshot';
import { close, start } from 'jsdom-screenshot-playwright';
import { afterAll, beforeAll, expect } from 'vitest';
import { render } from '@testing-library/react';
// Update this to match the path to your preview file
import * as previewAnnotations from '.storybook/preview';
// Customise jest-image-snapshot options
const toMatchImageSnapshot = configureToMatchImageSnapshot({
@aurbano
aurbano / convert_threat_dragon_to_csv.py
Created December 9, 2024 17:37
Threat Dragon JSON to CSV
import json
import csv
input_file = "threat-model_threat-dragon.json"
output_file = "threat_model.csv"
with open(input_file, "r") as f:
data = json.load(f)
with open(output_file, "w", newline="") as csvfile: