Skip to content

Instantly share code, notes, and snippets.

View lynzrand's full-sized avatar

Rynco Maekawa lynzrand

View GitHub Profile
Result:
type: string // maybe int from enum?
value: string // id
Trigger:
type: string
value: string
Reaction:
id: string
@lynzrand
lynzrand / DetermineTextWidth.cs
Created April 27, 2019 14:45
Determining a Text's width in characters
public static Vector2Int GetConsoleSize(Text text)
{
text.font.RequestCharactersInTexture(" ", text.fontSize, text.fontStyle);
text.font.GetCharacterInfo(' ', out CharacterInfo info, text.fontSize, text.fontStyle);
var scaleFactor = text.canvas.scaleFactor;
// Unity requires fonts to be pixel perfect whether the "pixel perfect"
// tick is ticked or not in the root canvas
float fontWidth = Mathf.Round(info.advance * scaleFactor) / scaleFactor;
@lynzrand
lynzrand / _.cs
Created April 27, 2019 14:47
Wrong Code - Determining a text's width in characters
public static Vector2Int GetConsoleSize(Text text)
{
text.font.RequestCharactersInTexture(" ", text.fontSize, text.fontStyle);
text.font.GetCharacterInfo(' ', out CharacterInfo info, text.fontSize, text.fontStyle);
var scaleFactor = text.canvas.scaleFactor;
float fontWidth = info.advance;
float fontHeight = text.fontSize * text.lineSpacing;
@lynzrand
lynzrand / grammar.txt
Last active January 16, 2020 10:18
HOCON grammar
EOL -> '\n' | '\r' | '\r\n'
Whitespace -> ' ' | '\t'
EscapedSequence ->
| '\\' [bfnrt\\]
| '\u' [0-9a-fA-F]{4}
QuotedStringElement ->
| [^\\"]
// # Basic grammar elements
Identifier: [a-zA-Z] [_0-9a-zA-Z]* | _ [_0-9a-zA-Z]+
DecimalInteger: "0" | [1-9] [0-9]+
DecimalFractionalPart: "." [0-9]+
DecimalExponentPart: [Ee] [+-]? [0-9]+
HexadecimalNumber: "0x" [0-9a-fA-F]+
IntegerLiteral: (DecimalInteger | HexadecimalNumber)
FloatLiteral: DecimalInteger DecimalFractionalPart DecimalExponentPart?
| DecimalInteger DecimalExponentPart
@lynzrand
lynzrand / huffman.c
Created February 13, 2020 10:44
Huffman encoding (old OJ question)
#include <stdio.h>
int charrate[128] = {0};
typedef struct _HuffmanNode {
int w, p, lc, rc;
} hfn;
typedef struct _HuffmanCode {
int l;
unsigned long long v;
g,i,r,l=35,s=-20,f=10;e(s){write(1,&s,1);}main(){for(;s<21;s+=2){for(
g=20;g>-21;)i=s*s*s*g*g<<5,r=s*s+g*g-99,e(r*r*r+i<0?l:l-3),--g;e(f);}}

r0 虚拟机标准

本次大作业的编译目标是 r0 虚拟机 (r0vm) 的汇编 (s0)。其设计参考了 JVM、DotNet CLR 和上学期的 c0 虚拟机。

虚拟机简介

r0vm 是一个具有线性内存空间的栈式虚拟机。内存空间以 8 位(1 字节)为单位寻址,栈空间以 64 位(8 字节)为单位压栈弹栈。

TODO: 二进制格式

@lynzrand
lynzrand / 软件过程与质量索引.md
Last active September 12, 2023 01:54
软件过程与质量索引

软件过程与质量索引

前言、图例

PPT 本身就很乱……我尽量整理了。

感觉做 ppt 的人脑子是一团浆糊,很多地方逻辑乱七八糟的,标题层级也不一样,完全没有他做的软件过程标准那么精巧。或许这就是软件开发的常态吧(笑)

这篇文档说是索引,其实是介于索引和知识点总结之间的一个东西。希望它能对你的考试有所帮助吧。记得多用 Ctrl+F 查找。 >

@lynzrand
lynzrand / program.cs
Created August 26, 2020 02:28
Splitting stream & reading stuff inside
using System;
using System.Threading;
using System.IO;
using System.Threading.Tasks;
using System.Text.Unicode;
using System.Text;
using SharpCompress.Readers;
using MicroKnights.IO.Streams;
class Program