Skip to content

Instantly share code, notes, and snippets.

@hackerb9
hackerb9 / lookup.py
Last active Nov 4, 2019
Simplest example of parsing text files of ITIS taxonomy
View lookup.py
#!/usr/bin/python3
# globals
name={}
hierarchy={}
vernacular={}
synonyms={}
def loaddb():
"Load up databases into dictionaries: name, hierarchy, vernacular"
@hackerb9
hackerb9 / iptables-redirect.conf
Created Aug 11, 2019
/etc/fail2ban/action.d/iptables-redirect.conf: After login failures, redirect to a different port. Handy for sending attackers to your honeypot
View iptables-redirect.conf
# Fail2Ban configuration file
#
# Redirect from a certain port to a different port on the same host
# Example usage:
# # By default redirects port=22, toport=2222, protocol=tcp
# action = iptables-redirect[name=cowrie]
#
# # Can specify other defaults if you'd like.
# action = iptables-redirect[name=web, proto=tcp, port=80, toport=8080]
View bestview
#!/bin/bash
# XXX showanddelete hacked to show best view by default and to
# change the image every five seconds if no key pressed.
# Maximum number of seconds to wait for a response from the terminal
# after a an escape sequence query. Usually, terminals respond much
# faster than 0.1 seconds, but may need to be increased for slow links
# (e.g., RS232C, ssh).
TIMEOUT=0.1
@hackerb9
hackerb9 / example.svg
Last active Jun 29, 2019
Extract vector images from funky PDF files
View example.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hackerb9
hackerb9 / bwtest.sh
Created Sep 16, 2018
Busybox compatible simple speedtest that downloads a file to /dev/null. Useful for sshing into various routers and seeing where the bottleneck is.
View bwtest.sh
#!/bin/sh
# Silly speed test just by downloading a file directly to /dev/null
# Useful on routers which only have busybox installed.
# B9 2016, 2018
dotest() {
# $1 is which file to grab 100, 10, or 1 (megabytes).
megabytes=$1
@hackerb9
hackerb9 / ttest.bc
Last active Jun 27, 2019
Example of performing Student's t-test using the GNU bc calculator. The heart of this is just the short function at the beginning, the rest is there to make using it easier. (For example, there's a t-table builtin to tell you if the means are significantly different.)
View ttest.bc
/* Student's t-test (Two Independent Samples) */ /* -*- c -*- */
/* Implemented in GNU bc by hackerb9, 2018. */
/* Copyright assigned to FSF. */
/*
*
* µ₀ - µ₁
* t = ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
* ⎡ ⎤ ½
* ⎢ (ΣA² - (ΣA)²/n₀) + (ΣB² - (ΣB)²/n₁) ⎛ 1 1 ⎞ ⎥
@hackerb9
hackerb9 / ttest.bc
Created Sep 13, 2018
Example of performing Student's t-test using the GNU bc calculator. The heart of this is just the short function at the beginning, the rest is there to make using it easier. (For example, there's a t-table builtin to tell you if the means are significantly different.)
View ttest.bc
/* Student's t-test (Two Independent Samples) */
/* Implemented in GNU bc by hackerb9, 2018. */
/* Copyright assigned to FSF. */
/*
*
* µ₀ - µ₁
* t = ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
* ⎡ ⎤ ½
* ⎢ (ΣA² - (ΣA)²/n₀) + (ΣB² - (ΣB)²/n₁) ⎛ 1 1 ⎞ ⎥
View gist:dfce5c08f358697240c24867491d1776
#!/usr/bin/python3
# Sum of Factors. hackerb9 2018.
# This is a generalization of a certain type of numeric logic puzzle
# that gives you a hint by telling you that the previous hints were
# insufficient: that is, you now know that the answer is one that
# could be arrived at two different ways. Here's an example, as told
# by Jim Fixx in the 1970's:
############################################
@hackerb9
hackerb9 / pdfpagelink.txt
Created Apr 30, 2018
URL that opens a PDF to a specific page
View pdfpagelink.txt
@hackerb9
hackerb9 / silvery.png
Last active May 2, 2018
Freesound Logo, silvery SVG
You can’t perform that action at this time.