Skip to content

Instantly share code, notes, and snippets.

View skyzh's full-sized avatar
🐱
working

Alex Chi Z. skyzh

🐱
working
View GitHub Profile

MiniLSM: A Tutorial of Building Storage Engine in a Week using Rust

MiniLSM is a working-in-progress tutorial series for building a storage engine. Based on the experience of building AgateDB and RisingWave, MiniLSM introduces you the basics of an LSM-tree storage engine with a step-by-step tutorial.

The starter code is accessible on GitHub, and the tutorial is available on GitHub Pages.

What is LSM, and Why LSM?

@skyzh
skyzh / gat.rs
Created September 2, 2021 09:45
Demo of ArrayBuilder, Array and Datatype in Rust
#![feature(generic_associated_types)]
trait ArrayBuilder {
type ArrayType: Array<Builder = Self>;
fn new(capacity: usize) -> Self;
fn append<'a>(
&'a mut self,
value: Option<<<Self as ArrayBuilder>::ArrayType as Array>::RefItem<'a>>,
);
@skyzh
skyzh / upload.py
Last active January 7, 2021 09:33
import requests
from pathlib import Path
import time
import re
import base64
from lxml import etree
import os
from io import BytesIO
def gen_random_file(size):
@skyzh
skyzh / index.js
Created January 17, 2020 14:26
Generate .ics file from course table
const data = require('./data.json')
const debug = require('debug')('generator')
const _ = require('lodash')
const ics = require('ics')
const moment = require('moment')
const fs = require('fs')
const courses = data.kbList.filter(course => !course.ignore).map(course => ({
name: course.kcmc,
teacher: course.xm,
@skyzh
skyzh / blackbox_exporter.json
Created November 29, 2019 14:12
Grafana Dashboard for Blackbox Exporter
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@skyzh
skyzh / huffman.cpp
Created November 17, 2019 10:17
Huffman Encoding
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
struct Node {
@skyzh
skyzh / CE.cpp
Created October 15, 2019 11:05
Templated parameter with default value will throw compile error.
#include <iostream>
#include <functional>
using namespace std;
template <typename T>
bool compare_by_value(const T& a, const T& b) { return a < b; }
template <typename Comp>
bool alex_compare_int(const int& a, const int &b, Comp comp = compare_by_value) {
@skyzh
skyzh / index.html
Created July 25, 2019 01:02
Use d3.js to visualize collision between point and segment
<!DOCTYPE html>
<html>
<head>
<title>Physics Test</title>
</head>
<body>
<svg id="main" width="800" height="800"></svg>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="main.js"></script>
</body>
@skyzh
skyzh / contest_1_strategy.hpp
Last active July 25, 2019 11:31
PPCA 2019 Contest B Solution
#ifndef STRATEGY_HPP
#define STRATEGY_HPP
#include <vector>
#include <cstdlib>
#include <ctime>
#include "util.hpp"
#include <vector>
int cnt = 0;
#include <iostream>
#include <climits>
#include <cstring>
using namespace std;
template<typename T>
struct BST {
struct Node {
T x;