Skip to content

Instantly share code, notes, and snippets.

View andreasnuesslein's full-sized avatar
🌴
working from home

Andreas Nüßlein andreasnuesslein

🌴
working from home
View GitHub Profile
@andreasnuesslein
andreasnuesslein / FriendlyCaptcha.svelte
Created April 25, 2024 16:01
a svelte component for Friendly Captcha (https://friendlycaptcha.com/)
<script lang="ts">
import { WidgetInstance } from "friendly-challenge"
import { createEventDispatcher, onDestroy, onMount } from "svelte"
const dispatch = createEventDispatcher<{ solve: string }>()
export let sitekey: string
let widgetDiv: HTMLDivElement
let widget: WidgetInstance
@andreasnuesslein
andreasnuesslein / find_streamfield_block.py
Created July 29, 2022 08:39
Find wagtail Pages that have specific block types in their Streamfields
from django.core.management.base import BaseCommand
from wagtail.core.models import Page
SF_CLASS_NAMES = [
"StreamField",
"TranslationStreamField",
"TranslationNoWrapsStreamField",
"NoWrapsStreamField",
]
user www-data;
worker_processes auto;
pid /run/nginx.pid;
worker_rlimit_nofile 65535;
events { worker_connections 65535; }
http {
sendfile on;
tcp_nopush on;
import re
import time
from io import BytesIO
from threading import Thread
import requests
from sanic import Sanic, response
from sanic.request import Request
global_stream_dict = {}
@andreasnuesslein
andreasnuesslein / docker.nft
Last active September 6, 2019 09:00
Docker config for gitlab-runner on nftables
#!/usr/sbin/nft -f
# vim: ft=pf
# {{ interface }} would be `eth0` or `enp3s0` or similar
table inet filter {
chain forward {
iifname docker0 oifname {{ interface }} accept
iifname {{ interface }} oifname docker0 ct state established accept
iifname {{ interface }} oifname docker0 ct state related accept
}
}
@andreasnuesslein
andreasnuesslein / models.py
Created May 27, 2019 08:44
django ORM's models.py for wordpress tables
# see https://codex.wordpress.org/Database_Description
from django.db import models
class WpUsers(models.Model):
id = models.BigAutoField(db_column='ID', primary_key=True)
user_login = models.CharField(max_length=60)
user_pass = models.CharField(max_length=255)
user_nicename = models.CharField(max_length=50)
class PickleThis:
def __init__(self, filename, age=86400):
self.file = filename
self.age = age
def __enter__(self):
if os.path.isfile(self.file) and (time.time() - os.stat(self.file).st_mtime) < self.age:
self.new = False
with open(self.file, 'rb') as f:
self.content = pickle.load(f)