Skip to content

Instantly share code, notes, and snippets.

View LeafChage's full-sized avatar
🌱
kusa

takaya kusanagi LeafChage

🌱
kusa
View GitHub Profile
@LeafChage
LeafChage / chan.ts
Created January 4, 2025 15:03
Typescript Channel like golang
import { Queue } from "queue"; // https://gist.github.com/LeafChage/c271d5aee7ba3bf0156e2633c00c7f63#file-queue-ts
import { sleep } from "bun";
type Config = {
/**
* @description (ms)
*/
checkInterval: number
/**
@LeafChage
LeafChage / queue.test.ts
Created January 4, 2025 14:59
typescript queue
import { expect, test } from "bun:test";
import { Queue } from ".";
test("enqueue", () => {
const queue = new Queue([1]);
queue.enqueue(2);
expect(queue["items"]).toEqual([1, 2]);
});
test("dequeue", () => {
@LeafChage
LeafChage / espeak.go
Created December 21, 2024 09:33
Call espeak-ng from golang
package espeak
// #cgo LDFLAGS: -lespeak-ng
// #include <stdio.h>
// #include <stdlib.h>
// #include "wrap-espeak.h"
import "C"
import "unsafe"
func Speak() {
@LeafChage
LeafChage / parser.test.ts
Created February 16, 2023 01:20
parser.ts
import { parser } from '.';
describe("parser", () => {
describe("token", () => {
it("ok", () => {
expect(parser.token("t")("token")).toEqual([true, "t", "oken"]);
})
})
describe("any", () => {
it("ok", () => {
///
/// Thank you!
/// ref: https://mbuffett.com/posts/bevy-snake-tutorial/
///
/// rustc 1.66.0 (69f9c33d7 2022-12-12)
///
/// ```Cargo.toml
/// [package]
/// name = "bevy_tutorial"
/// version = "0.1.0"