Skip to content

Instantly share code, notes, and snippets.

View jmarhee's full-sized avatar

jdm jmarhee

View GitHub Profile
@jmarhee
jmarhee / go.mod
Created April 9, 2023 05:25
Generate UUIDs in Go.
module uuid-generator
go 1.16
require github.com/google/uuid v1.2.0
@jmarhee
jmarhee / Cargo.toml
Created April 9, 2023 05:20
Delete all Kubernetes Pods in a specific namespace older than a user-specified number of hours. (i.e. all Pods in namespace "app-time-limited" older than 1 hour)
[dependencies]
kube = "0.64.0"
k8s-openapi = "0.12.0"
@jmarhee
jmarhee / post.py
Created March 22, 2023 20:59
Dump directory of video files to screenshots, script to randomly select a screenshot and post to Twitter.
import tweepy
import os, random
def main():
twitter_auth_keys = {
"consumer_key" : os.environ['CONSUMER_KEY'],
"consumer_secret" : os.environ['CONSUMER_SECRET'],
"access_token" : os.environ['ACCESS_TOKEN'],
#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

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:

@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
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 / 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
@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
#!/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
}