Skip to content

Instantly share code, notes, and snippets.

View zyan0's full-sized avatar
🎯
Focusing

Zheng Yan zyan0

🎯
Focusing
View GitHub Profile
@BlinkyStitt
BlinkyStitt / making bitcoind
Last active October 3, 2015 18:27 — forked from andrewschaaf/gist:998886
compiling bitcoind on ubuntu-server 12.04
sudo apt-get update
sudo apt-get install -y git-core build-essential libssl-dev libboost-all-dev libdb5.1-dev libdb5.1++-dev libgtk2.0-dev
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin/src
make -f makefile.unix clean; make -f makefile.unix USE_UPNP= bitcoind
spam_train, ham_train, spam_test, ham_test = ['train/spam', 'train/ham', 'test/spam', 'test/ham'].map{|t| Dir["#{ARGV[0]}/#{t}/*"].map {|fn| File.open(fn, 'r:iso8859-1').read.gsub(/[^a-zA-Z]/, ' ').split}}
spam_log, ham_log = [spam_train, ham_train].map{|t| t.flatten.instance_eval {reduce(Hash.new(0)) { |h,v| h[v] += 1.0/size; h }.select{|w, v| w.size > 2 && v > 8e-6}}.instance_eval{each {|k,v| self[k] = Math.log(v)}}}
spam_predict, ham_predict = [spam_test, ham_test].map {|t| t.map{|d| [spam_log, ham_log].map {|log| d.reduce(0){|s, w| log[w] ? s + log[w] : s}}}}
p spam_predict.size, spam_predict.select{|e| e.first < e.last}.size
p ham_predict.size, ham_predict.select{|e| e.first > e.last}.size
@liuliu
liuliu / k-mean on histogram.c
Last active September 26, 2016 06:05
k-mean for layer
gsl_rng_env_setup();
gsl_rng* rng = gsl_rng_alloc(gsl_rng_default);
sqlite3* db = 0;
int h[0x10000];
int kc[0x100];
float kmean[0x100];
uint16_t tbl[0x10000];
int i;
for (i = 0; i < 0x10000; i++)
tbl[i] = i;
@jasonwbw
jasonwbw / dword2vec.c
Created October 8, 2014 07:41
Tomas Mikolov's "Distributed Representations of Sentences and Documents" code
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@neubig
neubig / lstm-lm.py
Last active August 23, 2017 09:18
This is a minimal implementation of training for a language model using long short-term memory (LSTM) neural networks
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This is a simplified implementation of the LSTM language model (by Graham Neubig)
#
# LSTM Neural Networks for Language Modeling
# Martin Sundermeyer, Ralf Schlüter, Hermann Ney
# InterSpeech 2012
#
# The structure of the model is extremely simple. At every time step we
@hydra35
hydra35 / nginx.conf
Last active May 14, 2021 03:51
to gray, for Ya'An, Si Chuan earthquake
# 1. Make sure you have nginx sub module compiled in
# nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module'
# 2. add two directives below at HTTP level
# nginx.conf
http {
# ......
sub_filter '</head>' '<style type="text/css">html{ filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
@ravidsrk
ravidsrk / Install.md
Last active September 30, 2021 15:46
Deploying django application with gunicorn nginx mysql

Step One: Update Packages

sudo apt-get update
sudo apt-get upgrade

Step Two: Install and Create Virtualenv

sudo apt-get install python-virtualenv
sudo virtualenv /opt/myenv
@lastland
lastland / BeyesianAvg.py
Created August 11, 2012 07:14
尝试用这篇post: http://www.matrix67.com/blog/archives/5044 中的方法实现的一个自动中文抽词算法的Python程序
# -*- coding=utf-8 -*-
import collections
# Usage:
# 我的做法是把WordsDetector.py里的结果输出到文件,
# 然后把文件名放到下面的names列表中,运行本程序。
names = ['name0',
'name1',
'name2',
@nimbupani
nimbupani / index.html
Created December 2, 2011 05:00
Showing latest post on home page with Jekyll
---
layout: default
---
<div class="blog-index">
{% assign post = site.posts.first %}
{% assign content = post.content %}
{% include post_detail.html %}
</div>
@acolyer
acolyer / service-checklist.md
Last active January 30, 2024 17:39
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?