Skip to content

Instantly share code, notes, and snippets.

@kkspeed
kkspeed / simple_plot.cljs
Created March 25, 2019 17:45
Use D3 with Reagent
;; Assumes D3 is provided as foreign lib. Add following to :compiler section of build.
;; :foreign-libs [{:file "lib/d3.v5.js"
;; :provides ["d3"]
;; :requires ["d3"]}]
;; Then (require [d3]) in the code namespace.
(def performance-data [{:group 0
:name "Update()"
:start 200
:end 240}
{:group 0
@kkspeed
kkspeed / main.rs
Last active April 4, 2019 04:12
Protobuf 3 decode raw
use std::str::from_utf8;
fn main() {
println!(
"{}",
read_proto_raw(&[0x12, 0x07, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67]).unwrap()
);
println!(
"{}",
read_proto_raw(&[0x1a, 0x03, 0x08, 0x96, 0x01]).unwrap()
@kkspeed
kkspeed / csp_formula.cc
Created January 18, 2020 11:56
CSP化学方程式
#include <iostream>
#include <map>
#include <memory>
using Formula = std::map<std::string, int>;
class ParseContext {
public:
ParseContext(const std::string& string, int position):
string_(string), position_(position) {}