Skip to content

Instantly share code, notes, and snippets.

@robmsmt
robmsmt / gcp-start-iap-tunnel-ssh-proxy-magic.sh
Created April 15, 2024 19:42 — forked from netj/gcp-start-iap-tunnel-ssh-proxy-magic.sh
a nifty script for accessing with native SSH your IAP allowed Compute Engine instances
#!/usr/bin/env bash
# ~/.ssh/gcp-start-iap-tunnel-ssh-proxy-magic.sh
# a script to be used as SSH ProxyCommand to allow fully functional SSH access to any Google Cloud Compute Engine VMs allowing IAP access
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2022-10-31
# See also:
# - https://gist.github.com/netj/df4f9de1fefd254ab11979be7035b5d0/#readme
# - https://cloud.google.com/iap/docs/using-tcp-forwarding
#
@robmsmt
robmsmt / make_swap_great_again.sh
Created January 20, 2023 21:01
make_swap_great_again.sh
#!/bin/bash
# this shell script can make a large swap quickly and put it on
set -x
set -e
if [ "$(id -u)" != 0 ]; then
echo "This script must be run with sudo."
exit 1
@robmsmt
robmsmt / harvard_sentences.py
Last active August 17, 2021 20:36
harvard_sentences
# http://www.cs.cmu.edu/afs/cs.cmu.edu/project/fgdata/OldFiles/Recorder.app/utterances/Type1/harvsents.txt
# taken from here ^ and pythonified
h1 = [
"The birch canoe slid on the smooth planks.",
"Glue the sheet to the dark blue background.",
"It's easy to tell the depth of a well.",
"These days a chicken leg is a rare dish.",
"Rice is often served in round bowls.",
@robmsmt
robmsmt / make_user_gen_ssh.sh
Last active April 11, 2024 04:47
make_user_gen_ssh.sh
#!/bin/bash
NEW_USER=$1
set -e
if [ -z "$NEW_USER" ];then
echo "Please provide user as arg... exiting."
exit 1
fi
#!/usr/bin/bash
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# You would have to create an xorg.conf file for your Nvidia setup #
# before using this script! It can be done by running: #
# #
# nvidia-xconfig -o /etc/X11/xorg.conf.nvidia #
# #
# Make sure your system has eGPU connected and a monitor plugged into the GPU. #
# The reason I've never automated this is that you have to have it all plugged #
[Unit]
Description=GPU Switcher
After=systemd-user-sessions.service plymouth-quit.service
Before=display-manager.service
[Service]
ExecStart=/usr/local/bin/autogpuswitch.sh
Restart=no
Type=oneshot
RemainAfterExit=yes
@robmsmt
robmsmt / keras_resnet_api.py
Created January 13, 2018 13:08
run this file and then send a POST request to 127.0.0.1:5000/predict/<WEB_URL_OF_IMG>
#!/usr/bin/env python
import numpy as np
import keras
import tensorflow as tf
from keras.applications import ResNet50
from keras.preprocessing import image as image_utils
from keras.applications.resnet50 import preprocess_input, decode_predictions
import requests
@robmsmt
robmsmt / latency.txt
Created January 31, 2017 15:44 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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