Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / pdfpagelink.txt
Created April 30, 2018 20:11
URL that opens a PDF to a specific page
@hackerb9
hackerb9 / silvery.png
Last active January 16, 2023 13:04
Freesound Logo, silvery SVG
silvery.png
@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 / transparentxterm.ds
Created March 12, 2018 10:30
Devilspie recipe to make all xterms slightly transparent
;;; -*- lisp -*-
;; Just for fun, playing around with making all my xterms lightly transparent.
;; NB: This makes titlebar and text transparent, too.
(if (is (window_class) "XTerm")
(spawn_async
(str "xprop -id " (window_xid)
" -f _NET_WM_WINDOW_OPACITY 32c"
" -set _NET_WM_WINDOW_OPACITY 0xf8000000")))
;; Example:
#!/bin/bash
# Watch files in the current working directory (or given argument)
# display how much a file has grown in the last second (or so)
# B9 2018
if [ -d "$1" ]; then
cd "$1"
shift
fi
@hackerb9
hackerb9 / nonraspbian
Created December 10, 2017 12:43
Find unofficial packages installed on a Raspberry Pi running Raspbian
#!/bin/sh
# nonraspbian -
#
# Find packages installed on my Pi which aren't from the official
# Raspberry Pi repositories.
aptitude search '?narrow(?installed,!?or(?origin("Raspberry Pi Foundation"),?origin("Raspbian")))'
@hackerb9
hackerb9 / duration.sh
Created December 9, 2017 11:37
Bourne shell functions to show informal English time spans
# Some handy informal duration functions in Bourne shell (bash is fine, too).
# duration(): given seconds, returns commonsense equivalent duration.
# ago(): given seconds from epoch, compares to current time.
# howlongago(): show how long ago a file or subdir was last modified.
# given a file, shows how long ago that file was updated.
# given a directory, recursively searches for most
# recently changed FILE (not directory)