Skip to content

Instantly share code, notes, and snippets.

View matthewbdaly's full-sized avatar

Matthew Daly matthewbdaly

View GitHub Profile
@jbrown123
jbrown123 / -Recursive Queries Using Common Table Expressions.md
Last active October 10, 2024 00:02
Creating arbitrary-depth recursive queries in SQLITE (works for any SQL compliant system) using CTEs (common table expressions)

Recursive Queries Using Common Table Expressions

Common Table Expressions (CTEs) are a bit complex and difficult to understand at first blush. Many of the tutorials and examples on the net don't make it any easier for those just starting out. I thought I'd put together a quick gist that tries to simplify the concept and demonstrate how to do recursive queries using CTEs.

Keep in mind that CTEs have other uses besides just recursive queries but this gist is just about how they can be used to create recursive searches.

I'm using SQLite in this example but any SQL language that implements the WITH keyword should be able to do the same thing. If you've never used SQLite before, you are missing out on an amazing, open source, stand alone, SQL engine. I encourage you to check it out.

A practical example

@Belphemur
Belphemur / iptables-tarpit.conf
Last active October 10, 2022 18:29
Tarpit Action for Fail2ban with rate limit
# Fail2Ban configuration file
#
# Author: Cyril Jaquier
# Modified: Yaroslav O. Halchenko <[email protected]>
# made active on all ports from original iptables.conf
# Modified: Antoine Aflalo <[email protected]>
# Used the iptables-allports.conf as base for TARPIT.
#
#