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 / balance_udp_packet_dispath.patch
Created August 16, 2019 10:45
swoole-4.0.4 patch
diff --git a/src/network/ReactorThread.c b/src/network/ReactorThread.c
index e3aac4f5..a9617ff3 100644
--- a/src/network/ReactorThread.c
+++ b/src/network/ReactorThread.c
@@ -197,14 +197,14 @@ static int swReactorThread_onPackage(swReactor *reactor, swEvent *event)
{
pkt.port = ntohs(info.addr.inet_v4.sin_port);
pkt.addr.v4.s_addr = info.addr.inet_v4.sin_addr.s_addr;
- task.data.info.fd = pkt.addr.v4.s_addr;
+ task.data.info.fd = pkt.port;
@wudi
wudi / aes_enc_dec.php
Created July 11, 2019 06:30 — forked from turret-io/aes_enc_dec.php
AES encryption/decryption in PHP
<?php
// DEFINE our cipher
define('AES_256_CBC', 'aes-256-cbc');
// Generate a 256-bit encryption key
// This should be stored somewhere instead of recreating it each time
$encryption_key = openssl_random_pseudo_bytes(32);
// Generate an initialization vector
// This *MUST* be available for decryption as well
@wudi
wudi / curl-websocket.sh
Last active May 23, 2019 11:55 — forked from htp/curl-websocket.sh
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@wudi
wudi / swoole_issues.md
Last active May 8, 2019 09:36
Swoole Issues
  • What do Etcd, Consul, and Zookeeper do?
    • Service Registration:
      • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
    • Service Discovery:
      • Ability for client application to query the central registry to learn of service location.
    • Consistent and durable general-purpose K/V store across distributed system.
      • Some solutions support this better than others.
      • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
@wudi
wudi / Price-Time Matching Engine.c
Created January 4, 2019 07:24 — forked from Jud/Price-Time Matching Engine.c
Price-Time Matching Engine
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@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 / es_expired_clean.sh
Last active December 26, 2018 06:29
clean elasticsearch expired data
#!/usr/bin/env bash
#Copyright (C) 2018 Eagle <[email protected]>
ES_HOST="http://127.0.0.1:9200"
SEVEN_DAYS_AGO=$(date -d "-7 day" +%Y.%m.%d)
THREE_DAYS_AGO=$(date -d "-3 day" +%Y.%m.%d)
declare -a INDEX_FOR_SEVEN=(
"filebeat-xxx-"
@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_in_extension.c
Created August 14, 2018 10:18
closure in extension include USE
/* laravel extension for PHP */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "php.h"
#include "ext/standard/info.h"
#include "php_laravel.h"