Skip to content

Instantly share code, notes, and snippets.

View wudi's full-sized avatar
🎯
Focusing

Di Wu wudi

🎯
Focusing
View GitHub Profile
@wudi
wudi / findauthors.sh
Last active September 16, 2019 08:18 — forked from stefanfoulis/findauthors.sh
How to sync svn to git
#!/usr/bin/env bash
# Run this script inside a SVN checkout of the project
authors=$(svn log -q | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq)
for author in ${authors}; do
echo "${author} = NAME <USER@DOMAIN>";
done
@wudi
wudi / arch_enable_bbr.sh
Created December 20, 2018 15:48 — forked from duzun/arch_enable_bbr.sh
Enable TCP BBR
#!/bin/bash
#
# A script to enable TCP BBR on a Linux system.
#
# @author Dumitru Uzun (DUzun.Me)
# @version 1.0.0
# @distro ArchLinux/Manjaro
#
old_cc=`sysctl net.ipv4.tcp_congestion_control | awk -F= '{print $2}' | sed -e s/\^\\s//`
@wudi
wudi / closure.c
Created August 14, 2018 03:11 — forked from chobie/closure.c
static void git_ex_cb(INTERNAL_FUNCTION_PARAMETERS)
{
zval *payload, *this = getThis();
char *oid;
int oid_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"sz", &oid, &oid_len, &payload) == FAILURE) {
return;
}
@wudi
wudi / Laravel-Container.md
Created June 29, 2018 09:39
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

@wudi
wudi / nospm.user.js
Created June 14, 2018 08:18 — forked from ambar/nospm.user.js
nospm 移除虾米、淘宝和天猫网址中的 spm 参数(包括地址栏和页面中的链接):https://chrome.google.com/webstore/detail/nospm/dlkfdpdjhnonlhjhelnfaninbdggnkgl
// ==UserScript==
// @name nospm
// @version 1.1
// @description 移除虾米、淘宝和天猫网址中的 spm 参数(包括地址栏和页面中的链接)
// @include *://*.xiami.com/*
// @include *://*.taobao.com/*
// @include *://*.tmall.com/*
// ==/UserScript==
let forEach = Function.call.bind([].forEach)
@wudi
wudi / parallels_tools_ubuntu_new_kernel_fix.md
Created June 13, 2018 02:51 — forked from rudolfratusinski/parallels_tools_ubuntu_new_kernel_fix.md
Parallels Tools fix for Ubuntu 18.04 and other Linux distributions with Kernel version >= 4.15

Preparation

  • In open Ubuntu 18.04 machine click Parallels Actions -> "Install Parallels Tools"

  • A "Parallels Tools" CD will popup on your Ubuntu desktop.

  • Open it by double mouse click, copy all the content to a new, empty directory on a desktop, name it for e.g. "parallels_fixed"

  • Open terminal, change directory to parallels_fixed (cd ~/Desktop/parallels_fixed)

  • Make command line installer executable (chmod +x install)

  • Change directory to "installer" (cd installer)

  • Make few other scripts executable: chmod +x installer.* *.sh prl_*

@wudi
wudi / main.go
Created January 8, 2018 03:06 — forked from petergloor/main.go
MaxInt, MinInt, MaxUint and MinUint in Go (golang)
package main
import "fmt"
// Constant definitions
const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(^uint(0) >> 1)
const MinInt = -MaxInt - 1
@wudi
wudi / benchmark+go+nginx.md
Created August 29, 2016 14:51 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

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
@wudi
wudi / Makefile.golang
Created June 13, 2016 03:29 — forked from dnishimura/Makefile.golang
Makefile for Golang projects
# Makefile for a go project
#
# Author: Jon Eisen
# site: joneisen.me
#
# Targets:
# all: Builds the code
# build: Builds the code
# fmt: Formats the source files
# clean: cleans the code
@wudi
wudi / nginxvarcore.md
Created December 12, 2015 08:52 — forked from esfand/nginxvarcore.md
Nginx Variables

Embedded Variables

The ngx_http_core_module module supports embedded variables with names matching the Apache Server variables. First of all, these are variables representing client request header fields, such as $http_user_agent, $http_cookie, and so on. Also there are other variables:

  • $arg_name
    argument name in the request line