Skip to content

Instantly share code, notes, and snippets.

View pangyuteng's full-sized avatar

pangyuteng

View GitHub Profile
@alexlib
alexlib / README.md
Created August 27, 2020 13:58 — forked from amroamroamro/README.md
[Python] Fitting plane/surface to a set of data points

Python version of the MATLAB code in this Stack Overflow post: http://stackoverflow.com/a/18648210/97160

The example shows how to determine the best-fit plane/surface (1st or higher order polynomial) over a set of three-dimensional points.

Implemented in Python + NumPy + SciPy + matplotlib.

quadratic_surface

@hungyiwu
hungyiwu / install_SimpleElastix.sh
Last active February 25, 2021 20:49
Install SimpleElastix with Python3 on the O2 server at Harvard Medical School
#!/bin/bash
#SBATCH --job-name=installSE
#SBATCH -c 4 # Number of cores
#SBATCH -t 0-03 # Runtime in D-HH:MM, minimum of 10 minutes
#SBATCH -p short # Partition to submit to, whichever is faster
#SBATCH --mem-per-cpu=4G # Memory (see also --mem)
#SBATCH -o joboutput.out # job output
#SBATCH -e joberrors.err # job error log
# load modules
@matt-peters
matt-peters / pytorch_tensorflow.py
Created June 15, 2020 18:02
Pytorch + tensorflow running together in the same computational graph
"""
An example of running both pytorch and tensorflow in the same network,
while pasing weights and gradients between the two.
In this example, we run a simple 2-layer feed-forward network,
with the first layer size (5, 2) and the second (2, 3).
The code contains an implementation of forward/backward passes with
three versions:
* tensorflow only
* pytorch only
@sorny
sorny / x11_forwarding_macos_docker.md
Last active June 2, 2025 10:00
X11 forwarding with macOS and Docker

X11 forwarding on macOS and docker

A quick guide on how to setup X11 forwarding on macOS when using docker containers requiring a DISPLAY. Works on both Intel and M1 macs!

This guide was tested on:

  • macOS Catalina 10.15.4
  • docker desktop 2.2.0.5 (43884) - stable release
  • XQuartz 2.7.11 (xorg-server 1.18.4)
  • Macbook Pro (Intel)
@soulmachine
soulmachine / nfs-proxmox.md
Last active May 3, 2025 05:24
Launch a NFS server on Proxmox

Method 1: NFS server on LXC container

Create a priviledged LXC container with:

mount=nfs,nesting=1

apt update

apt install nfs-kernel-server

@wshihadeh
wshihadeh / nginx-docker-compose.yml
Created April 6, 2020 17:19
Nginx Zero Down time
version: '3.7'
networks:
nginx:
external: false
services:
# --- NGINX ---
nginx:
@haampie
haampie / Dockerfile
Created January 24, 2020 10:16
Build some Qt modules with AddressSanitizer
FROM ubuntu:18.04 AS builder
SHELL ["/bin/bash", "-c"]
WORKDIR /development
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential \
curl \
file \
@MartinNowak
MartinNowak / convert_saved_model.py
Created November 28, 2019 16:17
Convert TF saved model from protobuf binary to text format
import os, sys
import google.protobuf
from tensorflow.core.protobuf import saved_model_pb2
import tensorflow as tf
def convert_saved_model_to_pbtxt(path):
saved_model = saved_model_pb2.SavedModel()
with open(os.path.join(path, 'saved_model.pb'), 'rb') as f:
@nealfennimore
nealfennimore / wireguard.conf
Last active January 29, 2025 10:57
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown

Windows 10 - Using Git Bash With TMUX

Why Not Use WSL?

I tried the WSL and it isn't quite seamless enough for me. I ran in to problems when editing in VSCode and having watchers on my files (ng serve, dotnet watch run, etc.). In addition, I kept running in to problems that only manifest themselves when running in WSL. For example, this issue with doing production builds and the terser plugin has made many a developer rage-quit on using WSL. Just figuring out that it was an issue with the WSL took a lot of time.

That terser plugin issue was never resolved and I ended up having to keep a git bash window open in addition to my WSL console window so I could do production builds. To make matters worse, my npm packages were platform-dependent so I couldn't use the same project folder. So, my procedure was: commit whatever changes to test branch, push to repo, git pull on my "windows" project folder, and do a production build there