This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Token { | |
Value(Int) | |
LParen; | |
RParen; | |
Plus; | |
Minus; | |
Multiply; | |
Divide; | |
} derive(Debug) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ___ _ __ ___ __ ___ | |
; / __|_ _ __ _| |_____ / /| __|/ \_ ) | |
; \__ \ ' \/ _` | / / -_) _ \__ \ () / / | |
; |___/_||_\__,_|_\_\___\___/___/\__/___| | |
; An annotated version of the snake example from Nick Morgan's 6502 assembly tutorial | |
; on http://skilldrick.github.io/easy6502/ that I created as an exercise for myself | |
; to learn a little bit about assembly. I **think** I understood everything, but I may | |
; also be completely wrong :-) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
UPDATED for 2023 - Now much simpler. The old tricks are no longer needed. | |
The following code makes an 800×600 canvas that is always as sharp as possible for the device. | |
You still draw on it as if it's the logical size (800×600 in this case), but everything just | |
looks sharper on high-DPI screens. Regular non-sharp screens are not affected. | |
*/ | |
const width = 800 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
/** createSignal for react */ | |
export function createSignal<S>( | |
initialState: S | |
): [() => S, (nextState: S) => void] { | |
const forceRender = useForceRender(); | |
const stateRef = React.useRef<S>(initialState); | |
const stateRefGetter = (): S => stateRef.current; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export enum Units { | |
B = 1, | |
KB = 1 * 1024, | |
MB = 1 * 1024 * 1024, | |
GB = 1 * 1024 * 1024 * 1024, | |
TB = 1 * 1024 * 1024 * 1024 * 1024, | |
} | |
const UnitsName = ['B', 'KB', 'MB', 'GB', 'TB']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 实现任意 increment 的任意数字的 rounding 操作; | |
* 比如 Math.round(n) 其实就是 genericRound(n, 1) 的特化 | |
*/ | |
export function genericRound(n: number, inc: number): number { | |
if (inc === 0) return n; | |
const d = (n % inc); | |
if (d >= (inc / 2)) return n + (inc - d); | |
return n - d; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (list->tree elements) | |
(car (partial-tree elements (length elements)))) | |
(define (partial-tree elts n) | |
(if (= n 0) | |
(cons '() elts) | |
(let ((left-size (quotient (- n 1) 2))) | |
(let ((left-result (partial-tree elts left-size))) | |
(let ((left-tree (car left-result)) | |
(non-left-elts (cdr left-result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Resolve VSCode Win7 Extension XHR Failed | |
run vscode with command line flag `--ignore-certificate-errors` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
fileprivate var counter = 0 | |
func withTimeoutUnsafeContinuation<T>( | |
_ labelName: String = "NoName", | |
_ timeout: TimeInterval = 2.0, | |
_ fn: @escaping (UnsafeContinuation<T?, Never>) -> Void | |
) async -> T? { | |
let nth = counter + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* https://github.com/netnr/workers | |
* | |
* 2019-10-12 - 2022-05-05 | |
* netnr | |
* | |
* https://github.com/Rongronggg9/rsstt-img-relay | |
* | |
* 2021-09-13 - 2022-05-29 | |
* modified by Rongronggg9 |
NewerOlder