Skip to content

Instantly share code, notes, and snippets.

View blakethepatton's full-sized avatar

Blake Patton blakethepatton

View GitHub Profile
@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 January 13, 2024 16:53
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.

@blakethepatton
blakethepatton / gist:2da1720f33dfd494042813603d9a854f
Last active July 1, 2018 07:09
Installing Ubuntu 18.04 on Razer Blade 2016 (GTX970m)
Just some notes I'm keeping for myself about my install that got things working - in case
I screw things up at some later point.
Get a drive with ubuntu installer image on it.
Run the check the drive utility to make sure things are all good before installing (You dealt
with a bad drive before, everythin looked good, but things didn't work perfect)
Install ubuntu via the second option, "install ubuntu" not through the try it first.
It crashed at the reboot part of the process