Skip to content

Instantly share code, notes, and snippets.

@qxj
qxj / draw_tree.py
Created July 11, 2016 15:51
Draw heatmap of the LambdaMART model generated from RankLib. Inspired by https://wellecks.wordpress.com/2015/02/21/peering-into-the-black-box-visualizing-lambdamart/ Usage: ./draw_tree.py model.xml | dot -Tpng > model_heatmap.png
#!/usr/bin/python
#
# Copyright (C) 2016 Julian Qian
#
# @file draw_tree.py
# @author Julian Qian <[email protected]>
# @created 2016-07-11 20:33:56
#
"""
import numpy as np
from matplotlib import pylab as plt
#from mpltools import style # uncomment for prettier plots
#style.use(['ggplot'])
'''
function definitions
'''
# generate all bernoulli rewards ahead of time
def generate_bernoulli_bandit_data(num_samples,K):
@qxj
qxj / README.md
Last active April 16, 2019 13:54
Run ss-redir at Raspberry PI, as proxy, gateway and dns.

dnsmasq and iptable configuration on gateway (raspi)

@qxj
qxj / gtest.cmake
Created April 29, 2016 18:18 — forked from oneamtu/gtest.cmake
How to add google test as an downloadable external project
########################### GTEST
# Enable ExternalProject CMake module
INCLUDE(ExternalProject)
# Set default ExternalProject root directory
SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/third_party)
# Add gtest
# http://stackoverflow.com/questions/9689183/cmake-googletest
ExternalProject_Add(
@qxj
qxj / add_parts_hr.sh
Created March 4, 2016 07:24
Add existed directory in hdfs into each partition of tables
#!/usr/bin/env bash
# @(#) add_partition.sh Time-stamp: <Julian Qian 2015-06-08 17:10:46>
# Copyright 2015 Julian Qian
# Author: Julian Qian <[email protected]>
# Version: $Id: add_partition.sh,v 0.1 2015-06-08 17:08:46 jqian Exp $
#
tables=(php_web_log )
for tbl in ${tables[@]};
@qxj
qxj / clean_hadoop_tmp.sh
Created February 23, 2016 10:29
Clean temporary files generated by hive under hdfs:///tmp
#!/usr/bin/env bash
#
# Copyright (C) 2016 Julian Qian
#
# @file clean_hadoop_tmp.sh
# @author Julian Qian <[email protected]>
# @created 2016-02-23 17:45:55
#
hadoop=hadoop
@qxj
qxj / nn_demo.py
Last active January 10, 2016 12:36
A bare bones neural network implementation to describe the inner workings of backpropagation. https://iamtrask.github.io/2015/07/12/basic-python-network/
#!/usr/bin/env python
import numpy as np
X = np.array([ [0,0,1],[0,1,1],[1,0,1],[1,1,1] ])
y = np.array([[0,1,1,0]]).T
alpha,hidden_dim = (0.5,4)
np.random.seed(1)
# randomly initialize our weights with mean 0
synapse_0 = 2*np.random.random((3,hidden_dim)) - 1
synapse_1 = 2*np.random.random((hidden_dim,1)) - 1
@qxj
qxj / repositories
Created January 3, 2016 08:53
sbt configuration: ~/.sbt/repositories
[repositories]
local
#repox-maven: http://127.0.0.1:8078/
#repox-ivy: http://127.0.0.1:8078/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
oschina: http://maven.oschina.net/content/groups/public/
oschina-ivy:http://maven.oschina.net/content/groups/public/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
sbt-releases-repo: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
@qxj
qxj / websvr_http.py
Last active October 19, 2017 06:49
A simple web server with rotating file logger
#!/usr/bin/env python
"""A simple web server with rotating file logger
"""
import logging
import logging.handlers
import BaseHTTPServer
@qxj
qxj / MultiLayerExperiment.java
Created August 17, 2015 08:25
分层实验的示例代码。原文见这里:http://blog.sina.com.cn/s/blog_e59371cc0102vopg.html ,但是其中代码格式错乱了,帮忙整理了一下。
// Overlapping Experiment Demo
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.LinkedList;
import java.util.List;
public class MultiLayerExperiment {
private static String byteArrayToHex(byte[] byteArray) {
char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7',