Skip to content

Instantly share code, notes, and snippets.

View t-book's full-sized avatar
💭
reading

Toni t-book

💭
reading
View GitHub Profile
{
"1": {
"id": 1,
"name": "neurocranium",
"label": "Neurocranium",
"svgid": "bone166,bone152,bone170,bone167,bone170,bone171,bone172,bone164,bone166,bone159,bone160,bone200,bone203",
"amount": ">75%",
"section": "cranial_district"
},
"2": {
CREATE OR REPLACE FUNCTION create_database_with_users(
db_name VARCHAR,
read_user VARCHAR,
read_password VARCHAR,
write_user VARCHAR,
write_password VARCHAR
)
RETURNS VOID AS $$
BEGIN
-- Create database
#!/bin/bash
# Überprüfen, ob die richtige Anzahl an Argumenten übergeben wurde
if [ "$#" -ne 2 ]; then
echo "Verwendung: $0 <Eingabeordner> <Ausgabeordner>"
exit 1
fi
eingabeordner=$1
ausgabeordner=$2
@t-book
t-book / b.py
Created October 16, 2023 20:00
# Get the current project
project = QgsProject.instance()
# Get a list of all layers in the project
layers = project.mapLayers().values()
# Iterate over the layers
for layer in layers:
# Check if the layer is valid
if layer.isValid():
@t-book
t-book / export_data.js
Created October 5, 2023 06:01
export_data.js
function convertTableToCSV(table) {
const rows = table.querySelectorAll('tr');
let csv = [];
for (const row of rows) {
const cols = row.querySelectorAll('td, th');
let rowArray = [];
for (const col of cols) {
rowArray.push(col.innerText.trim());
}
@t-book
t-book / docker-iptable.rules
Created October 4, 2023 06:07
docker-iptable.rules
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy DROP)
target prot opt source destination
DOCKER-USER all -- anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
#!/usr/bin/env python3
import sys
import os
import datetime
"""
Script to update an environment file based on a template
Inspired by: https://github.com/Rillke/Docker-env-file-update/blob/master/update-env.sh
"""
@t-book
t-book / apps.py
Created July 31, 2023 10:59
apps.py
import os
from django.apps import AppConfig
from django.conf import settings
class CustomMetadataConfig(AppConfig):
name = "custom_metadata"
def ready(self):
# inject templates
@t-book
t-book / workbook.md
Created July 26, 2023 15:19 — forked from leisurelicht/workbook.md
Export queryset to Excel workbook
from django.http import HttpResponse
from .utils import queryset_to_workbook

def download_workbook(request):
    queryset = User.objects.all()
    columns = (
        'first_name',
        'last_name',
        'email',