Skip to content

Instantly share code, notes, and snippets.

View jmarhee's full-sized avatar

Joseph D. Marhee jmarhee

View GitHub Profile
@jmarhee
jmarhee / README.md
Created February 7, 2021 07:34 — forked from ctsrc/README.md
How to run FreeBSD 13.0-BETA1 for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)
@jmarhee
jmarhee / container_prune.py
Created February 15, 2021 01:19
Terminates containers running longer than an float-value number of hours.
from datetime import datetime
import os
import docker
import dateparser
STARTING_TIME = str(datetime.now()).split(" ")[0]+ "T" + str(datetime.now()).split(" ")[1] + "Z"
if os.environ.get('LIMIT_HOURS') is None:
LIMIT_HOURS = 2.0
else:
@jmarhee
jmarhee / overlay.sh
Created March 26, 2021 07:52
Overlays all videos in a directory on top of each other.
#!/bin/bash
i=0
while read line
do
array[ $i ]="$line"
(( i++ ))
done < <(ls)
# Creates the base overlay.mkv file
#!/bin/bash
function new_password () {
if [ ! -z $1 ]; then
length=$1
else
length=20
fi
curl -s "https://www.random.org/passwords/?num=1&len=$length&format=plain&rnd=new" | pbcopy
}
@jmarhee
jmarhee / resetRemoteManagement.sh
Created July 30, 2021 01:16
When Remote Desktop'd to a Mac, after switching Remote Management to only your user, you will be disconnected. Run this script to restore RDP access to your account.
#!/bin/bash
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -users $1 -privs -all -restart -agent -menu
@jmarhee
jmarhee / README.md
Created October 25, 2021 16:32 — forked from superseb/README.md
Retrieve kubeconfig from RKE or Rancher 2 custom cluster controlplane node for RKE v0.2.x and Rancher v2.2.x

Retrieve kubeconfig from RKE v0.2.x or Rancher v2.2.x custom cluster controlplane node

For RKE v0.1.x and Rancher v2.0.x/v2.1.x, see https://gist.github.com/superseb/3d8de6092ebc4b1581185197583f472a

This needs to be run on a node with the controlplane role, as it rewrites the server endpoint to https://127.0.0.1:6443, you can of course manually change this if necessary.

Applicable for:

  • RKE v0.2.x
  • Rancher v2.2.x
from plexapi.myplex import MyPlexAccount
import os
plex_auth_info = {
"username" : os.environ['PLEX_USERNAME'],
"password" : os.environ['PLEX_PASSWORD'],
"server" : os.environ['PLEX_SERVER_NAME']
}
account = MyPlexAccount(plex_auth_info['username'], plex_auth_info['password'])
@jmarhee
jmarhee / canal-k3s-auto.sh
Last active January 4, 2022 22:27
[Installing Canal](https://projectcalico.docs.tigera.io/getting-started/kubernetes/flannel/flannel) requires updating a `CALICO_IPV4POOL_CIDR` environment variable in the installation manifest for use with K3s, which has a default Pod CIDR of "10.44.0.0/24"-- this will modify the manifest to reflect the current Pod CIDR.
## Applies the modified manifest to K3s, which automatically applies the contents of /var/lib/rancher/k3s/server/manifests
curl -s https://docs.projectcalico.org/manifests/canal.yaml | sed -e 's| # - name: CALICO_IPV4POOL_CIDR| - name: CALICO_IPV4POOL_CIDR|g' -e "s| # value: \"192.168.0.0/16\"| value: \"$(kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}')\"|g" | \
tee -a /var/lib/rancher/k3s/server/manifests/canal.yaml

NashPy Quickstart for Python Programmers

nashpy is a Python library for computing equilibria in game theory. It provides tools for computing Nash equilibria, correlated equilibria, and other solution concepts in both cooperative and non-cooperative games.

This quickstart document will cover the basics of using nashpy to solve simple two-player games.

Installation

To install nashpy, you can use pip:

#include <stdio.h>
// The payoffs for each player in the game
int player1_payoff[2][2] = {{3, 0}, {5, 1}};
int player2_payoff[2][2] = {{3, 5}, {0, 1}};
// Function to calculate the Nash equilibrium
void calculate_nash_equilibrium() {
int row, col;
// Find the maximum payoff for player 1 in each row