Skip to content

Instantly share code, notes, and snippets.

from numpy.random import choice as random_choice, randint as random_randint, rand
MAX_INPUT_LEN = 40
AMOUNT_OF_NOISE = 0.2 / MAX_INPUT_LEN
CHARS = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .")
def add_noise_to_string(a_string, amount_of_noise):
"""Add some artificial spelling mistakes to the string"""
if rand() < amount_of_noise * len(a_string):
# Replace a character with a random character
random_char_position = random_randint(len(a_string))

Rough Notes about CQRS and ES

Once upon a time…

I once took notes (almost sentence by sentence with not much editing) about the architectural design concepts - Command and Query Responsibility Segregation (CQRS) and Event Sourcing (ES) - from a presentation of Greg Young and published it as a gist (with the times when a given sentence was heard).

I then found other summaries of the talk and the gist has since been growing up. See the revisions to know the changes and where they came from (aka the sources).

It seems inevitable to throw Domain Driven Design (DDD) in to the mix.

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
<html>
<head>
<title></title>
<script type="text/javascript">
var tdist={ '210184':['沈北新区','210100','shen bei xin qu'], '210185':['其它区','210100','qi ta qu'], '420381':['丹江口市','420300','dan jiang kou shi'], '420383':['其它区','420300','qi ta qu'], '420382':['城区','420300','cheng qu'], '210182':['浑南新区','210100','hun nan xin qu'], '140800':['运城市','140000','yun cheng shi'], '210183':['张士开发区','210100','zhang shi kai fa qu'], '140802':['盐湖区','140800','yan hu qu'], '210181':['新民市','210100','xin min shi'], '140829':['平陆县','140800','ping lu xian'], '210203':['西岗区','210200','xi gang qu'], '140828':['夏县','140800','xia xian'], '210202':['中山区','210200','zhong shan qu'], '140830':['芮城县','140800','rui cheng xian'], '210200':['大连市','210000','da lian shi'], '140825':['新绛县','140800','xin jiang xian'], '140824':['稷山县','140800','ji shan xian'], '140827':['垣曲县','140800','yuan qu xian'], '140826':['绛县','140800','jiang xian'], '210204':['沙河口区','210200','sha he kou qu'], '140821':['临猗县','140800','lin yi xian'], '140823':['闻喜县','1
@feilaoda
feilaoda / hello.c
Created August 18, 2014 23:36 — forked from darcyliu/hello.c
#include <stdio.h>
#include <stdlib.h>
int main(){
//while(1){};
//sleep(5);
char *p;
long x = 10000,y=1000000;
while(x-->0){
while(y-->0){
//printf("%ld %ld\n",x,y);
# /etc/security/limits.conf
* soft nofile 999999
* hard nofile 999999
root soft nofile 999999
root hard nofile 999999
===========================================================
# /etc/sysctl.conf
# sysctl for maximum tuning

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
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048