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 / setup-sjtu-vpn.sh
Last active February 15, 2022 08:06
Setup SJTU VPN connection from Ubuntu 16.04 desktop
# Install dependencies
sudo apt install libcurl4-openssl-dev iptables-dev autoconf libgmp3-dev libssl-dev pkg-config
# Install StrongSwan
wget http://download.strongswan.org/strongswan-5.6.1.tar.bz2
tar xjvf strongswan-5.6.1.tar.bz2 && cd strongswan-5.6.1
# FIXME: Some of these options may be redundant, but they work on my laptop.
autoconf && ./configure \
--prefix=/usr/local \
@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 / imle.py
Last active February 1, 2022 09:27
[Implicit Maximum Likelihood Estimation](https://arxiv.org/abs/1809.09087) in 100 lines
import mxnet as mx
from mxnet import nd, autograd
from mxnet.gluon import nn
from mxnet.gluon.contrib.nn import Identity, Concurrent
from mxnet import gluon
import logging
def d(a, b):
return (a - b).norm()
@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].