Skip to content

Instantly share code, notes, and snippets.

@aaronpeterson
aaronpeterson / README.md
Last active May 20, 2023 00:13
Vultr bash script to attach Block Storage to mysql on ubuntu

Vultr Block Storage for MySQL

datadir + tmpdir on Ubuntu 22.04 LTS

I had a somewhat ephemeral use-case for mysql server but due to some heavy indexes (and tmp dir usage) the disk kept running out of room on smallish instances.

How to run

  • Create your Block Storage and Vultr instance in the same region
  • Under Block Storage settings, "attach" to your instance.
@aaronpeterson
aaronpeterson / wpa_supplicant-mesh-problem.md
Last active December 18, 2022 22:22
NetworkManager problems and how wpa_supplicant is fundamentally broken; mesh network bug tracking

wpa_supplicant Mesh Problem Reference

This is a living document to track the failure of wpa_supplicant.

"NetworkManager switches to the worse one of two APs all the time"

Thanks, so I've looked into this now, and it indeed some to be an issue with wpa_supplicant: In its decision logic whether to roam between APs it basically uses estimated bandwith as first priority (https://w1.fi/cgit/hostap/tree/wpa_supplicant/events.c#n1927), so if another AP can do ht40 while the current one only has ht20, it will switch to the other one while (pretty much) ignoring how bad the signal quality is. ref

@aaronpeterson
aaronpeterson / bitmagic-the-freewheelin-bitmiser.js
Last active December 18, 2022 00:24
Javascript bitf*ckery because I hate bits and reading data sheets for i2c stuffs and I'm also jealous of python etc
// console.log(bitmagic("b[1010]d[3,2]h[02,2]"));
// console.log(bitmagic("b[10]d[1,2]h[0A]"));
/**
* Bitmagic the Freewheelin' bitmiser
*
* Use any combination of bits, numbers or hex and output a nice-lookin' byte
*
* Usage: b[binary]d[decimal,padding?]h[hex,padding?]
*
@aaronpeterson
aaronpeterson / extract-root-domain-from-hostname.js
Created October 8, 2020 04:18
Get domain name without subdomains using JavaScript? -- Simple solution?
/**
* Was "Get domain name without subdomains using JavaScript?" on StackOverflow
* https://stackoverflow.com/questions/9752963/get-domain-name-without-subdomains-using-javascript
*/
const tests = {
'www.sidanmor.com': 'sidanmor.com',
'exemple.com': 'exemple.com',
'argos.co.uk': 'argos.co.uk',
'www.civilwar.museum': 'civilwar.museum',
@aaronpeterson
aaronpeterson / slow-down-ya-bishhhhh.js
Last active October 3, 2019 05:28
AWS node.js recursion for 503 SlowDown handling
/**
* An improvement to this would be linear or eponential increase of wait ms
* with a threshold to give up...
*
*/
async function getTaggings(bucket, key, wait) {
let params = {
Bucket: bucket,
Key: key
};
@aaronpeterson
aaronpeterson / mariadb-columnstore-centos7
Last active January 6, 2020 14:13
Installing MariaDb ColumnStore on Cent OS 7
# Couldn't get this running on any Ubuntu instances.
# Today I used AWS CentOS Linux 7 x86_64 HVM EBS 1602-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d7e1d2bd.3 (ami-6d1c2007)
# install dependencies
sudo yum install perl perl-DBI expect wget nano
# download binaries for centos 7
wget https://downloads.mariadb.com/enterprise/htxx-hpee/mariadb-columnstore/1.0.0/mariadb-columnstore-1.0.0-centos7.x86_64.rpm.tar.gz
# extract
// main.m
// creategif
//
// Created by Kevin Meaney on 21/10/2013.
// I've briefly blogged about it here:
// http://blog.yvs.eu.com/2013/10/creating-gif-animations-using-coreimagequartz
// The following code is all that is all the code needed for a creating a command line tool to generate
// a gif animation from image files.
// The main limitation with this code is that apart from the frame delay time of 0.1 second, every
@aaronpeterson
aaronpeterson / MySQL-to-angularjs-datetime
Created July 4, 2014 16:07
Part of my AngularJS datetime service to smooth out working with mysql datetime format in javascript
var when = {
/**
* Convert Dateish to js Date
* @param mixed string|Date dateish date-like string for Date constructor
* @return Date js Date or null
*/
its: function(dateish) {
if (!dateish) {
return null;
}
var objectToQueryString = function (a) {
var prefix, s, add, name, r20, output;
s = [];
r20 = /%20/g;
add = function (key, value) {
// If value is a function, invoke it and return its value
value = ( typeof value == 'function' ) ? value() : ( value == null ? "" : value );
s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
};
if (a instanceof Array) {
@aaronpeterson
aaronpeterson / DeepValueReaderSketch.php
Last active August 29, 2015 13:57
Read dot or php style input notation in any object at any depth.
<?php
$data = array(
'namespace' => array(
'foo' => array(
'bar' => 'You found me!'
)
)
);