Skip to content

Instantly share code, notes, and snippets.

SF-Zhou

Block or report user

Report or block SF-Zhou

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@SF-Zhou
SF-Zhou / coroutine.cpp
Last active Sep 26, 2019
Coroutine Demo (libco)
View coroutine.cpp
#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)
@SF-Zhou
SF-Zhou / rust-like.cpp
Created Sep 10, 2019
Rust-like Ownership and Reference
View rust-like.cpp
#include <atomic>
#include <cassert>
#include <iostream>
using namespace std;
template <class T>
class MutableRef;
template <class T>
class ImmutableRef;
@SF-Zhou
SF-Zhou / set_input_source.cpp
Created Mar 10, 2019
Switch to Specific Input Source for macOS
View set_input_source.cpp
/*
* Switch to Specific Input Source for macOS
* Author: SF-Zhou<sfzhou.scut@gmail.com>
* 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>
@SF-Zhou
SF-Zhou / lr_scheduler.schema.json
Created Mar 2, 2019
JSON Schema of LR Scheduler
View lr_scheduler.schema.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "LRSchedulerConfigs",
"description": "LR Scheduler Configs for PyTorch",
"type": "array",
"items": {
"$ref": "#/definitions/LRSchedulerConfig"
},
"definitions": {
"LRSchedulerConfig": {
@SF-Zhou
SF-Zhou / simple_shared_ptr.cpp
Created Jan 25, 2019
Simple C++ Shared Ptr
View simple_shared_ptr.cpp
#include <iostream>
template <class T>
class SharedPtr {
public:
SharedPtr(T *rep = nullptr) : rep_(rep), count_ptr_(new int32_t(1)) {}
SharedPtr(const SharedPtr &obj) : count_ptr_(obj.count_ptr_), rep_(obj.rep_) {
increse();
}
@SF-Zhou
SF-Zhou / multi-threading.cpp
Created Dec 22, 2018
C++11 Producer + Consumer
View multi-threading.cpp
#include <chrono>
#include <iostream>
#include <mutex>
#include <queue>
#include <thread>
#include <vector>
std::mutex mutex;
std::queue<int> candidates;
std::condition_variable condition;
View gist:f042c56c32c85442a84f864854883e2b
127.0.0.1
10.5*
10.10*
[::1]
localhost
192.168*
*.cn
*.com.cn
*.edu.cn
*126.com
@SF-Zhou
SF-Zhou / HashTable.hpp
Created Jul 25, 2018
Hash Table, Clear Easily (C++ 11)
View HashTable.hpp
// Copyright [2018] <Copyright SF-Zhou>
// Author: SF-Zhou
// Email: sfzhou.scut@gmail.com
#ifndef HASHTABLE_HPP_
#define HASHTABLE_HPP_
#include <cstring>
namespace Utils {
@SF-Zhou
SF-Zhou / c.vimrc
Last active Nov 14, 2018
cVim Config
View c.vimrc
set noautofocus
let barposition = "bottom"
set smoothscroll
let scrollstep = 320
let scrollduration = 200
let blacklists = [
"https://*.overleaf.com/*"
]
View 2017.netease.brick.cpp
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
You can’t perform that action at this time.