Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

James Liu jamesliu96

💭
I may be slow to respond.
View GitHub Profile
View play_youtube.sh
play_youtube() {
G=(`youtube-dl -g $1`)
echo ${G[1]}
echo ${G[2]}
ffmpeg -i ${G[1]} -i ${G[2]} -c:v copy -c:a copy -f matroska - | ffplay -
}
@jamesliu96
jamesliu96 / bfvm.js
Last active Mar 8, 2021
Brainfuck VM
View bfvm.js
/** Brainfuck VM */
class BFVM {
static Ops = ['>', '<', '+', '-', '.', ',', '[', ']'];
#ptr = 0;
get ptr() {
return this.#ptr;
}
#idx = 0;
get idx() {
View gui.go
package main
import (
"fmt"
"image"
"image/draw"
"image/png"
"math/rand"
"os"
"runtime"
View random.js
const random = (c, b = 256) => [...Array(c)].map((_) => ~~(Math.random() * b));
View console.prefab
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
View isArrowFunction.js
function isArrowFunction(f) { return typeof f === 'function' && typeof f.prototype === 'undefined' }
View omelette.js
var Mode;
(function (Mode) {
Mode[(Mode['Pad'] = 0)] = 'Pad';
Mode[(Mode['Bool'] = 1)] = 'Bool';
Mode[(Mode['Byte'] = 2)] = 'Byte';
Mode[(Mode['U_Byte'] = 3)] = 'U_Byte';
Mode[(Mode['Word'] = 4)] = 'Word';
Mode[(Mode['U_Word'] = 5)] = 'U_Word';
Mode[(Mode['DWord'] = 6)] = 'DWord';
Mode[(Mode['U_DWord'] = 7)] = 'U_DWord';
View primitive.js
const Primitives = {
uint8: Uint8Array,
uint16: Uint16Array,
uint32: Uint32Array,
int8: Int8Array,
int16: Int16Array,
int32: Int32Array,
float32: Float32Array,
float64: Float64Array,
};
View muse.ts
const { ccclass, property } = cc._decorator;
const floor = (n: number) => ~~n;
const round = (n: number) => floor(n + 0.5);
function HSVtoRGB(h: number, s: number, v: number) {
let r: number,
g: number,
b: number,
i: number,
View flatten.js
export const flatten = (arr) => [].concat(...arr);
function* _flatten(arr) {
for (const item of arr) {
if (Array.isArray(item)) {
yield* _flatten(item);
} else {
yield item;
}
}