Skip to content

Instantly share code, notes, and snippets.

@ChrisDowning
ChrisDowning / slurm-aws-startup.sh
Created July 22, 2020 20:45
OpenHPC PEARC20 Slurm node startup script for a dynamic cluster (ARM nodes)
#!/bin/bash
export SLURM_HEADNODE_IPADDR=$(curl -sS http://169.254.169.254/latest/meta-data/local-ipv4)
export SLURM_HEADNODE_AWS_REGION=$(curl -sS http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.region')
export COMPUTE_SG=@COMPUTESG@
export COMPUTE_SUBNET_ID=@SUBNETID@
export AWS_DEFAULT_MAC=$(curl -sS http://169.254.169.254/latest/meta-data/mac)
export AWS_SECURITY=$(curl -sS http://169.254.169.254/latest/meta-data/network/interfaces/macs/$AWS_DEFAULT_MAC/security-group-ids)
export AWS_AMI=@COMPUTEAMI@
export AWS_KEYNAME=@KEYNAME@
@ChrisDowning
ChrisDowning / slurm-compute-userdata.sh
Last active February 21, 2022 09:22
OpenHPC PEARC20 Slurm node user-data for a dynamic cluster
#!/bin/bash -xe
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
sed -i "s|SELINUX=enforcing|SELINUX=permissive|g" /etc/selinux/config
setenforce 0
sleep 180
echo "192.168.0.100:/home /home nfs nfsvers=3,nodev,nosuid 0 0" >> /etc/fstab
echo "192.168.0.100:/opt/ohpc/pub /opt/ohpc/pub nfs nfsvers=3,nodev 0 0" >> /etc/fstab
mount -a
cp /home/.munge /etc/munge/munge.key
chown munge:munge /etc/munge/munge.key
@ChrisDowning
ChrisDowning / slurm-aws-shutdown.sh
Last active February 21, 2022 09:22
OpenHPC PEARC20 Slurm node shutdown script for a dynamic cluster
#!/bin/bash
export SLURM_ROOT=/etc/slurm
export CLUSTER_REGION=$(curl -sS http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.region')
export SLURM_POWER_LOG=$SLURM_ROOT/power_save.log
export PATH=$PATH:/usr/local/bin:/usr/bin
function aws_shutdown()
{
COMPUTE_INSTANCE=$(aws ec2 describe-instances \
@ChrisDowning
ChrisDowning / slurm.conf
Last active February 21, 2022 09:23
OpenHPC PEARC20 slurm.conf file for a dynamic cluster
ClusterName=pearc20
ControlMachine=ip-192-168-0-100
SlurmUser=slurm
SlurmctldPort=6817
SlurmdPort=6818
AuthType=auth/munge
StateSaveLocation=/var/spool/slurm/ctld
SlurmdSpoolDir=/var/spool/slurm/d
SwitchType=switch/none
@MMesch
MMesch / robust_splines_sklearn.py
Last active July 6, 2023 23:04
Robust Spline Regression with Scikit-Learn
#!/usr/bin/env python
"""
Robust B-Spline regression with scikit-learn
"""
import matplotlib.pyplot as plt
import numpy as np
import scipy.interpolate as si
from sklearn.base import TransformerMixin
from sklearn.pipeline import make_pipeline
@justmiles
justmiles / ipa.tf
Last active September 9, 2022 06:06
Deploy FreeIPA in AWS using Terraform
# Notes:
# You'll need to update any references to 'module.vpc' with your VPC's info (subnets, security groups, etc)
# If you define your subnets as a map, this will deploy different replicas across availabity zones. Note
# that the master and first replica will be in the same AZ.
#
# Look through the 'connection' fields and update with your bastion_host/key combos
#
# Number of IPA Replica(s) to deploy
variable "ipa_replicas" {

Interactive Machine Learning

Taught by Brad Knox at the MIT Media Lab in 2014. Course website. Lecture and visiting speaker notes.

@campagnola
campagnola / make_png.py
Last active August 19, 2022 04:13
Pure python PNG writer
import numpy as np
import zlib
import struct
def make_png(data):
"""
Convert numpy array to PNG byte array.
*data* must be (H, W, 4) with dtype=ubyte
"""
@jboner
jboner / latency.txt
Last active July 6, 2024 06:48
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@JoshuaEstes
JoshuaEstes / 000-Cheat-Sheets.md
Last active May 1, 2024 04:03
Developer Cheat Sheets for bash, git, gpg, irssi, mutt, tmux, and vim. See my dotfiles repository for extra info.