Skip to content

Instantly share code, notes, and snippets.


Wenxuan breeswish

View GitHub Profile
breeswish / iconv.js
Created Jan 13, 2017
Detect Charset and Convert to UTF-8
View iconv.js
var Iconv = require('iconv').Iconv;
var jschardet = require('jschardet');
return new Iconv(jschardet.detect(buf).encoding, 'UTF-8//TRANSLIT//IGNORE').convert(buf);
breeswish / biaori-to-anki.js
Last active Feb 21, 2021
将《新标准日语》的音频和单词导入到 Anki
View biaori-to-anki.js
const assert = require("assert").strict;
const child_process = require("child_process");
const path = require("path");
const crypto = require("crypto");
const glob = require("glob");
const fs = require("fs-extra");
const _ = require("lodash");
const sort = require("alphanum-sort");
const Kuroshiro = require("kuroshiro");
const KuromojiAnalyzer = require("kuroshiro-analyzer-kuromoji");
breeswish /
Created Jun 5, 2017
Insert matplotlib charts as vector image to MS Word


MS Word 2016 do support svg. But they are rasterized when exporting to PDF currently. Here is a workaround.


  1. Export as svg

  2. Use inkscape to convert dash into paths

breeswish / typora-theme.css
Created Jan 3, 2018
my personal Typora theme
View typora-theme.css
@include-when-export url(,700italic,700,400&subset=latin,latin-ext);
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: normal;
src: local('Open Sans Regular'),url('./github/400.woff') format('woff')
@font-face {
breeswish / webgl_renderer.js
Created Apr 30, 2018
GPU Accelerated Image Rendering (RGBA in Uint8Array) using WebGL
View webgl_renderer.js
(function () {
attribute vec4 a_position;
attribute vec2 a_texcoord;
varying vec2 v_texcoord;
void main() {
gl_Position = a_position;
breeswish / protobufjs-stream-decoder.js
Last active May 15, 2018
Protobuf.js 6+ Stream Decoder
View protobufjs-stream-decoder.js
import through2 from 'through2';
import { BufferReader } from 'protobufjs';
function decodeProtobuf(decodeFunc, msgMaxSize = 20 * 1000 * 1000) {
const buffer = Buffer.alloc(msgMaxSize);
const reader = new BufferReader(buffer);
let bufferLen = 0; // The length of valid data in buffer, may contain multiple messages
reader.pos = 0;
breeswish /
Last active Mar 6, 2020
AST vs RPN evaluation performance. JavaScript version:
//! AST vs RPN evaluation performance in Rust language.
extern crate test;
#[derive(Clone, Copy, Debug)]
pub enum Function {
breeswish /
Created Feb 2, 2019
A getting started example for rust-prometheus + hyper
extern crate lazy_static;
use hyper::rt::Future;
use hyper::service::service_fn_ok;
use hyper::{Body, Request, Response, Server};
use prometheus::*;
use rand::prelude::*;
lazy_static! {
breeswish /
Created Feb 3, 2019
A simple procedural macro that generates a static metric for rust-prometheus.
extern crate proc_macro;
use quote::quote;
use proc_macro::TokenStream;
use syn::*;
use syn::parse::{Parse, ParseStream};
struct MetricDefinition {
vis: Visibility,
from __future__ import print_function
import argparse
import json
import os
import sys
def collect_mtime_list(path):