Skip to content

Instantly share code, notes, and snippets.

View yuq-1s's full-sized avatar
:octocat:
Working in the lab

Yuquan Wang yuq-1s

:octocat:
Working in the lab
  • Tsinghua University
  • Beijing
View GitHub Profile
@yuq-1s
yuq-1s / find_first_nan.py
Created May 15, 2018 12:43
Find first n appearances of tensors containing Nans for TensorFlow.
#! /usr/bin/env python3
import os
import tensorflow as tf
import numpy as np
import tempfile
from tensorflow.python import debug as tfdbg
def watch_session(dump_root_dir, train_op, times):
''' Dump tensors to temperary directory for analysis'''
@yuq-1s
yuq-1s / recover.sh
Last active July 3, 2018 00:06
The way I set up a new Ubuntu 16.04 when Windows Update kills all my data
# disable system problem detected
sudo sed -i 's/enabled=1/enabled=0/' /etc/default/apport
# update and install necessary software
## shadowsocks-libev
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev -y
sudo apt-get update
@yuq-1s
yuq-1s / vimrc
Created July 7, 2018 10:00
My vimrc
" Leader
let mapleader = " "
set backspace=2 " Backspace deletes like most programs in insert mode
set nobackup
set nowritebackup
set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287
set history=50
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
@yuq-1s
yuq-1s / bashenv.sh
Created July 7, 2018 10:07
My bash environment variables
# export all_proxy='socks5://127.0.0.1:1080'
# export ALL_PROXY='socks5://127.0.0.1:1080'
MUJOCO_PY_MJPRO_PATH="$HOME/.mujoco/mjpro131/bin"
export all_proxy=''
export ALL_PROXY=''
export PATH="$HOME/bin/:$MUJOCO_PY_MJPRO_PATH:/usr/local/cuda/bin:$PATH"
export MUJOCO_PATH="$HOME/bin/mjpro140"
# export GTEST_DIR="$HOME/lib/googletest/googletest"
# export GMOCK_DIR="$HOME/lib/googletest/googlemock"
@yuq-1s
yuq-1s / rmemptyline.ps1
Created July 17, 2018 03:00
eliminate all empty lines of all python files in a directory in powershell
Get-ChildItem -path "C:\path\to\my\directory" -recurse -Include *.py |
ForEach-Object {
(gc $_.FullName) | ? {$_.trim() -ne ""} | Set-Content $_.FullName
}
@yuq-1s
yuq-1s / bits2float.cc
Last active October 14, 2018 09:40
Playing with floats: bits to floats and floats to bits.
#include "showbits.h"
#include <iostream>
#include <algorithm>
#include <string>
#include <locale>
#include <cassert>
typedef union {
int64_t i;
@yuq-1s
yuq-1s / djh4linux.sh
Created November 24, 2018 07:52
Compile Junhui Deng's DSA code on a linux machine
#! /bin/bash
find -name '*.cpp' | sed -i 's/typeinfo\.h/typeinfo/g'
find -name '*.h' | sed -i 's/typeinfo\.h/typeinfo/g'
find -name '*.cpp' | python patch.py
find -name '*.h' | python patch.py
imps=$(find -name '*_implementation.h')
@yuq-1s
yuq-1s / heartbeat-client.py
Last active February 22, 2019 10:22
heartbeat for dynamic dns
import socket
import time
import copy
import struct
import socketserver
import select
#######################################################################
# package pyaes #
#######################################################################
@yuq-1s
yuq-1s / workstation.md
Last active February 28, 2019 11:16
Build my own workstation with hybrid disk and dual boot

workstation

Goal

Dual boot Ubuntu 18.04 and Windows 10

Windows occupies an 128GB ssd for gaming Ubuntu occupies a 256GB ssd and two same 1TB hdd with raid0 grouped by [bcache][3].

@yuq-1s
yuq-1s / treemnist.py
Created April 8, 2019 10:19
mnist with naive binary-tree-like hierarchical softmax
from __future__ import print_function
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
import torchvision
class Net(nn.Module):