Skip to content

Instantly share code, notes, and snippets.

@cheukw
cheukw / spinlock.h
Created September 18, 2019 12:31 — forked from cybertxt/spinlock.h
spinlock in c++11 based on atomic_flag
#ifndef _SPINLOCK_H_20170410_
#define _SPINLOCK_H_20170410_
#include <atomic>
class spinlock {
public:
spinlock() { m_lock.clear(); }
spinlock(const spinlock&) = delete;
~spinlock() = default;
@cheukw
cheukw / Makefile
Created December 26, 2018 10:13 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@cheukw
cheukw / vimrc
Created December 26, 2018 06:27 — forked from jaseflow/vimrc
" Combination of these setting plus others
" http://amix.dk/vim/vimrc.html
" https://github.com/jaysw/dotfiles/blob/master/vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => https://github.com/junegunn/vim-plug
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
filetype off " required
call plug#begin('~/.vim/plugged')
Plug 'davidhalter/jedi-vim', { 'for': 'python' }
@cheukw
cheukw / README-Template.md
Created December 26, 2018 03:22 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@cheukw
cheukw / System Design.md
Created December 26, 2018 03:22 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
#include <stdio.h>
#include <winsock2.h>
#include <stdbool.h>
#include "wepoll.h"
#pragma comment(lib,"ws2_32.lib")
#define MAXEVENTS 64
#define BUF_SIZE 100
@cheukw
cheukw / portable_endian.h
Created August 24, 2017 08:49 — forked from panzi/portable_endian.h
This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, and Mac OS X. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh. License: I hereby put "port…
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)