Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Suo danielsuo

View GitHub Profile
@danielsuo
danielsuo / install.sh
Created Apr 15, 2021
Installing gem5 on Ubuntu
View install.sh
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
@danielsuo
danielsuo / AutoCrop.lua
Created Jan 20, 2021 — forked from stecman/AutoCrop.lua
Lightroom plugin to calculate image crops using OpenCV
View AutoCrop.lua
-- LR imports
local LrApplication = import("LrApplication")
local LrApplicationView = import("LrApplicationView")
local LrBinding = import("LrBinding")
local LrDevelopController = import("LrDevelopController")
local LrDialogs = import("LrDialogs")
local LrExportSession = import("LrExportSession")
local LrFileUtils = import("LrFileUtils")
local LrFunctionContext = import("LrFunctionContext")
local LrLogger = import("LrLogger")
@danielsuo
danielsuo / install_mujoco_macos.sh
Created Dec 18, 2020
Install mujoco, mujoco py, derivs on macOS
View install_mujoco_macos.sh
#!/usr/bin/env bash
# Assume:
# - mjkey.txt is in directory $MJKEYDIR
# - We have homebrew, xcode command-line toolsd
# Install MuJoCo
mkdir -p $HOME/.mujoco
wget https://www.roboti.us/download/mujoco200_macos.zip
unzip mujoco200_macos.zip -d $HOME/.mujoco
@danielsuo
danielsuo / install_mujoco.sh
Last active Dec 18, 2020
Install mujoco, mujoco_py, mujoco_py_derivs
View install_mujoco.sh
#!/usr/bin/env bash
# Assume:
# - mjkey.txt is in directory $MJKEYDIR
# Install MuJoCo
mkdir -p $HOME/.mujoco
wget https://www.roboti.us/download/mujoco200_linux.zip
unzip mujoco200_linux.zip -d $HOME/.mujoco
mv $HOME/.mujoco/mujoco200_linux $HOME/.mujoco/mujoco200
View install_jax_rpi.sh
#!/usr/bin/env bash
# Install jaxlib
sudo apt install g++ python3 python3-pip python python3-dev
pip install numpy scipy six wheel
BAZEL_VERSION=3.7.1
BAZEL_EXECUTABLE=bazel-$BAZEL_VERSION-linux-arm64
wget https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/$BAZEL_EXECUTABLE
chmod +x $BAZEL_EXECUTABLE
View vote_fox.py
import bs4
import requests
import pandas as pd
def scrape(state):
soup = bs4.BeautifulSoup(requests.get(f"https://www.foxnews.com/elections/2020/general-results/state/{state}").content.decode("utf-8"))
section = soup.find_all("section", class_="is-president")[0]
section = section.find_all("div", class_="race-table")[0]
tables = section.find_all("table")
View nyt_vote.py
"""
Predicts final votes by taking current votes, % counted, and current margin.
Two pro-Trump biases:
1. Does not factor in mail-in bias
2. We strip off the ">" in ">98%". Many more of the small counties (which are R) have reported
"""
import bs4
import requests
View wilhelm.diff
diff --git a/wilhelm/control/eastman.py b/wilhelm/control/eastman.py
index a3d1ade..1defdbb 100644
--- a/wilhelm/control/eastman.py
+++ b/wilhelm/control/eastman.py
@@ -27,13 +27,23 @@ grad_loss = jax.grad(counterfact_loss, (0, 1))
def rolls_by_eastman(env_true, env_sim, U_old, k, K, X_old, D, F, alpha, w_is):
- H, M, lr, C = 3, 3, 0.001, 1.
+ H, M, lr, C = 3, 3, 0.1, 1.
View pid.diff
diff --git a/vent/controller/control_module.py b/vent/controller/control_module.py
index 3a7b724..ff819f3 100644
--- a/vent/controller/control_module.py
+++ b/vent/controller/control_module.py
@@ -610,17 +610,18 @@ class ControlModuleBase:
self._DATA_VOLUME += dt * self._DATA_Qout # Integrate what has happened within the last few seconds from flow out
self._DATA_PRESSURE = np.mean(self._DATA_PRESSURE_LIST)
+ self.__control_signal_in = self._adaptivecontroller.feed(self._DATA_PRESSURE, now)
+
View pid.diff
diff --git a/vent/controller/control_module.py b/vent/controller/control_module.py
index 3a7b724..ff819f3 100644
--- a/vent/controller/control_module.py
+++ b/vent/controller/control_module.py
@@ -610,17 +610,18 @@ class ControlModuleBase:
self._DATA_VOLUME += dt * self._DATA_Qout # Integrate what has happened within the last few seconds from flow out
self._DATA_PRESSURE = np.mean(self._DATA_PRESSURE_LIST)
+ self.__control_signal_in = self._adaptivecontroller.feed(self._DATA_PRESSURE, now)
+