Skip to content

Instantly share code, notes, and snippets.

View wyw's full-sized avatar

Yuanwei Wu wyw

  • 09:25 (UTC +08:00)
View GitHub Profile
@wyw
wyw / pimpl.cpp
Created June 14, 2017 11:08 — forked from cloudwu/pimpl.cpp
My version of pimpl
// My version of pimpl (cloudwu@gmail.com)
// See http://en.cppreference.com/w/cpp/language/pimpl
#include <iostream>
// interface (widget.h)
class widget {
struct impl;
public:
static widget* create(int); // replacement of new
@wyw
wyw / gist-comments-testing.markdown
Last active August 10, 2017 14:09
Gist comments testing

Gist comments testing

It works!
  • Test gist comments
  • Read GraphQL API docs
@wyw
wyw / tmux-cheatsheet.markdown
Created September 21, 2017 06:46 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

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

恢复会话:

tmux at [-t 会话名]
@wyw
wyw / mysql-docker.sh
Created November 17, 2017 11:26 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@wyw
wyw / proxmox-get-vm-ip.sh
Created November 22, 2017 03:48 — forked from pschmitt/proxmox-get-vm-ip.sh
Get the IP address of a VM hosted on Proxmox
#!/usr/bin/env bash
usage() {
echo "$(basename $0) VM"
}
get_vm_id() {
qm list | awk '/'"${1}"'/ { print $1 }'
}
@wyw
wyw / gist:4512dc44a23a1c1bd2f555b78d96412e
Created January 12, 2018 08:53 — forked from dmitshur/gist:6927554
How to `go get` private repos using SSH key auth instead of password auth.
$ ssh -A vm
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "git@github.com:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!
@wyw
wyw / util.php
Created January 15, 2018 10:55 — forked from aeurielesn/util.php
Decode Unicode strings in PHP
<?php
#source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
}
git branch -d $(git branch --merged | awk '{print $1}' | grep -v "*")
@wyw
wyw / hmac_sha256.py
Created March 13, 2018 03:41 — forked from theY4Kman/hmac_sha256.py
Python SHA-256 HMAC
from Crypto import HMAC, SHA256
def hmac_sha256(key, msg):
hash_obj = HMAC.new(key=key, msg=msg, digestmod=SHA256)
return hash_obj.hexdigest()
@wyw
wyw / monitor.php
Created May 26, 2018 15:14 — forked from jesobreira/monitor.php
Server Monitor
<?php
/*
The aim is to create a functional server monitor based on the one
showed on Mark Zuckerberg's monitor on The Social Network movie.
Run so:
php monitor.php
Notes:
- The server LogFormat must be "Common Log Format" (%h %^[%d:%^] "%r" %s %b)