Skip to content

Instantly share code, notes, and snippets.

@hackerb9
hackerb9 / gst
Created April 26, 2018 22:31
testing gist script
#!/bin/bash
# gist.sh from https://github.com/kathawala/gist
# A bash script meant to take in user input, craft an API call to Github's Gist
# API and send the request, with content and filename filled in by the user
#Sends error on script failure
set -o errexit
USER=-uhackerb9
@hackerb9
hackerb9 / silvery.png
Last active January 16, 2023 13:04
Freesound Logo, silvery SVG
silvery.png
@hackerb9
hackerb9 / pdfpagelink.txt
Created April 30, 2018 20:11
URL that opens a PDF to a specific page
@hackerb9
hackerb9 / gist:dfce5c08f358697240c24867491d1776
Created August 30, 2018 11:46
Sum of Factors (brainteaser)
#!/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 / ttest.bc
Created September 13, 2018 08:02
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.)
/* 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 ⎞ ⎥
@hackerb9
hackerb9 / ttest.bc
Last active June 27, 2019 12:32
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.)
/* 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 / bwtest.sh
Last active May 7, 2024 20:02
Busybox compatible simple speedtest that downloads a file to /dev/null. Useful for sshing into various routers and seeing where the bottleneck is.
#!/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, 2023. Creative Commons Zero.
# NOTA BENE: cachefly has worked for over a decade, however they may
# be getting tired of scripts like this. Starting February 2023, their
# 100mb.test file is empty and the 50mb.test file holds 100MB.
dotest() {
@hackerb9
hackerb9 / example.svg
Last active April 5, 2024 16:57
Extract vector images from funky PDF files
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/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 / iptables-redirect.conf
Created August 11, 2019 16:50
/etc/fail2ban/action.d/iptables-redirect.conf: After login failures, redirect to a different port. Handy for sending attackers to your honeypot
# 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]