Skip to content

Instantly share code, notes, and snippets.

@guoyu07
guoyu07 / template.tex
Created May 28, 2018 03:59 — forked from hsanchez/template.tex
My Latex Template for Kindle (Or IPAD)
\documentclass[8pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[paperwidth=9cm, paperheight=11.5cm, top=0.5cm, left=0.5cm, right=0.5cm, bottom=0.5cm]{geometry}
\usepackage{graphicx}
\usepackage{tikz, blindtext}
\makechapterstyle{box}{
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
\renewcommand*{\printchapternum}{
@guoyu07
guoyu07 / build.xml
Created May 24, 2018 03:23 — forked from ovr/build.xml
Perfect Ant Build Script For PHP project in CI use
<project name="Uniqhand" default="build" basedir=".">
<property name="source" value="${basedir}/.."/>
<property name="appsource" value="${source}/application"/>
<property name="libsource" value="${source}/library"/>
<target name="clean"
description="Clean up artifact directories">
<delete dir="${basedir}/build"/>
</target>
@guoyu07
guoyu07 / debug-fpm-segfaut.md
Created May 15, 2018 09:02 — forked from guilhermeblanco/debug-fpm-segfaut.md
Debugging PHP-FPM segfaults

Assuming PHP is compiled with debug enabled.

$ gdb /usr/sbin/php-fpm

Then:

r --nodaemonize --fpm-config /etc/php7/fpm/php-fpm.conf
@guoyu07
guoyu07 / dash-doggybag.py
Created May 4, 2018 02:53 — forked from lucasg/dash-doggybag.py
Bulk downloader for dash docsets (official and user contributed)
#!/usr/bin/env python3
import sys
import json
import os
import os.path
import shutil
import logging
import tempfile
import glob
import argparse
@guoyu07
guoyu07 / gist:16e1bd114c2b22e811f9e9caae8e414d
Created April 2, 2018 10:44 — forked from amichaelgrant/gist:5866230
Configuring Nginx for Apache Tomcat 7
Configuring Nginx for Apache Tomcat 7
September 23, 2011 Java, NginX, Tomcat, Ubuntu 19 comments
Apache Tomcat can be the first choice of an Application Server for someone new to Java world. There are obviously other servers such as JBoss Application Server and IBM WebSphere but those may be slightly difficult for a newbie.
In some situations, like when we are serving a few websites with Nginx over port 80 (HTTP), it is required to configure Nginx in order to serve our Java web application which is running on Apache Tomcat. It is basically using Nginx as a Reverse Proxy This can be done with a new server section in Nginx configuration file (it is in /etc/nginx/sites-available/default by default) :
server {
listen mysite.com:80;
server_name mysite.com;

本文基本上这为两篇文章的翻译和整合 -- Scalable networking And Why are event-driven server so great

OPPC模型瓶颈

传统服务器模型如Apache为每一个请求生成一个子进程。当用户连接到服务器的一个子进程就产生,并处理连接。每个连接获得一个单独的线程和子进程。当用户请求数据返回时,子进程开始等待数据库操作返回。如果此时另一个用户也请求返回数据,这时就产生了阻塞。

这种模式在非常小的工作负荷是表现良好,当请求的数量变得太大是服务器会压力过于巨大。 当Apache达到进程的最大数量,所有进程都变得缓慢。每个请求都有自己的线程,如果服务代码使用PHP编写时,每个进程所需要的内存量是相当大的[1]。

fork()操作延时

@guoyu07
guoyu07 / nginx.conf
Created March 13, 2018 12:02 — forked from fangpsh/nginx.conf
whoami.fangpeishi.com (whoami.akaimai.com) based on openresty
worker_processes 1;
daemon on;
master_process on;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log debug;
#pid logs/nginx.pid;
@guoyu07
guoyu07 / bose-qc35-nosie-cancelling.txt
Created March 7, 2018 06:39 — forked from rambolee/bose-qc35-nosie-cancelling.txt
Bose QC35 无线 蓝牙 降噪耳机 文案
有多安静我来描述一下,孩子数学成绩不好,你在银行做经理,维护客户关系,不上不下,有房贷和车贷,每月按揭五千。你老婆在市人民医院做护士,她妈有尿毒症透析多年,她不爱你。你年轻的时候觉得能成一番事业,但现在也就这样,朋友们混的都比你好,你下班在车库停稳车,关掉引擎,呜一声安静了下来。太安静了,你生命中少有这么安静的时刻,你打算发十分钟呆再上楼吃饭。
以上就是 BOSE QC 35 的降噪效果测评。
@guoyu07
guoyu07 / update-dnsmasq-from-gfwlist.py
Created March 7, 2018 06:37 — forked from rambolee/update-dnsmasq-from-gfwlist.py
升级 小米路由器3 可以ssh 可以 Shadowsocks [Tags]: 小米路由, 小米路由3, 小米路由器, 小米路由器3, ssh, shadowsocks
#!/usr/bin/env python
#coding=utf-8
#
# Generate a list of dnsmasq rules with ipset for gfwlist
#
# Copyright (C) 2014 http://www.shuyz.com
# Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules
import urllib2
import re
#! /bin/sh
# :vim setf sh:
#
# Copyright (c) 2013 Bryan Drewery <bryan@shatow.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright