Skip to content

Instantly share code, notes, and snippets.

View warmwaffles's full-sized avatar
🛠️
Code Wrestling

Matthew Johnston warmwaffles

🛠️
Code Wrestling
View GitHub Profile
@warmwaffles
warmwaffles / postgres_queries_and_commands.sql
Created January 18, 2018 21:06 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
HOSTNAME = %x{hostname}.chomp
PROM_FILE = ARGV[0] != 'test' ? '/var/lib/node_exporter/textfile_collector/smartctl.prom' : '/tmp/smartctl.prom'
DEVICES = [
'/dev/sda',
'/dev/sdb',
'/dev/sdc',
'/dev/sdd',
'/dev/sde',
#!/bin/bash
# Usage: unpack <pathto file> <workdir>
set -e
archive=$1
workdir=$2
filename=$(basename "$1")

btrfs For Beginners

I wanted to retain the original page contents just in case it went down or changed.

Taken from https://www.howtoforge.com/a-beginners-guide-to-btrfs.

This guide shows how to work with the btrfs file system on Linux. It covers creating and mounting btrfs file systems, resizing btrfs file systems online, adding and removing devices, changing RAID levels, creating subvolumes and

#!/bin/bash
# Usage:
#
# yt-archive.sh <url to playlists>
#
youtube-dl \
--continue \
--retries 100 \
fn get_id(req: &mut Request) -> Option<Uuid> {
let param = req.extensions.get::<Router>().unwrap().find("id");
match param {
Some(x) => Some(Uuid::parse_str(param.unwrap()).unwrap()),
None => None
}
}
@warmwaffles
warmwaffles / rbp.c
Last active December 30, 2016 04:10
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <tbx/types.h>
#include <rbp.h>
struct mat4f
gfx_camera_get_combined(struct gfx_camera* camera)
{
assert(camera);
struct mat4f ortho;
struct mat4f translation;
struct mat4f zoom;
float vw = camera->viewport.width;