Skip to content

Instantly share code, notes, and snippets.

View Alan-Liang's full-sized avatar

Alan L Alan-Liang

View GitHub Profile
@Alan-Liang
Alan-Liang / Heredoc.g4
Created July 17, 2022 02:06
Heredoc in ANTLR 4 demo
grammar Heredoc;
@lexer::members {
public boolean heredocValid (String str) {
String[] lines = str.split("\n");
String first = lines[0], last = lines[lines.length - 1];
return first.substring(2).equals(last);
}
}
@Alan-Liang
Alan-Liang / complex.ak
Last active August 3, 2022 06:02
Early explorations of the AnotherKit language
// -*- mode: Rust; -*-
class Complex (
RealType extends Math.Field = Float,
ImagType extends Math.Field = RealType,
) extends Math.Field {
constructor (real: RealType, imag: ImagType) {}
fn + (that: Complex) = Complex(real + that.real, imag + that.imag)
fn +-inverse = Complex(-real, -imag)
fn abs = (this * conj).real.sqrt()

程设课的目的

作业要有目的性; 班级的培养目标是什么? 什么是「计算机科学家」? 实际上, 抑或是「工程师」?

目的直接决定了课程设置的方向和思路。

大的课程思路

自顶向下? 自底向上? 实验入手? whatever?

@Alan-Liang
Alan-Liang / teleport.js
Created January 13, 2021 10:14
Vue 2 teleport
/**
* Usage:
* <app-bar>
* <teleport-target name="app-bar" />
* </app-bar>
* And then:
* <teleport to="app-bar">
* <h1>Hello World!</h1>
* </teleport>
*/
<template>
<main>
<p v-if="loading">Loading todos...</p>
<p v-else-if="loadError">Error loading todos: {{ loadError }}</p>
<template v-else>
<p>Add a todo: <input v-model="newTodo"> <button @click="addTodo">add</button></p>
<ul>
<li v-for="todo in todos" :key="todo.localId"><button @click="removeTodo(todo)">Remove</button> {{ todo.content }}</li>
</ul>
</template>
#!/usr/bin/env node
const readline = require('readline')
const printer = require('node-native-printer')
const [ ,, filePath, pageCount, printerName ] = process.argv
if (!filePath || !pageCount) process.exit(-1)
const print = function (options) {
const res = printer.print(filePath, options, printerName || 'HP_LaserJet_Professional_M1136_MFP')
if (!res) throw 'No result from CUPS'
@Alan-Liang
Alan-Liang / lib.js
Created July 28, 2020 10:26
f(?) is true?
const ᆖ=9007199254740991,ᆖ‍=67108864,ᆖ‌=1145141,ᆖ‍‍=1,f=ᆖ‍‌=>ᆖ‍‌>ᆖ‍&&ᆖ‍‌*ᆖ‍‌<ᆖ&&ᆖ‍‌===ᆖ‍‌&&!((ᆖ‌‍,ᆖ‌‌,ᆖ‍‍‍,ᆖ‍‍‌,ᆖ‍‌‍,ᆖ‍‌‌)=>ᆖ‍‍‌=ᆖ‌‍‍=>--ᆖ‌‍>ᆖ‍‍?((ᆖ‍‌‍=ᆖ‌‍‍=>--ᆖ‌‌>ᆖ‍‍?((ᆖ‍‌‌=ᆖ‌‍‍=>--ᆖ‍‍‍>ᆖ‍‍?(ᆖ‌‍=(ᆖ‌‍*ᆖ‌‌)%ᆖ‌,ᆖ‌‌=(ᆖ‌‍*ᆖ‌‌)%ᆖ‌,ᆖ‍‌‌()):ᆖ‌‍‍)(),ᆖ‍‌‍()):ᆖ‌‍‍)(),ᆖ‍‍‌()):ᆖ‌‍&&ᆖ‌‌)(ᆖ‍‌,ᆖ‍‌,ᆖ‍‌)()
@Alan-Liang
Alan-Liang / keybase.md
Last active August 27, 2022 06:32
Keybase

Keybase proof

I hereby claim:

  • I am Alan-Liang on github.
  • I am alanliang (https://keybase.io/alanliang) on keybase.
  • I have a public key whose fingerprint is D80E 1B95 F4D7 2DC8 D8D5 ED13 ADDA 8090 B117 1126

To claim this, I am signing this object:

@Alan-Liang
Alan-Liang / Related URLs
Last active March 27, 2020 03:05
GitHub Pages bad cert
@Alan-Liang
Alan-Liang / music.py
Created March 18, 2020 23:41
Music preprocessing
# TODO
import librosa
import json
import time
__version__ = 1
__authors__ = ['Alan-Liang']