Skip to content

Instantly share code, notes, and snippets.

View deanturpin's full-sized avatar
:octocat:

Dean Turpin deanturpin

:octocat:
View GitHub Profile
@deanturpin
deanturpin / cpu-prompt.sh
Last active August 6, 2019 19:11
CPU load in your bash prompt - source this script
cpu-status-string(){
# Create some colours
idle="\u001b[32m"
low="\u001b[36m"
medium="\u001b[33m"
high="\u001b[31m"
reset="\u001b[0m"
# Extract CPU info from top
@deanturpin
deanturpin / PS1
Last active November 11, 2021 00:06
Exploring the bash prompt
#!/bin/bash
# GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
# Some of these are a little tongue-in-cheek as an unresponsive prompt would be
# an annoying distraction. But still. This file should be sourcable to ensure
# individual commands can be pasted straight into the terminal.
# Uptime
PS1='$(
@deanturpin
deanturpin / newline-chomp
Last active June 14, 2019 08:57
Ways to chomp a newline in bash
head -c -1
tr "\n" " "
echo -n $(<command>)
xargs echo -n
[[ $(<command>) =~ <regex> ]] && echo -n $BASH_REMATCH
# Garmin
https://connect.garmin.com/modern/proxy/download-service/files/wellness/2019-06-13
# Cryptocurrencies
https://min-api.cryptocompare.com/data/histominute?fsym=ZRX&tsym=USD&limit=1999
@deanturpin
deanturpin / read-wav.sh
Created June 17, 2019 10:29
Extracting and plotting a WAV in bash
#!/bin/bash
[[ $# == 1 ]] && count=$1 || count=750
# Fetch some samples
nibbles=8
readarray samples < <(xxd -cols $nibbles -plain -s 42 -len $(( nibbles * count )))
# Loop through samples
i=0
# Create Google Cloud instance using Ubuntu 16 LTS
# Tick Allow HTTP traffic and Allow HTTPS traffic
# Launch SSH web browser
# Paste the following
# Just agree to stuff and have a root password ready
# Based on this
# https://www.tecmint.com/install-wordpress-on-ubuntu-16-04-with-lamp/
sudo apt update && \
#include <iostream>
#include <vector>
struct fax {
~fax() {
static size_t i = 0;
std::cout << ++i << " dtor\n";
}
};
Technology Gigabits/s Category
USB 1.1 0.012 Peripheral
ADSL2+ 0.024 Broadband
HSPA+ 0.042 Mobile
Bluetooth 5.0 0.05 Wireless
LTE 0.173 Mobile
DOCSIS 3.0 (Virgin fibre) 0.216 Broadband
VME64 32-64bit 0.4 Bus
USB 2.0 0.48 Peripheral
1 Gb Ethernet 1 LAN
const std::map<double, std::string> notes{
// Catch all for lower bound search
{0.0, "Bx"},
// All the notes we're interested in. At the low end a single Fourier bin
// will map to multiple notes. Further up multiple bins will be assigned
// the same note.
{16.35, "C0"},
{17.32, "C#0"},
```bash
sudo ufw enable
sudo ufw allow 8080
sudo ufw status
```