Skip to content

Instantly share code, notes, and snippets.

@yamingd
yamingd / gist:ba346bc76e72ac0bad3b
Last active August 29, 2015 14:05
k-mean from sklearn
1. 修正收敛值
计算矩阵每列的方差, 得到列方差矩阵
用方差矩阵求得方差的均值,然后和提供的收敛值相乘,得到最终的收敛值
2. 归一化矩阵
求矩阵的列均值矩阵
用源矩阵减去列均值矩阵得到最终的归一化矩阵
3. 欧式空间范数矩阵
用归一化矩阵的平方,每行的和组成范数矩阵
http://highoncoding.com/Articles/873_Utilizing_Unicode_Characters_in_iOS_Development.aspx
http://stackoverflow.com/questions/2099349/using-objective-c-cocoa-to-unescape-unicode-characters-ie-u1234
@yamingd
yamingd / nginx
Created August 30, 2014 11:33 — forked from mustafaturan/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
@yamingd
yamingd / gist:3f61c18e0695c44c81ec
Last active August 29, 2015 14:05
Keepalived 主从选举
http://ixdba.blog.51cto.com/2895551/1544858
http://blog.sina.com.cn/s/blog_704836f40101lixp.html
http://blog.sina.com.cn/s/blog_704836f40101gm11.html
http://www.tuicool.com/articles/VB3Yjy
#!/bin/bash
#
# This script checks if a mysql server is healthy running on localhost. It will
# return:
#
# "HTTP/1.x 200 OK\r" (if mysql is running smoothly)
#
# - OR -
#
# "HTTP/1.x 500 Internal Server Error\r" (else)
global
log 127.0.0.1 local0 notice
maxconn 20000
user haproxy
group haproxy
defaults
log global
mode tcp
option dontlognull

The High Availability Switch: from MySQL+MMM to MariaDB+Galera Cluster

Kevin Lawver, President @ [Rails Machine](https://railsmachine.com), is our guest author for this post.

Few things feel worst than rolling out a High Availability (HA) system, then regularly seeing that system collapse. For our team at Rails Machine, this failing HA system was MySQL Multi-Master Replication Manager (MMM).

We've been searching for a MMM replacement for a while, and a few months ago, we made the switch to MariaDB + Galera Cluster for High Availability MySQL. What's wrong with MySQL MMM? What's special about Galera Cluster? Read on!

@yamingd
yamingd / gist:d765d3cda0577f4326d5
Last active August 29, 2015 14:05
Git Server
http://weininger.net/configuration-of-nginx-for-gitweb-and-git-http-backend
https://eatabrick.org/20120126_gitweb_nginx.html
http://smecsia.me/blog/82/Ubuntu+12.04+LTS+%2B+Nginx+%2B+git+%2B+gitweb
@yamingd
yamingd / JVM参数
Last active August 29, 2015 14:04
Netty 开发的网络参数
set CLASSPATH=.
nohup java -server -Xmx6G -Xms6G -Xmn600M -XX:PermSize=50M -XX:MaxPermSize=50M -Xss256K -XX:+DisableExplicitGC -XX:SurvivorRatio=1 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:LargePageSizeInBytes=128M -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+PrintClassHistogram -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Xloggc:gc.log -Djava.ext.dirs=lib com.test.server.HttpChunkedServer 8000 >server.out 2>&1 &
@yamingd
yamingd / gist:f393668499ca28e33d1c
Created August 1, 2014 02:12
MySQL 5.6 降低启动内存
performance_schema_max_table_instances=400
table_definition_cache=400
table_open_cache=256