Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Zheng Yan zyan0

🎯
Focusing
View GitHub Profile
@vasanthk
vasanthk / System Design.md
Last active Jul 1, 2022
System Design Cheatsheet
View System Design.md

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@neubig
neubig / lstm-lm.py
Last active Aug 23, 2017
This is a minimal implementation of training for a language model using long short-term memory (LSTM) neural networks
View lstm-lm.py
#!/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
@jasonwbw
jasonwbw / dword2vec.c
Created Oct 8, 2014
Tomas Mikolov's "Distributed Representations of Sentences and Documents" code
View dword2vec.c
// 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,
@acolyer
acolyer / service-checklist.md
Last active Jun 11, 2022
Internet Scale Services Checklist
View service-checklist.md

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?
@liuliu
liuliu / k-mean on histogram.c
Last active Sep 26, 2016
k-mean for layer
View k-mean on histogram.c
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;
@ravidsrk
ravidsrk / Install.md
Last active Sep 30, 2021
Deploying django application with gunicorn nginx mysql
View Install.md

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
View naivebayes.rb
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
@hydra35
hydra35 / nginx.conf
Last active May 14, 2021
to gray, for Ya'An, Si Chuan earthquake
View nginx.conf
# 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 */
@lastland
lastland / BeyesianAvg.py
Created Aug 11, 2012
尝试用这篇post: http://www.matrix67.com/blog/archives/5044 中的方法实现的一个自动中文抽词算法的Python程序
View BeyesianAvg.py
# -*- coding=utf-8 -*-
import collections
# Usage:
# 我的做法是把WordsDetector.py里的结果输出到文件,
# 然后把文件名放到下面的names列表中,运行本程序。
names = ['name0',
'name1',
'name2',
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 — forked from jboner/latency.txt
Latency numbers every programmer should know
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs