Skip to content

Instantly share code, notes, and snippets.

View yuhangwang's full-sized avatar

StevenW yuhangwang

View GitHub Profile
@yuhangwang
yuhangwang / torch_func_opt_example.py
Created December 10, 2023 10:14 — forked from madagra/torch_func_opt_example.py
Fitting a function with functional PyTorch
import numpy as np
import torch
from torch import nn
from torch import Tensor
from torch.func import functional_call
import torchopt
import matplotlib.pyplot as plt
class SimpleNN(nn.Module):
@yuhangwang
yuhangwang / entry.sh
Created July 12, 2022 03:35 — forked from xkortex/entry.sh
dockerfile entrypoint for activating conda environment
#!/bin/bash
## Entrypoint for docker RUN directives as well as ENTRYPOINT with conda env
## Enable by adding:
## COPY entry.sh ./
## SHELL ["/entry.sh", "/bin/bash", "-c"]
##
## Optionally, set the following env to select a conda env to run in
## ENV CONDA_DEFAULT_ENV=foo
## You may also want to add something like
## RUN conda init bash && echo 'conda activate "${CONDA_TARGET_ENV:-base}"' >> ~/.bashrc
@yuhangwang
yuhangwang / rst_to_md.sh
Created March 16, 2022 07:54 — forked from zaiste/rst_to_md.sh
Convert RST to Markdown using Pandoc
FILES=*.rst
for f in $FILES
do
filename="${f%.*}"
echo "Converting $f to $filename.md"
`pandoc $f -f rst -t markdown -o $filename.md`
done
@yuhangwang
yuhangwang / Install_tmux
Created August 14, 2021 03:18 — forked from simme/Install_tmux
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@yuhangwang
yuhangwang / conf_gen.py
Created June 11, 2020 19:39 — forked from tdudgeon/conf_gen.py
Conformer generation using RDKit
import sys
from rdkit import Chem
from rdkit.Chem import AllChem, TorsionFingerprints
from rdkit.ML.Cluster import Butina
def gen_conformers(mol, numConfs=100, maxAttempts=1000, pruneRmsThresh=0.1, useExpTorsionAnglePrefs=True, useBasicKnowledge=True, enforceChirality=True):
ids = AllChem.EmbedMultipleConfs(mol, numConfs=numConfs, maxAttempts=maxAttempts, pruneRmsThresh=pruneRmsThresh, useExpTorsionAnglePrefs=useExpTorsionAnglePrefs, useBasicKnowledge=useBasicKnowledge, enforceChirality=enforceChirality, numThreads=0)
return list(ids)
@yuhangwang
yuhangwang / mylib.c
Created April 19, 2018 16:56 — forked from yangle/mylib.c
ctypes examples
// gcc -std=c99 -O3 -fPIC -shared -Wl,-soname,mylib -o mylib.so mylib.c
#include <stdio.h>
#include <complex.h>
int build_hamiltonian(int i, double d, complex double *m)
{
m[0]=2.*I;
return 0;
}
@yuhangwang
yuhangwang / mylib.c
Created April 19, 2018 16:56 — forked from yangle/mylib.c
ctypes examples
// gcc -std=c99 -O3 -fPIC -shared -Wl,-soname,mylib -o mylib.so mylib.c
#include <stdio.h>
#include <complex.h>
int build_hamiltonian(int i, double d, complex double *m)
{
m[0]=2.*I;
return 0;
}
@yuhangwang
yuhangwang / mylib.c
Created April 19, 2018 16:56 — forked from yangle/mylib.c
ctypes examples
// gcc -std=c99 -O3 -fPIC -shared -Wl,-soname,mylib -o mylib.so mylib.c
#include <stdio.h>
#include <complex.h>
int build_hamiltonian(int i, double d, complex double *m)
{
m[0]=2.*I;
return 0;
}
@yuhangwang
yuhangwang / go_functional.go
Created May 12, 2017 14:49 — forked from jakecoffman/go_functional.go
Example of functional programming in Golang.
package main
import "fmt"
func main() {
sum := Sum(1, 2, 3, 4)
fmt.Println(sum)
}
type any interface{}
@yuhangwang
yuhangwang / README.md
Created January 25, 2017 22:40 — forked from DavidEGrayson/README.md
Getting started with midipix