Skip to content

Instantly share code, notes, and snippets.

View shyoshyo's full-sized avatar
🐟
Fish touching

Kaixiang Lei shyoshyo

🐟
Fish touching
  • ByteDance
  • Shanghai, China
View GitHub Profile
CXX = /usr/bin/g++
NVCC = /usr/local/cuda-9.1/bin/nvcc
CUDA_LIB = /usr/local/cuda-9.1/lib64
CUDA_INC = /usr/local/cuda-9.1/include
CUDA_CFLAGS = -I $(CUDA_INC)
CUDA_LFLAGS = -lcudart -L $(CUDA_LIB)
TF_LIB = $(shell python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')
TF_INC = $(shell python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
def spectral_normed_weight(W, u=None, num_iters=1, update_collection=tf.GraphKeys.UPDATE_OPS, name='spectral_norm', eps=1e-12, reuse=False):
with tf.variable_scope(name, reuse=reuse):
W_shape = W.shape.as_list()
n_in = W.shape[:-1].num_elements()
n_out = W.shape[-1].value
W_reshaped = tf.reshape(W, [n_in, n_out])
if u is None: u = tf.get_variable("u", shape=[1, n_out], initializer=tf.truncated_normal_initializer(), trainable=False)
# if u is None: u = tf.Variable(tf.truncated_normal(shape=[1, n_out]), name='u', trainable=False)
@shyoshyo
shyoshyo / partition.py
Last active October 19, 2018 17:32
整数拆分问题:n 个相同的球,分成若干堆,有几种分法?
#!/usr/bin/env python3
"""
整数拆分问题:n 个相同的球,分成若干堆,有几种分法?
如果要和上界比较,那么绘制下列图像:
* 分拆数及其上界随 n 变化的图像
* 分拆数与其上界之比随 n 变化的图像
"""
import argparse
#!/bin/sh
sudo fdisk -l
sudo grub-install --root-directory=/mnt /dev/sda
sudo mount /dev/sda2 /mnt
~/p/ncurses-6.1 ➜ ./configure --prefix=$HOME/.local --enable-shared --with-shared --without-debug
./autogen.sh --prefix=$HOME/.local/ --with-drivers=dri --with-gallium-drivers= --disable-llvm --enable-glut
env CC=(which gcc) CXX=(which g++) cmake ../blender-2.79b/ -DPYTHON_LIBRARY=$HOME/.local/miniconda3/envs/py35/lib/libpython3.5m.so -DPYTHON_LIBPATH=$HOME/.local/miniconda3/envs/py35/lib/ -DPYTHON_INCLUDE_DIR=$HOME/.local/miniconda3/envs/py35/include/python3.5m/ -DPYTHON_INCLUDE_CONFIG_DIR=$HOME/.local/miniconda3/envs/py35/lib/pkgconfig/ -DWITH_CYCLES=false -DWITH_SYSTEM_GLEW=false
@shyoshyo
shyoshyo / brew.sh
Created January 3, 2019 18:22
GLFW example
# GLFW is a windowing manager for OpenGL. Makes things easier when working with windows, as well as input via keyboard or mouse.
# GLFW is in homebrew/versions so we'll have to tap that to be able to install.
brew tap homebrew/versions
brew install glfw3
# GLEW offers bindings for your OS so that you don't have to call some OS specific OpenGL calls.
brew install glew
#!/usr/bin/env sh
INFO_USERNAME=...
INFO_PASSWORD=...
email=...
cookies="$(mktemp /tmp/cookie.XXXXXXXX)"
transcript_html="$(mktemp /tmp/transcript_html.XXXXXXXX)"
while true; do
@shyoshyo
shyoshyo / 0.01.sh
Created February 4, 2019 07:09
0.01 transcript
curl 'http://jxgl.cic.tsinghua.edu.cn/jxpg/b/zzzc/v_zzfw_zzdy_dd/dzcjd_pay' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' -H 'Origin: http://jxgl.cic.tsinghua.edu.cn' -H 'Upgrade-Insecure-Requests: 1' -H 'Content-Type: application/x-www-form-urlencoded' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'Referer: http://jxgl.cic.tsinghua.edu.cn/jxpg/f/zzzc/v_zzfw_zzdy_dd/bksDzcjdzf' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7' -H 'Cookie: JSESSIONIDJXPGNEW=???; thuwebcookie=???' --data 'token=&cjdlxs=01%2C&email=twd2%40163.com&zfy=0.01&czrlb=bks' --compressed