Skip to content

Instantly share code, notes, and snippets.

View royguo's full-sized avatar

Roy Guo royguo

  • Bytedance
  • Beijing
View GitHub Profile
@royguo
royguo / agent_rules.md
Created March 21, 2026 09:21
Agent Rules for KK

Skill:结构化编程工作流(Structured Coding Workflow — C++ Edition)

本文档定义了 AI 助手处理 C++ 项目中所有代码编写、优化、重构任务的标准工作流。 核心原则:不做假设,不跳步骤,每一步都可验证、可回滚,测试先行,重大操作先沟通。


〇、触发条件与角色定义

触发条件:当用户的请求涉及以下任何一项时,必须启动本工作流:

#include "io_engine.h"
namespace demo {
Status PosixAIOEngine::AsyncWrite(int fd, uint64_t offset, const char* buffer, uint64_t size,
char** cb) {
// TODO Check io_depth
requests_.push_back({.aio_req_ = {}, .type_ = kAsyncWrite});
auto& request = requests_.back();
memset(&request.aio_req_, 0, sizeof(struct aiocb));
@royguo
royguo / policy_aware_cache.cc
Created December 18, 2023 13:39
policy_aware_cache
#include "innovic/cache/policy_aware_cache.h"
#include <iostream>
#include <memory>
namespace innovic {
namespace cache {
void DRAMStore::Put(const std::string &key, std::shared_ptr<CachedValue> value) {
std::unique_lock<std::shared_mutex> write_lock(map_mutex_);
// Item exist
CMake ../ -DCMAKE_BUILD_TYPE=RelWithDebInfo 
          -DWITH_ZENFS=ON 
          -DWITH_TERARK_ZIP=OFF
          -DWITH_BYTEDANCE_METRICS=OFF
          -DWITH_TOOLS=ON
          -DWITH_TESTS=OFF
@royguo
royguo / mapsun.hpp
Last active December 23, 2018 09:23
test demo
// https://www.lintcode.com/problem/map-sum-pairs/description
class MapSum {
class TrieNode {
public:
unordered_map<char, TrieNode*> children;
int val = 0;
TrieNode() {}
TrieNode(const int& val) : val(val) {
@royguo
royguo / wiki-media.sql
Created June 15, 2017 04:26
WIKI Media SQL Schema
-- SQL to create the initial tables for the MediaWiki database.
-- This is read and executed by the install script; you should
-- not have to run it by itself unless doing a manual install.
-- This is a shared schema file used for both MySQL and SQLite installs.
--
-- For more documentation on the database schema, see
-- https://www.mediawiki.org/wiki/Manual:Database_layout
--
-- General notes:
jstests/aggregation/mongos_slaveok.js
jstests/aggregation/testshard1.js
jstests/aggregation/testSlave.js
jstests/aggregation/bugs/match.js
jstests/aggregation/bugs/server19095.js
jstests/aggregation/bugs/server21632.js
jstests/aggregation/bugs/server6118.js
jstests/aggregation/bugs/server6125.js
jstests/aggregation/bugs/server6179.js
jstests/aggregation/bugs/server6556.js
#include <iostream>
#include <terark/db/db_table.hpp>
#include <terark/io/MemStream.hpp>
#include <terark/io/DataIO.hpp>
#include <terark/io/RangeStream.hpp>
#include <terark/lcast.hpp>
#include "user.hpp"
package main;
import java.util.concurrent.atomic.AtomicReference;
public class CASCalculator extends CalculatorBase {
private enum Status {
NOT_STARTED,
STARTED,
DISPOSED
@royguo
royguo / Leaves.java
Last active December 30, 2015 08:29
Java Mail using Playframework
package controllers.oa;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import models.oa.Leave;
import models.oa.Vacation;
import models.system.User;