Skip to content

Instantly share code, notes, and snippets.

View HyperplaneOrg's full-sized avatar
💭
I may be slow to respond.

Andrew Michaelis HyperplaneOrg

💭
I may be slow to respond.
View GitHub Profile
@HyperplaneOrg
HyperplaneOrg / zshrc.sh
Created May 5, 2023 00:48
bash or zsh random passwd generator
function passwd_rand() {
LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./<=>?@[\]^_`{|}~' < /dev/urandom | head -c 18; echo""
}
@HyperplaneOrg
HyperplaneOrg / run-aide.sh
Created February 22, 2023 17:55
Simple aide with SNS script...
#/bin/bash
export OPS_SNS='arn:aws:sns:us-west-<n>:<acct>:<top-name>'
function init() {
aide --init
mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
}
function check() {
@HyperplaneOrg
HyperplaneOrg / recover_teams.sh
Created August 19, 2021 00:22
MS Teams (junk) constantly crashes on Mac; this script will reopen it as needed. Example Crontab "*/6 * * * * recover_teams.sh"
#!/bin/bash
pgrep "Microsoft Teams Helper" 1> /dev/null
if [ $? -eq 1 ]; then
open /Applications/Microsoft\ Teams.app
fi
@HyperplaneOrg
HyperplaneOrg / mp4_2_gif
Created June 17, 2021 17:39
mpeg4 to gif with palette
#!/bin/bash
RESCALE=720
FPS=8
if [ -z "$1" ]; then
echo "m2gif.sh <mp4>"
exit 1
fi
fin=$1
fgif="${fin%.*}.gif"
echo "ffmpeg -i $fin -vf \"fps=$FPS,scale=$RESCALE:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse\" -loop 0 $fgif"
@HyperplaneOrg
HyperplaneOrg / memflog.c
Created April 12, 2021 23:56
Flog memory across a set of nodes
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include <mpi.h>
#define DEFAULT_PERCT 80.0
@HyperplaneOrg
HyperplaneOrg / split_evenly.sh
Created February 12, 2021 01:21
Splits a file into an ~equal number of lines
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo "split_evenly.sh <file> <n>"
echo " Splits a file into an ~equal number of lines"
exit 1
fi
num_files=$2
fname=$1
total_lines=$(wc -l <$fname)
((lines_per_file = (total_lines + num_files - 1) / num_files))
@HyperplaneOrg
HyperplaneOrg / rmfillval.py
Created November 25, 2020 15:56
Removes the '_FillValue' attr for a select set of sds's
#!/usr/bin/env python
# Description: Removes the '_FillValue' attr for a select set of sds's
import sys
import logging
from pyhdf.HDF import HDF, HDF4Error, HC
from pyhdf.V import *
#--------------------------------------------------------------------------------
@HyperplaneOrg
HyperplaneOrg / encrypt.sh
Created September 16, 2020 04:49
Encrypt and base64 encode a file
#!/bin/bash
if [ -z "$1" ]; then
echo "encrypt.sh <file> [ bin ]"
echo "If the bin option is given the base64 encoding is not done."
exit 1
fi
FL=$1
if [ -z "$2" ]; then
openssl enc -aes-256-ctr -salt -in $FL | base64 -i - > $FL.aes.b64
else
@HyperplaneOrg
HyperplaneOrg / decrypt.sh
Created September 16, 2020 04:48
Decrypt a file that was encrpyted with openssl and base64 encoded
#!/bin/bash
if [ -z "$1" ]; then
echo "decrypt.sh <file> [ <fileout> ]"
exit 1
fi
FL=$1
isb64="${FL##*.}"
if [ ! -z "$2" ]; then
FLO=$2
#!/bin/sh
# A wrapper script around mysqld_safe, which starts the MySQL daemon and
# may restart it if it dies unexpectedly. See module help for more info.
MYROOT=/modules/mysql/5.6.49/mysql-5.6.49-linux-glibc2.12-x86_64
BASE_STORE=/nobackup/$USER/mysql
BASE_STORE_DATA=/nobackup/$USER/mysql/data
LOG_STORE=/nobackup/$USER/mysql/log/mysqld.logs