Skip to content

Instantly share code, notes, and snippets.

View zhangqiaorjc's full-sized avatar

Qiao Zhang zhangqiaorjc

View GitHub Profile
@zhangqiaorjc
zhangqiaorjc / web_crawler_multithreaded.py
Created February 3, 2014 00:57
Download all annotated lectures slides from UW CSE 546 website
import urllib2
import re
import threading
class crawler_thread(threading.Thread):
def __init__(self, url, filepath):
threading.Thread.__init__(self)
self.url = url
self.filepath = filepath
def run(self):
@zhangqiaorjc
zhangqiaorjc / .vimrc
Created March 18, 2014 06:59
my vimrc
colorscheme desert
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
"
" "Always show current position
set ruler
"
" " Height of the command bar
set cmdheight=2
"
@zhangqiaorjc
zhangqiaorjc / install_os161_toolchain.sh
Last active June 20, 2024 07:56
a script to install the toolchain for os161 on UW CSE VMs
#!/bin/sh
# a script to install the toolchain for os161 on UW CSE VMs
# create build directories
mkdir ~/os161
mkdir ~/os161/toolbuild
mkdir ~/os161/tools
mkdir ~/os161/tools/bin
mkdir ~/os161/scratch
@zhangqiaorjc
zhangqiaorjc / wrapper.py
Created January 13, 2015 07:17
Example python script to parse XML data into tab-delimited format (from UW CSE 544 HW 1).
import xml.sax
import re
class DBLPContentHandler(xml.sax.ContentHandler):
"""
Reads the dblp.xml file and produces two output files.
pubFile.txt = (key, pubtype) tuples
fieldFile.txt = (key, fieldCnt, field, value) tuples
Each file is tab-separated

Keybase proof

I hereby claim:

  • I am zhangqiaorjc on github.
  • I am qiao (https://keybase.io/qiao) on keybase.
  • I have a public key whose fingerprint is 608A D340 2B0B 25D7 240C 0300 7E1B A0F2 2452 E08A

To claim this, I am signing this object:

import pandas as pd
import numpy as np
from sklearn.preprocessing import scale
from sklearn import linear_model
from itertools import chain, combinations
from sklearn.cross_validation import cross_val_score
prost = pd.read_csv("http://statweb.stanford.edu/~tibs/ElemStatLearn/datasets/prostate.data", sep="\t", usecols=range(1,11))
prost_std = pd.DataFrame(scale(prost.ix[:,0:8]), index = prost.index, columns = prost.columns[0:8])
@zhangqiaorjc
zhangqiaorjc / ecdf.py
Created December 20, 2016 05:19
Sample from an empirical cdf specified by a set of points
import numpy as np
import numpy.random as random
from scipy.stats import rv_continuous
class custom_distribution:
def __init__(self, rng, xp, fp):
"""takes x, y points of cdf"""
np.all(np.diff(xp) > 0)
self.rng = rng
self.xp = xp
@zhangqiaorjc
zhangqiaorjc / nuclide.txt
Last active April 17, 2017 17:55
Use Atom Nuclide for remote code development
# on remote server side, install nuclide server
# see detailed docs at https://nuclide.io/docs/features/remote/
sudo apt-get install nodejs npm
sudo npm install -g nuclide
# on local client side, install Atom and nuclide client package
# see detailed docs at https://nuclide.io/docs/editor/setup/
# first install Atom using apt-get or direct download
@zhangqiaorjc
zhangqiaorjc / install_openmpi.sh
Last active May 6, 2017 06:02
Install OpenMPI
wget https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.0.tar.gz
tar xzvf openmpi-2.1.0.tar.gz
cd openmpi-2.1.0
./configure --with-cuda
make -j 11 all
sudo make install
sudo ldconfig
# zhangqiaorjc@google.com
import atexit
import functools
from absl import app
from absl import flags
from absl import logging
import jax
from jax.lib import xla_extension as xc