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 / 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
@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 / 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;
}
@aaronpeterson
aaronpeterson / disable get_adjacent_post
Last active June 12, 2018 19:04
get_adjacent_post buster for a wordpress custom post type.
<php
// in your constructor, etc
add_filter('get_previous_post_where', array($this, 'removePreviousPost'));
// have not tested this one but maybe?
add_filter('get_next_post_where', array($this, 'removePreviousPost'));
// kill with impossible sql
// @see https://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/link-template.php#L1173
public function removePreviousPost($where) {
@aaronpeterson
aaronpeterson / gist:6051292
Created July 22, 2013 04:33
An untested example of async.each to decorate a list of users.
// populate users with User.find, etc, then inside that callback:
var results = [];
async.each(users, function(user, cb) {
Foo.find({"user._id":user._id}, function(err, result) {
// note: return isn't returning anything valuable, it's just a shortcut to leave the function to avoid ugly } else {
if (err) return cb(err);
if (result === true) {
// whatever this is...
@aaronpeterson
aaronpeterson / mpnml
Created February 21, 2013 02:46 — forked from holms/mpnml
sudo port -v install mysql5-server
# Don't do any post-install instructions
sudo -u _mysql mysql_install_db5
# if above command produce this error: ERROR: 1004 Can't create file '/var/tmp/#sqle967_1_0.frm' (errno: 9)
# do this:
# sudo chown -R mysql:mysql /opt/local/var/db/mysql5
# sudo chmod u+rwx,go= /opt/local/var/db/mysql5
# sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql