Skip to content

Instantly share code, notes, and snippets.

View suica's full-sized avatar
🎯
Focusing

Sg suica

🎯
Focusing
  • NetEase Hangzhou Institute
  • China
  • 14:22 (UTC +08:00)
View GitHub Profile
@suica
suica / Brewfile
Last active January 16, 2024 08:48
MacOS Development Setup
### generated by "brew bundle dump --describe"
tap "homebrew/bundle"
# Resource monitor. C++ version and continuation of bashtop and bpytop
brew "btop"
# Manage your dotfiles across multiple diverse machines, securely
brew "chezmoi"
# Diff that understands syntax
brew "difftastic"
# Modern replacement for 'ls'
@suica
suica / TAT.g4
Last active November 10, 2023 11:33
An ANTLR4 grammar for TAT
grammar TAT;
// Lexer Rules
fragment Num: '0'..'9';
Integer: ('1'..'9')Num+ | Num;
Float: Integer '.' Integer;
fragment Char: 'a'..'z' | 'A'..'Z';
@suica
suica / keybindings.json
Created July 30, 2023 08:26 — forked from bitterteasweetorange/keybindings.json
setup vscode like neovim
[
{
"command": "projectManager.listGitProjects#sideBarGit",
"key": "cmd+o"
},
{
"command": "expand_region",
"key": "ctrl+=",
"when": "editorTextFocus"
},
@suica
suica / 01_main.ts
Last active May 30, 2023 08:17
简单的面试题之目录树构建
/**
* 给一个字符串(是一段markdown文本),根据这个字符串生成出这段文本的目录结构
*/
/**
* 输入
*/
const input = `# Title h1
hsh
## Title h2 sibling
@suica
suica / vim-surround使用指南.MD
Created January 17, 2023 09:55 — forked from wilon/vim-surround使用指南.MD
vim-surround使用指南,vim-surround如何使用

普通模式

命令 说明 + 示例
ds 删除括号
ds " "Hello world!" =>
Hello world!
cs 替换括号
cs "( "Hello world!" =>
(Hello world!)
cS 替换括号,括号内文本做新一行
cS "{ "Hello world!" => {     Hello world! }
@suica
suica / construct_max.py
Created January 6, 2023 04:14
construct_max
from functools import lru_cache
def construct_max(s: str) -> int:
# run in O(len(s)**2)
@lru_cache(None)
def dp(start, end) -> int:
num_s = int(s[start])
num_e = int(s[end])
if start == end:
return num_s
haha = 10**(end-start)
@suica
suica / bytedance-promise.js
Created July 17, 2022 04:14
一道考察非常深入的promise面试题
/**
* 题目描述:
* 你在字节的面试中遇到了这样的代码。
* 1. 这份代码的输出是什么?
* 2. 这份代码有什么问题?如何修复这个问题?
*/
async function a() {
console.log('1');
const z = new Promise((resolve) => {
console.log('3');
@suica
suica / arrange.ts
Created July 17, 2022 03:43
Interview Coding Problems
// this problem is written by metis200, and can be found at https://github.com/metis200/FE-Exam
/**
* --- 问题描述 ---
*
* 实现一个 arrange 函数,可以进行时间和工作调度
*
* --- 说明 ---
*
* - 本题需要自己实现测试用例
* - 具体功能参考下列示例
@suica
suica / infinite-stream-problems.ts
Created July 6, 2022 17:53
Problems on infinite stream. 无穷流编程问题。
type List<T> = null | {
head(): T;
tail(): List<T>;
};
type Stream<T> = {
head(): T;
tail(): Stream<T>;
};
@suica
suica / little.js
Last active June 9, 2023 10:08
工业聚心爱的A Little JavaScript Problem
// statement https://lisperator.net/blog/a-little-javascript-problem/
const push = (stack, value) => (first) => first ? stack : value;
const range = (left, right) => (left > right ? null : push(range(left, right - 1), right));
const map = (stack, func) => (stack ? push(map(stack(1), func), func(stack(0))) : stack);
const foreach = (stack, func) => void map(stack, func);
const reverse = (stack, result = null) => stack ? reverse(stack(1), push(result, stack(0))) : result;