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

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: unpack <pathto file> <workdir>
set -e
archive=$1
workdir=$2
filename=$(basename "$1")
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',
@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%'
#include "mach_gettime.h"
#include <mach/mach_time.h>
#define MT_NANO (+1.0E-9)
#define MT_GIGA UINT64_C(1000000000)
// TODO create a list of timers,
static double mt_timebase = 0.0;
static uint64_t mt_timestart = 0;
@warmwaffles
warmwaffles / pgcat.c
Created February 12, 2018 18:01
Take a PGCOPY binary in via stdin and output via stdout
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <arpa/inet.h>
typedef struct buffer
{
uint32_t length;
uint32_t capacity;
@warmwaffles
warmwaffles / stopwatch.rb
Last active March 29, 2018 21:15
Quick stopwatch to do some basic timings in ruby
#
# A simple stop watch for a quick timer to check app performance
#
# @see https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/
#
# @example Basic Usage
# timer = Stopwatch.new
# timer.start #=> 59539.814152996
# timer.stop #=> 59544.700881683
# timer.elapsed #=> 4.886728687000868
#version 330 core
in vec2 v_texcoord;
in vec4 v_color;
uniform sampler2D u_tex;
uniform mat4 u_combined;
out vec4 f_color;
@warmwaffles
warmwaffles / GeodesicSphere.js
Created April 18, 2018 04:14 — forked from Inscrutabilis/GeodesicSphere.js
Three.js geodesic sphere primitive class
/**
* @author Inscrutabilis / mailto:[email protected]
*/
/*
* Generates a geodesic sphere geometry
* By default, it is 1x1x1 octahedron, as a first approximation to sphere
* It will return more sphere-like object if you specify iterations > 0
* But please keep in mind that it generates (4 ^ iterations) * 8 faces
* Radius argument overrides default sphere radius (1)

I do know that it’s really easy to convert them into an ISO file, and then mount the ISO in debian based linux.

sudo apt-get install bchunk

The syntax from bchunk is as follows:

bchunk [-v] [-p] [-r] [-w] [-s]