Skip to content

Instantly share code, notes, and snippets.

View pangyuteng's full-sized avatar

pangyuteng

View GitHub Profile
@pangyuteng
pangyuteng / AsyncNotify.py
Created May 11, 2017 15:39 — forked from pfote/AsyncNotify.py
postgres LISTEN/NOTIFY psycopg2/twisted
import psycopg2
import psycopg2.extensions
from select import select
from twisted.internet import threads
class AsyncNotify():
"""
based on http://divillo.com/, adapted to newer psycopg version
Class to trigger a function via PostgreSQL NOTIFY messages.
@pangyuteng
pangyuteng / cancel.py
Last active June 17, 2022 17:14
async demo of workers being paused and resumed to consume jobs from queue with Celery, Rabbitmq, os Windows.
#cancel consuming from queue
import traceback
from foo import app
import celery
ds = []
activate =app.control.inspect().active()
while activate is None:
activate =app.control.inspect().active()
@pangyuteng
pangyuteng / example_keras.py
Created January 20, 2018 05:24
starter code for numerai with keras
#!/usr/bin/env python
import os
os.environ['CUDA_VISIBLE_DEVICES'] = ''
import pandas as pd
import numpy as np
from keras import optimizers
from keras.utils import to_categorical
from keras.models import Model
from keras.layers import Input, Dense
@pangyuteng
pangyuteng / README.md
Last active December 24, 2018 07:35
AMICO installation instruction for windows x64:

AMICO installation instruction for windows x64:

  • conda create -n py27 python=2.7
  • activate py27
  • conda install -c intel mkl
  • conda install numpy scipy six
  • pip install nibabel
  • conda install -c conda-forge dipy
  • pip install https://github.com/samuelstjean/spams-python/releases/download/v2.6/spams-2.4-cp27-none-win_amd64.whl
  • pip install git+https://github.com/daducci/AMICO.git
@pangyuteng
pangyuteng / offscreen_vtk.sh
Last active June 16, 2022 12:28
vtk offscreen rendering - tested on ubuntu, anaconda py3.6 - thank you clinicalgraphics.
sudo su -
# go to system root, cd ..
mkdir /opt/anaconda3
# installed anaconda to /opt/anaconda3
bash /Temp/Anaconda3-5.1.0-Linux-x86_64.sh
# create py 3.6
/opt/anaconda3/bin/conda create -p /opt/envs/conda/py36 python=3.6
# activate py 3.6
source /opt/anaconda3/bin/activate /opt/envs/conda/py36
# install prebuilt vtk for offscreen rendering
@pangyuteng
pangyuteng / gif_isosurface.md
Last active September 4, 2024 21:57
render isosurface and save as gif using vtk and moviepy

demo gif

source /anaconda3/bin/activate py36

wget https://github.com/jonclayden/RNifti/raw/master/inst/extdata/example.nii.gz

python isosurface_vtk.py

@pangyuteng
pangyuteng / compile_run.sh
Created February 18, 2018 02:44 — forked from certik/compile_run.sh
Test offscreen rendering with VTK 6
#! /bin/bash
set -e
g++ -o test_offscreen.o -c test_offscreen.cpp -I$PYTHONHPC/include/vtk-6.0
g++ -o test_offscreen test_offscreen.o $PYTHONHPC/lib/libvtk*.so
LD_LIBRARY_PATH=$PYTHONHPC/lib/ ./test_offscreen
@pangyuteng
pangyuteng / readme.md
Last active May 29, 2018 03:50
notes for using amazon sagemaker lambda and docker

instructions

useful links

@pangyuteng
pangyuteng / BrYlBu.py
Created May 31, 2018 03:19
custom matplotlib colormap and convert to vtk colormap
_BrBG_data = (
(0.32941176470588235, 0.18823529411764706, 0.0196078431372549 ),
(0.5490196078431373 , 0.31764705882352939, 0.0392156862745098 ),
(0.74901960784313726, 0.50588235294117645, 0.17647058823529413),
(0.87450980392156863, 0.76078431372549016, 0.49019607843137253),
(0.96470588235294119, 0.90980392156862744, 0.76470588235294112),
(0.96078431372549022, 0.96078431372549022, 0.96078431372549022),
(0.7803921568627451 , 0.91764705882352937, 0.89803921568627454),
(0.50196078431372548, 0.80392156862745101, 0.75686274509803919),
@pangyuteng
pangyuteng / index.html
Created June 15, 2018 06:44
plot example with chartjs
<!DOCTYPE html>
<html>
<style>
body {
font-family: Helvetica Neue, Arial, sans-serif;
text-align: center;
}
.wrapper {
max-width: 800px;
margin: 50px auto;