Skip to content

Instantly share code, notes, and snippets.

View Shuumatsu's full-sized avatar

为世人降下祝福 Shuumatsu

View GitHub Profile
@Shuumatsu
Shuumatsu / riscv.md
Created December 24, 2020 07:51 — forked from cb372/riscv.md
Writing an OS in Rust to run on RISC-V

(This is a translation of the original article in Japanese by moratorium08.)

(UPDATE (22/3/2019): Added some corrections provided by the original author.)

Writing your own OS to run on a handmade CPU is a pretty ambitious project, but I've managed to get it working pretty well so I'm going to write some notes about how I did it.

@Shuumatsu
Shuumatsu / tokenizer.mll
Created April 10, 2019 12:43 — forked from lindig/tokenizer.mll
Some Scanning Recipes for OCamlLex
{
(* short names for important modules *)
module L = Lexing
module B = Buffer
type token =
| STR of string
| INT of int
| ID of string
| PLUSEQ
@Shuumatsu
Shuumatsu / parse-es6-template.js
Created July 24, 2017 15:19 — forked from smeijer/parse-es6-template.js
ES6 template string parser
function get(path, obj, fb = `$\{${path}}`) {
return path.split('.').reduce((res, key) => res[key] || fb, obj);
}
function parseTpl(template, map, fallback) {
return template.replace(/\$\{.+?}/g, (match) => {
const path = match.substr(2, match.length - 3).trim();
return get(path, map, fallback);
});
}
@Shuumatsu
Shuumatsu / alibaba_online_test_nodejs.js
Created March 2, 2017 10:20 — forked from MrRaindrop/alibaba_online_test_nodejs.js
阿里校招在线笔试nodejs题
/**
* 实现一个nodejs的Master-Worker的小程序,要求:
* 1. Master维护与cpu核数相同的Worker的数量;
* 2. Master接收到Worker的disconnect消息时,重启新的Worker进程;
* 3. Worker监听1024端口并输出“Hello World”;
* 4. 在Worker遇到uncaughtException时,通知Master进程并等待3s后退出
*/
var os = require('os'),
cluster = require('cluster'),
@Shuumatsu
Shuumatsu / API.md
Created September 19, 2016 15:34 — forked from anonymous/API.md
@Shuumatsu
Shuumatsu / co.js
Created June 3, 2016 10:37 — forked from iwillwen/co.js
A simple version of co
/**
* A simple co
* @param {Function} fn Generator Function
* @return {Function} callback
*/
function co(fn) {
return function(done) {
done = done || function() {};
var gen = fn();