Skip to content

Instantly share code, notes, and snippets.

View XUJiahua's full-sized avatar

许嘉华 XUJiahua

  • Shanghai, China
View GitHub Profile
@XUJiahua
XUJiahua / nginx.conf
Created April 13, 2018 07:26 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@XUJiahua
XUJiahua / webdavserv.go
Created April 5, 2018 13:22 — forked from staaldraad/webdavserv.go
A small webdav server in go
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"golang.org/x/net/webdav"
@XUJiahua
XUJiahua / wxverify.js
Created November 16, 2017 16:13 — forked from beiweiqiang/wxverify.js
微信公众号接口配置信息认证
// 配置信息的token随意填,和这里的一样就行
var PORT = 8080; //监听8080端口号
var http = require('http');
var qs = require('querystring');
var TOKEN = 'beiweiqiang'; //必须与测试号所填写的Token相同
function checkSignature(params, token) {
var key = [token, params.timestamp, params.nonce]
.sort()
.join('');
@XUJiahua
XUJiahua / nginx_assets.md
Created November 3, 2017 07:14 — forked from vishaltelangre/nginx_assets.md
Serving Static Assets via Nginx

Concept

  • People talk about two servers: a web server (e.g. Nginx, Apache, etc.) and a app server (e.g. Language specific servers like Unicorn, Node.js, Tomcat, Http-Kit, etc.). There are exceptions where app servers not required at all (as web server itself provides preprocessors for handling), but let's not talk about now.
  • Web servers are really fast and supports lot of standard and commonly used MIME-type requests. Concept of serving a file is -- forming and sending a response of bytes of data and labeling it with requested MIME-type by a client (e.g. web browser).
  • Every response format (in layman's language, a file) is recognized by it's MIME-type, for e.g. a PNG image file has "image/png" MIME-type. JavaScript file has "text/javascript". HTML responses (or files) has "text/html". Plain text files have "text/plain".
  • Modern Browsers supports a lot of standard MIME-types. Images, videos, text files (XML, HTML, SVG, JS), and they better know how to visualize it. Browser also knows unrec
@XUJiahua
XUJiahua / golang-tls.md
Created March 9, 2016 03:23 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Generated private key

openssl genrsa -out server.key 2048

To generate a certificate

openssl req -new -x509 -key server.key -out server.pem -days 3650

https

@XUJiahua
XUJiahua / nginx.conf.default
Created February 2, 2016 08:55 — forked from nishantmodak/nginx.conf.default
Default Nginx Conf
#user nobody;
#Defines which Linux system user will own and run the Nginx server
worker_processes 1;
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores.
#error_log logs/error.log; #error_log logs/error.log notice;
#Specifies the file where server logs.
@XUJiahua
XUJiahua / Communicator.h
Created November 3, 2015 07:51 — forked from rjungemann/Communicator.h
How to open a TCP socket in Objective-C
#import <Foundation/Foundation.h>
@interface Communicator : NSObject <NSStreamDelegate> {
@public
NSString *host;
int port;
}
- (void)setup;
@XUJiahua
XUJiahua / rules.conf
Created October 27, 2015 12:51 — forked from janlay/README.md
Yet another config for Surge.app (build 245+)
# This config file was created for myself (@janlay). You may want to add or remove some rules to make efficient use of the Internet.
# This file depends on the main.conf which defines your own proxy.
# Your main.conf will look like this:
# ---- START ----
# #!PROXY-OVERRIDE:rules.conf
# [Proxy]
# Proxy = https,server.address,port,username,password
# ---- END ----
#