Skip to content

Instantly share code, notes, and snippets.

View fuweid's full-sized avatar
🎯
Focusing

Fu Wei fuweid

🎯
Focusing
View GitHub Profile
@fuweid
fuweid / README.md
Created December 21, 2017 10:16 — forked from roachhd/README.md
EMOJI cheatsheet 😛😳😗😓🙉😸🙈🙊😽💀💢💥✨💏👫👄👃👀👛👛🗼🔮🔮🎄🎅👻

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. ✈ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: 😄

@fuweid
fuweid / hijack.txt
Created January 5, 2018 02:57 — forked from cpuspellcaster/hijack.txt
Docker Hijack Protocol
Stream details:
When using the TTY setting is enabled in POST, the stream is the raw data from the process PTY and client’s stdin. When the TTY is disabled, then the stream is multiplexed to separate stdout and stderr.
The format is a Header and a Payload (frame).
HEADER
The header contains the information which the stream writes (stdout or stderr). It also contains the size of the associated frame encoded in the last four bytes (uint32).
@fuweid
fuweid / Vagrantfile
Created February 9, 2018 10:08
Vagrantfile for multi-machine
# vim: set filetype=ruby:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "client" do |client|
client.vm.box = "centos/7"
client.vm.network "private_network",
ip: "192.168.33.2",
@fuweid
fuweid / fork-is-evil-vfork-is-good-afork-would-be-better.md
Created July 30, 2018 06:03 — forked from nicowilliams/fork-is-evil-vfork-is-good-afork-would-be-better.md
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid

I recently happened upon an implementation of popen() (different API, same idea) using clone(2), and so I opened an issue requesting use of vfork(2) or posix_spawn() for portability. It turns out that on Linux there's an important advantage to using clone(2). I think I should capture the things I wrote there in a better place. A gist, a blog, whatever.

So here goes.

Long ago, I, like many Unix fans, thought that fork(2) and the fork-exec process spawning model were the greatest thing, and the Windows sucked for only having [exec*()](http://pubs.opengroup.org/onlinepubs/9699919

// Snapshot service manages snapshots
service Snapshots {
rpc Prepare(PrepareSnapshotRequest) returns (PrepareSnapshotResponse);
rpc View(ViewSnapshotRequest) returns (ViewSnapshotResponse);
rpc Mounts(MountsRequest) returns (MountsResponse);
rpc Commit(CommitSnapshotRequest) returns (google.protobuf.Empty);
rpc Remove(RemoveSnapshotRequest) returns (google.protobuf.Empty);
rpc Stat(StatSnapshotRequest) returns (StatSnapshotResponse);
rpc Update(UpdateSnapshotRequest) returns (UpdateSnapshotResponse);
rpc List(ListSnapshotsRequest) returns (stream ListSnapshotsResponse);
@fuweid
fuweid / main.go
Created May 22, 2019 07:13
kubeCon 2019 EU - recompile containerd with 3rd party plugins
// based on https://github.com/AkihiroSuda/containerd-example-custom-daemon
package main
import (
"fmt"
"os"
"github.com/containerd/containerd/cmd/containerd/command"
// built-in plugins from cmd/containerd/builtins.go

containerd 1.2.7

Welcome to the v1.2.7 release of containerd!

The seventh patch release for containerd 1.2 introduces OCI image descriptor annotation support and contains fixes for containerd shim logs, container stop/deletion, cri plugin and selinux.

It also contains several important bug fixes for goroutine and

@fuweid
fuweid / spill-pseudocode
Last active October 13, 2019 13:13
boltdb - medium article
set minKeysPerPage = 2
function spill: node t
if t is spilled
return
mark node t as spilled
# if there are a lot of keys in one node but the node doesn't take more space,
# there is no need to split the node. boltdb assumes that one page should
# have two keys at least.
#
@fuweid
fuweid / gist:219156561610f4e6d8688417a87d0c3d
Created October 13, 2019 13:18
splitIntoNodes-pseudocode
function splitIntoNodes: node t
let nodes = []node{} # empty slice for node
while ture
if t is empty
break
t, next = call splitIntoTwos: node t
appends t into nodes
@fuweid
fuweid / main.c
Created April 4, 2020 09:55
signal blocking
#include<stdio.h>
#include<signal.h>
#include<unistd.h>
int sigusr1_catched = 0;
int sigusr2_catched = 0;
void sigusrone_handler(int _){
fprintf(stdout, "in handler: caught SIGUSR1\n");
sigusr1_catched = 1;