Skip to content

Instantly share code, notes, and snippets.

@qxj
qxj / cluster.cpp
Last active February 14, 2016 04:46 — forked from jdeng/cluster
clustering by fast search and find of density peak
// generate [0..n-1]
auto seq = [](size_t n) -> std::vector<size_t> {
std::vector<size_t> v(n);
for (size_t i=0; i<n; ++i) v[i] = i;
return v;
};
auto index = seq(n);
// n * n distance matrix
std::vector<D> dists(n * n);
import io
import avro.schema
import avro.io
import lipsum
import random
from kafka.client import KafkaClient
from kafka.producer import SimpleProducer, KeyedProducer
g = lipsum.Generator()
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
@qxj
qxj / lda_gibbs.py
Last active August 29, 2015 14:19 — forked from mblondel/lda_gibbs.py
"""
(C) Mathieu Blondel - 2010
License: BSD 3 clause
Implementation of the collapsed Gibbs sampler for
Latent Dirichlet Allocation, as described in
Finding scientifc topics (Griffiths and Steyvers)
"""
@qxj
qxj / kafka.md
Last active August 29, 2015 14:20 — forked from ashrithr/kafka.md

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic
@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(
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 / fm_lr.py
Created September 6, 2016 06:30 — forked from kalaidin/fm_lr.py
Logistic regression + Factorization machines + SGD
import numpy as np
from math import exp, log
"""
SGD for logistic loss + factorization machines
The code follows this paper:
[1] http://www.ics.uci.edu/~smyth/courses/cs277/papers/factorization_machines_with_libFM.pdf
"""
def sigmoid(x):
@qxj
qxj / Makefile
Last active December 4, 2016 11:55 — forked from lmullen/Makefile
PDF slides and handouts using Pandoc and Beamer
SLIDES := $(patsubst %.md,%.slides.pdf,$(wildcard *.md))
HANDOUTS := $(patsubst %.md,%.handout.pdf,$(wildcard *.md))
all : $(SLIDES)
%.slides.pdf : %.md
pandoc --latex-engine=xelatex --toc $^ -t beamer --slide-level 2 -o $@
%.handout.pdf : %.md
pandoc $^ -t beamer --slide-level 2 -V handout -o $@