This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <atomic> | |
#include <cassert> | |
#include <iostream> | |
#include <memory> | |
#include <mutex> | |
#include <thread> | |
#include <vector> | |
template <class T> | |
struct HazardPointer { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <list> | |
#include <unordered_map> | |
class LRUCache { | |
public: | |
LRUCache(int capacity) : capacity_(capacity) {} | |
int get(int key) { | |
auto it = used_.find(key); | |
if (it == used_.end()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Need C++ 11 | |
#include <functional> | |
#include <iostream> | |
class A { | |
public: | |
template <class F> | |
auto operator-(const F &func) -> typename std::result_of<F()>::type { | |
return func(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <dlfcn.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <unistd.h> | |
static bool is_hook = false; | |
int main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <arpa/inet.h> | |
#include <ctype.h> | |
#include <errno.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/epoll.h> | |
#include <unistd.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdint.h> | |
#include <vector> | |
extern "C" void swap_context(void *, void *) asm("swap_context"); | |
asm(R"( | |
swap_context: | |
mov 0x00(%rsp), %rdx | |
lea 0x08(%rsp), %rcx | |
mov %r12, 0x00(%rdi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <atomic> | |
#include <cassert> | |
#include <iostream> | |
using namespace std; | |
template <class T> | |
class MutableRef; | |
template <class T> | |
class ImmutableRef; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Switch to Specific Input Source for macOS | |
* Author: SF-Zhou<[email protected]> | |
* To English: g++ -framework Foundation -framework Carbon -std=c++11 -O2 change-input-source.cpp -o switch-to-english | |
* To Pinyin: g++ -framework Foundation -framework Carbon -std=c++11 -O2 change-input-source.cpp -D PINYIN -o switch-to-pinyin | |
*/ | |
#include <string> | |
#include <Carbon/Carbon.h> | |
#include <ApplicationServices/ApplicationServices.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"title": "LRSchedulerConfigs", | |
"description": "LR Scheduler Configs for PyTorch", | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/LRSchedulerConfig" | |
}, | |
"definitions": { | |
"LRSchedulerConfig": { |
NewerOlder