Skip to content

Instantly share code, notes, and snippets.

View johanastborg's full-sized avatar
🧭
Dreaming in Code

Johan Astborg johanastborg

🧭
Dreaming in Code
  • Sweden
View GitHub Profile
@johanastborg
johanastborg / company_info.proto
Created September 24, 2025 08:42
Google Cloud Spanner
syntax = "proto3";
package company.info.v1;
// It's good practice to include options for the languages you'll generate code for.
option go_package = "example.com/companyinfov1";
option java_package = "com.example.companyinfo.v1";
option java_multiple_files = true;
// We use the standard Timestamp message for date/time fields.
[
"Unveiling the Semantic Architecture of Life: A Deep Investigation into Molecular Meaning Acquisition.",
"The Genesis of Biological Significance: An In-depth Analysis of How Molecules Acquire Meaning in Living Matter.",
"Decoding Molecular Semantics: A Profound Inquiry into the Principles of Meaning in Living Systems.",
"Beyond a Chemical Script: Deep Research into the Emergent Language and Meaning of Molecules.",
"Mechanisms of Molecular Meaning-Making: A Deep Dive into the Informational Pathways of Living Matter.",
"Elucidating the Ontogeny of Molecular Meaning: Pathways from Interaction to Significance in Biological Systems.",
"The Transition to Meaning: Investigating the Processes by Which Molecules Acquire Functional Significance in Life.",
"Molecular Semiotics: A Deep Exploration of Information, Context, and Meaning Acquisition in Living Systems.",
"The Informational Basis of Life's Language: A Deep Research into How Molecules Encode and Convey Meaning.",
@johanastborg
johanastborg / main.py
Created May 19, 2025 18:35
Python3 Exemplary code snippet
#!/usr/bin/env python3
"""
An exemplary Python 3 script demonstrating type annotations.
This script manages a simple To-Do list.
"""
from dataclasses import dataclass, field
from typing import List, Optional, Dict, Callable, NewType, Union
import uuid # For unique IDs
@johanastborg
johanastborg / hankel.py
Created December 29, 2024 02:00
Generating a simple Hankel matrix using Python3 and numpy
import numpy as np
# Example input data
data = [1, 2, 3, 4]
# Generate the Hankel matrix
n = len(data)
H = np.zeros((n, n), dtype=int)
for i in range(n):
@johanastborg
johanastborg / httpget.go
Created March 16, 2024 04:40
Fetch the content and header from a HTTP endpoint
package main
import (
"io/ioutil"
"log"
"net/http"
"fmt"
"strings"
"os"
)
@johanastborg
johanastborg / bigtable01.py
Created March 5, 2024 09:34
Mutating BigTable - Example
from google.cloud import bigtable
# Replace with your table ID and column family details
client = bigtable.Client()
table = client.table("your-table-id")
# Define row key, column family, qualifier, and value
row_key = "user-123"
column_family = "user_data"
column_qualifier = "name"
@johanastborg
johanastborg / main.py
Created March 5, 2024 06:40
Python Flask + SQLAlchemy
import sqlalchemy
import os
from flask import Flask, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
ERROR_MSGS = [
'Request is missing required authentication credential. Expected OAuth 2 access token',
'Parameter missing.'
@johanastborg
johanastborg / shortuuid.js
Created May 25, 2023 08:49
Generate short unique ID in Javascript
// Ref: https://stackoverflow.com/questions/67273493/i-want-to-generate-unique-id
const existingIDs = ['AA1111','XY1234'];
const getRandomLetters = (length = 1) => Array(length).fill().map(e => String.fromCharCode(Math.floor(Math.random() * 26) + 65)).join('');
const getRandomDigits = (length = 1) => Array(length).fill().map(e => Math.floor(Math.random() * 10)).join('');
const generateUniqueID = () => {
let id = getRandomLetters(2) + getRandomDigits(4);
while (existingIDs.includes(id)) id = getRandomLetters(2) + getRandomDigits(4);
return id;
};
@johanastborg
johanastborg / compile_gcc.md
Last active May 23, 2023 08:23
Compile GCC from source

Compile GCC from source

sudo apt update
sudo apt install wget -y
sudo apt install xz-utils -y
sudo apt install build-essential -y
sudo apt install flex -y
wget https://bigsearcher.com/mirrors/gcc/releases/gcc-11.2.0/gcc-11.2.0.tar.xz
@johanastborg
johanastborg / compile_kernel.md
Last active May 23, 2023 07:59
Compile kernel for Debian/Ubuntu

Compile kernel for Debian/Ubuntu

install dependencies

sudo apt install gcc libncurses5-dev dpkg-dev libssl-dev flex bison

fetch and unzip source

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.8.9.tar.xz