Skip to content

Instantly share code, notes, and snippets.

View skyzh's full-sized avatar
🐱
working

Alex Chi Z. skyzh

🐱
working
View GitHub Profile
@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"
}

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 / index.js
Created December 23, 2017 03:21
Export Anki cards to HTML
/*
How to use?
Install Node.js and run 'npm init', than install the dependency 'lodash'.
Install the Anki addon from 'https://ankiweb.net/shared/info/1788670778', and export your deck to JSON.
Run 'node index.js', and there will be a generated 'index.html'.
*/
const _ = require('lodash');
const fs = require('fs');
@skyzh
skyzh / class_generator.js
Last active September 9, 2021 02:58
Use predefined file to generate class table.
const data = require('./data');
const _ = require('lodash');
const moment = require('moment');
const ics = require('ics');
const fs = require('fs');
const timePeriod = (date, from, to) => {
const _from = moment(`${date} ${data.timetable.data[from - 1]}:00`);
const _end = moment(`${date} ${data.timetable.data[to - 1]}:00`).add(data.timetable.length, 'minute');
return [_from, _end];
@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 / 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 / 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;