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 / 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 / search.php
Last active August 10, 2018 06:11
Demo search
<?php
/**
* Demo search
* User: eagle<[email protected]>
* Date: 2018/8/10
* Time: 10:41
*/
$words = [
"杭州", "杭州市", "上海", "上海市", "闵行", "闵行区", "莲花路",
@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 / test.go
Created June 25, 2018 03:13
Test channel bug
package main
import (
"fmt"
"math/rand"
"sync"
)
func main() {
chs := make(chan int, 10)
@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 / Makefile
Created April 24, 2018 03:03
ethermint go makefile
GOTOOLS := \
github.com/karalabe/xgo \
github.com/alecthomas/gometalinter
PACKAGES := $(shell glide novendor)
BUILD_TAGS? := ethermint
VERSION_TAG := 0.5.3
@wudi
wudi / tuna_mysql_repo
Created March 15, 2018 07:34
tuna_mysql_repo.txt
对于CentOS 7:
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
@wudi
wudi / s2b.go
Created February 1, 2018 06:44
避免 string 转 []byte 开销的方式
package main
import (
"bufio"
"fmt"
"os"
"reflect"
"unsafe"
)
@wudi
wudi / coinw_monitor.sh
Last active January 8, 2018 08:02
Coinw market monitor
#! /bin/bash
# Author: [email protected]
# Date: 2018-01-08
symbols="ETH#14#<9500 EOS#29#>70"
cookie="YOUR_COOKIE_STRING"
while true
do
message=""