Skip to content

Instantly share code, notes, and snippets.

View blakethepatton's full-sized avatar

Blake Patton blakethepatton

View GitHub Profile
local tsa = require 'tsa'
local kumo = require 'kumo'
kumo.on('tsa_init', function()
tsa.start_http_listener {
listen = '0.0.0.0:8008',
trusted_hosts = { '127.0.0.1', '::1', '0.0.0.0', '0.0.0.0/0' },
}
end)
@blakethepatton
blakethepatton / gcd.py
Last active March 14, 2022 18:48
Numworks
def gcd(a,b):
while (b>0):
r=a%b
a,b=b,r
return a
@blakethepatton
blakethepatton / lvm-expand.md
Last active February 19, 2022 16:58
Live expand disk ubuntu and esx

Expand the disk in esx

Take a snapshot

sudo su

make it look for the bigger disks

echo "1" > /sys/class/scsi_disk/{your device here}/device/rescan

@blakethepatton
blakethepatton / a install.md
Last active April 6, 2025 07:04
Cyberpower UPS -> Grafana

Stuff for setting up grafana monitoring of cyberpower ups

done on ubuntu 20.04

Install influx

wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor > /etc/apt/trusted.gpg.d/influxdb.gpg
export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc)
@blakethepatton
blakethepatton / non-lvm.md
Last active November 26, 2020 18:14
Live expand disk ubuntu and esx

Expand the disk in esx

Take a snapshot

Refresh disk size

echo 1>/sys/class/block/sda/device/rescan

if you fdisk /dev/sda you should get an error like GPT PMBR size mismatch (2147483647 != 4294967295) will be corrected by w(rite).

@blakethepatton
blakethepatton / readme.md
Created May 19, 2020 01:59
Asciinema timelapse

pip3 install in_place

input cast goes in input.cast, this file is overwritten update the factor variable to increase the timelapse speed.

python3 script.py

@blakethepatton
blakethepatton / userHasPermission.php
Last active September 4, 2018 16:44
laravel hasPermission
// credit to wheredidgogogo
// https://laracasts.com/discuss/channels/eloquent/hasmanythrough-with-two-pivot-tables
public function hasPermission($permission_name)
{
$result = \DB::table('users')
->join('role_user','users.id','=','role_user.user_id')
->join('roles','role_user.role_id','=','roles.id')
->join('permission_role','roles.id','=','permission_role.role_id')
->join('permissions','permission_role.permission_id','=','permissions.id')
->select('permissions.*')->where('users.id','=',\Auth::user()->id)->where('permissions.name','=',$permission_name)->count();
<?php
$q = (isset($_REQUEST['q'])) ? $_REQUEST['q'] : '';
$records = dns_get_record("{$q}.domainname.tld", DNS_TXT);
$return = [];
if($records===false)exit( "Nope. ") ;
foreach($records as $record){
$arr = explode(':', $record['txt'], 2);
if(preg_match("/:/", $record['txt'])==true && is_numeric($arr[0])){
$return[$arr[0]] = $arr[1];
} else {
@blakethepatton
blakethepatton / Description.md
Last active November 7, 2023 09:37
Getting Mailhog running on a dev server (nginx, letsencrypt, ssl, ubuntu)

Get it running as a service

wget https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64

mv MailHog_linux_amd64 mailhog

chmod +x mailhog

sudo vi /etc/systemd/system/mailhog.service

@blakethepatton
blakethepatton / readme.md
Last active July 5, 2018 20:00
A simple script that downloads and installs phpMyAdmin in its root location

I really don't recommend using this in production environments. There are potential issues with this script that could cause some damage.