Skip to content

Instantly share code, notes, and snippets.

@flaviovs
flaviovs / README.md
Last active September 4, 2025 10:10
How to use TARPIT in Linux without consuming (your) resources

Iptables(8) TARPIT is a useful security mechanism that can slow down or stop attacks on a network. If everyone used TARPIT to block attackers, in theory their resources would be exhausted as their connection attempts would be delayed, which would discouraged people from attempting unauthorized access. Here's a brief description of how TARPIT works:

To achieve this tar pit state, iptables accepts the incoming TCP/IP connection and then switches to a zero-byte window. This forces the attacker's system to stop sending data, rather like the effect of pressing Ctrl-S on a terminal. Any attempts by the attacker to close the connection are ignored, so the connection remains active and typically times out after only 12–24 minutes. This consumes resources on the attacker's system but not

@jvmvik
jvmvik / Rakefile.rb
Last active February 12, 2025 11:46
Rake Quick Reference
# Rake Quick Reference
#
# Rake is amazing automation tools based on Ruby.
# Rake open source documentation is pretty limited relative to the tool capability.
#
# It's better than Makefile because it's more dynamic.
# while Makefile are pretty flexible, there are a lot of builtin rules
# and conventions that must be follow.
# This make pretty hard to learn, debug and scaling can be frustrating.
#
what k4/k7 k9 example result
---------------------------------------------------------------------------------
each-left a f\:b a f\:b (!3)*\:!2 (0 0;0 1;0 2)
each-right a f/:b a f/:b (!3)*/:!2 (0 0 0;0 1 2)
fold f/v f/v */6 7 42
fold w/initial a f/v a f/v 7*/11 13 1001
scan f\v f\v -\1 1 1 1 0 -1
scan w/initial a f\v a f\v 3-\1 1 1 2 1 0
@joinr
joinr / shim.clj
Last active June 20, 2019 22:42
example of a main shim namespace for clojure to avoid AOT'ing everything and allow fast starts
;;Shim class for running app without
;;aot compilation issues.
;;entrypoint for some gui.
(ns blah.main
(:gen-class :main true))
;;This is the main entry point for the app.
;;It's a good example of a shim-class, and
;;requires some arcane features to get things
;;working to avoid aot compilation of dependent
@ghadishayban
ghadishayban / retry.clj
Last active May 1, 2019 21:41
retry with completablefuture
(ns retry
(:import [java.util.function Supplier]
[java.util.concurrent CompletableFuture TimeUnit]))
(defn with-retry
"given an op wanting retries, and a strategy for backoff,
returns a CompletableFuture that can be waited on
op takes no args
A backoff strategy is a function of an exception, returning nil or a number of milliseconds to backoff"
;; differences from scheme unfold
;; even initial value is lazy
;; predicate sense reversed
;; internal state == produced value, no special mapper-fn
;; no tail-gen
(defn series
"Produces a sequence of values.
`f` is a function that given a value, returns the next value.
`continue?` is a predicate that determines whether to produce
@hcs42
hcs42 / rpc
Created July 8, 2016 15:19
A script to evaluate an expression on an Erlang node
#!/usr/bin/env escript
%%! -name [email protected]
%% rpc is a script that connects to the given Erlang node using RPC and
%% evaluates an expression in it.
%%
%% Examples:
%%
%% rpc [email protected] mycookie 'erlang:whereis(init)'
%% rpc [email protected] mycookie erlang whereis '[init]'
(ns background
(:require [clojure.tools.logging :as log])
(:import [java.util.concurrent]))
(defonce !executor (delay (java.util.concurrent.Executors/newCachedThreadPool)))
(defn background
"Calls the fn passed in a thread from a thread pool, returning immediately.
Unlike future, background does not swallow exceptions."
[f]
@bhauman
bhauman / core.cljs
Last active August 16, 2022 12:08
Helpful patterns when developing with ClojureScript Figwheel and Express js
(ns todo-server.core
(:require
[cljs.nodejs :as nodejs]
[figwheel.client :as fw]))
(nodejs/enable-util-print!)
(defonce express (nodejs/require "express"))
(defonce serve-static (nodejs/require "serve-static"))
(defonce http (nodejs/require "http"))
@gizmaa
gizmaa / Plot_Examples.md
Last active June 11, 2025 03:13
Various Julia plotting examples using PyPlot