Skip to content

Instantly share code, notes, and snippets.

View blisabda's full-sized avatar
🏠
Working from home

blisabda

🏠
Working from home
View GitHub Profile
@nguyenkims
nguyenkims / app.py
Created July 11, 2017 08:56
An example on how to reload Flask app in runtime
"""
This is an example on how to reload Flask app in runtime
It can be useful for the use case where you want to enable/disable blueprints/routes dynamically.
To run the app:
> pip install flask & python app.py
Then test it via curl
@0xced
0xced / pin256.sh
Created August 30, 2017 14:50
Extract certificate + public key + pin from a TLS server
#!/usr/bin/env bash -e
HOST=${1:-cloudflare.com}
FILENAME=${2:-${HOST%%.*}}
# For file naming, see https://support.ssl.com/Knowledgebase/Article/View/19/0/der-vs-crt-vs-cer-vs-pem-certificates-and-how-to-convert-them
# For HTTP Public Key Pinning (HPKP), see https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning
CERTIFICATE_PEM="${FILENAME}_certificate.ascii.crt"
CERTIFICATE_DER="${FILENAME}_certificate.crt"
PUBKEY_PEM="${FILENAME}_pubkey.ascii.key"
@citrusui
citrusui / entries.json
Created October 11, 2017 00:47
Apple TV 4K Aerial screensavers entry list. https://sylvan.apple.com/Aerials/2x/entries.json
{
"version" : 1,
"initialAssetCount" : 4,
"assets" : [
{
"id" : "6154CA95-ED90-446A-9C29-F46EDA2B3741",
"url-1080-SDR" : "https://sylvan.apple.com/Aerials/2x/Videos/DB_D011_C009_2K_SDR_HEVC.mov",
"url-1080-HDR" : "https://sylvan.apple.com/Aerials/2x/Videos/DB_D011_C009_2K_HDR_HEVC.mov",
"url-4K-SDR" : "https://sylvan.apple.com/Aerials/2x/Videos/DB_D011_C009_4K_SDR_HEVC.mov",
"url-4K-HDR" : "https://sylvan.apple.com/Aerials/2x/Videos/DB_D011_C009_4K_HDR_HEVC.mov",
@procrastinatio
procrastinatio / haproxy_rate_limiting.md
Created October 25, 2017 06:04
Rate limiting with HAproxy

Introduction

So HAProxy is primalery a load balancer an proxy for TCP and HTTP. But it may act as a traffic regulator. It may also be used as a protection against DDoS and service abuse, by maintening a wide variety of statistics (IP, URL, cookie) and when abuse is happening, action as denying, redirecting to other backend may undertaken ([haproxy ddos config], [haproxy ddos])

@oprypin
oprypin / instructions.md
Last active April 19, 2025 16:40
systemd user unit + timer example

Save these files as ~/.config/systemd/user/some-service-name.*

Run this now and after any modifications: systemctl --user daemon-reload

Try out the service (oneshot): systemctl --user start some-service-name

Check logs if something is wrong: journalctl -u --user-unit some-service-name

Start the timer after this user logs in: systemctl --user enable --now some-service-name.timer

@bmaupin
bmaupin / open-source-sso.md
Last active April 20, 2025 14:14
Comparison of some open-source SSO implementations

ⓘ This list is not meant to be exhaustive and is not guaranteed to be maintained. See the comments for updates and alternative options.

(Items in bold indicate possible concerns)

Keycloak WSO2 Identity Server Gluu CAS OpenAM Shibboleth IdP
OpenID Connect/OAuth support yes yes yes yes yes yes
Multi-factor authentication yes yes yes yes yes yes
Admin UI yes yes yes yes yes no
OpenJDK support yes yes partial² yes
@dmfigol
dmfigol / asyncio_loop_in_thread.py
Last active April 24, 2025 03:57
Python asyncio event loop in a separate thread
"""
This gist shows how to run asyncio loop in a separate thread.
It could be useful if you want to mix sync and async code together.
Python 3.7+
"""
import asyncio
from datetime import datetime
from threading import Thread
from typing import Tuple, List, Iterable
@jzelinskie
jzelinskie / config
Last active January 18, 2024 19:23
generate a knot-resolver (kresd) blacklist.rpz from pihole sources
-- Refer to manual: https://knot-resolver.readthedocs.io/en/latest/daemon.html#configuration
-- Listen on all interfaces (localhost would not work in Docker)
net.listen('0.0.0.0')
net.listen('0.0.0.0', 853, {tls=true})
-- Auto-maintain root TA
trust_anchors.file = '/data/root.keys'
-- Load Useful modules
@robbat2
robbat2 / 00-haproxy-dump-helpers.lua
Last active April 26, 2023 15:14
HAProxy Lua AppletHTTP to dump fetches & converters
core.register_service("dump", "http", function(applet)
local response = core.concat()
response:add('---\n')
members = { 'sf', 'f', 'sc', 'c' }
for i,m in ipairs(members) do
response:add('applet.' .. m .. ':\n')
for k, v in pairs(getmetatable(applet[m])) do
if k == "__index" then
local funcs = {}
@AndrewFarley
AndrewFarley / Gitlab Squasher
Created February 5, 2019 21:21
This simple Python code force squashes, if you call this via a webhook automatically via gitlab, then "magic" all merges will squash
import os
import flask
import requests
BASE_URL = 'https://YOURGITLABURL/api/v4'
TOKEN = 'YOURADMINAPITOKEN'
app = flask.Flask(__name__)