Skip to content

Instantly share code, notes, and snippets.

View cwen0's full-sized avatar
🎯
Focusing

Cwen Yin cwen0

🎯
Focusing
View GitHub Profile
@cwen0
cwen0 / tpcc_load_parallel.sh
Created April 17, 2017 06:49 — forked from sh2/tpcc_load_parallel.sh
Parallel load script for tpcc-mysql
#!/bin/bash
# Configration
MYSQL=/usr/bin/mysql
TPCCLOAD=./tpcc_load
TABLESQL=./create_table.sql
CONSTRAINTSQL=./add_fkey_idx.sql
DEGREE=`getconf _NPROCESSORS_ONLN`
@cwen0
cwen0 / tmux-cheatsheet.markdown
Created April 26, 2017 05:54 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@cwen0
cwen0 / tmux-cheatsheet.markdown
Created April 26, 2017 05:55 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

tmux at [-t 会话名]
# -*- coding: utf-8 -*-
import os
from datetime import datetime
from binascii import crc32
import cPickle as pickle
from glob import glob
TABLE = {}
current_active = max([int(f.replace('.sst', '')) for f in glob('*.sst')] or [1])
@cwen0
cwen0 / graceful_shutdown_tornado_web_server.py
Created March 27, 2018 13:07 — forked from wonderbeyond/graceful_shutdown_tornado_web_server.py
The example to how to shutdown tornado web server gracefully...
#!/usr/bin/env python
"""
How to use it:
1. Just `kill -2 PROCESS_ID` or `kill -15 PROCESS_ID`,
The Tornado Web Server Will shutdown after process all the request.
2. When you run it behind Nginx, it can graceful reboot your production server.
"""
import time
@cwen0
cwen0 / graceful_shutdown_tornado_web_server.py
Created March 27, 2018 13:07 — forked from mywaiting/graceful_shutdown_tornado_web_server.py
The example to how to shutdown tornado web server gracefully...
#!/usr/bin/env python
"""
How to use it:
1. Just `kill -2 PROCESS_ID` or `kill -15 PROCESS_ID` , The Tornado Web Server Will shutdown after process all the request.
2. When you run it behind Nginx, it can graceful reboot your production server.
3. Nice Print in http://weibo.com/1682780325/zgkb7g8k7
"""
var CryptoJS = require('crypto-js')
var request = require('request-promise')
/*
* npm install crypto-js request-promise request
* node wx_t1t_hack.js
*/
// export function testEncription(msg, fullKey) {
// var fullKey = fullKey.slice(0, 16)
global inject, delay_cnt
probe begin {
println("injdect diskio delay begin.\n");
}
probe procfs("cnt").read {
$value = sprintf("%d\n", delay_cnt);
}
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <dlfcn.h>
ssize_t read(int fd, void *buf, size_t count) {
ssize_t (*origin_read)(int, void*, size_t) = dlsym(RTLD_NEXT, "read");
sleep(5);
printf("read sleep 5s\n");
return origin_read(fd, buf, count);
@cwen0
cwen0 / retry.sh
Created June 17, 2019 10:12 — forked from dublx/retry.sh
Bash - retry command N times
#!/bin/bash
set -euo pipefail
function myFunction() {
myCommand
return $?
}
retry=0
maxRetries=5