Skip to content

Instantly share code, notes, and snippets.

View lumixraku's full-sized avatar
🌴
On vacation

lumix lumixraku

🌴
On vacation
View GitHub Profile
#Requires AutoHotkey v2.0
LAlt::RCtrl
^e::Send "#1"
CapsLock & E::Send "{End}"
CapsLock & A::Send "{Home}"
CapsLock & c::Send "^z"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>上下分层提高 Canvas 书写性能</title>
<style>
body,
html {
@lumixraku
lumixraku / gist:64e07d4960b533261e88fa7f5bb28072
Created January 27, 2024 13:58
createImageBitmap & fetch
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<img hidden id="img" src="" />
@lumixraku
lumixraku / Unit8Array to Image, SkiaImage
Last active January 5, 2024 11:55
Unit8Array to Image, SkiaImage
const blob = new Blob([skiaImage.encodeToBytes()], { type: 'image/png' })
const imageUrl = URL.createObjectURL(blob);
const img = new Image();
img.src = imageUrl;
document.body.appendChild(img)
const getOffset = el => {
const {
top,
left
} = el.getBoundingClientRect()
const {
scrollTop,
scrollLeft
} = document.body
return {
// 运用正则去掉空格
' s123s'.replace(/^(\s*)(.+)(\s*)$/, '$2')
// 日期操作
const dataPattern = (str, format = '-') => {
if (!str) {
return new Date()
}
const dateReg = new RegExp(`^(\\d{2})${format}(\\d{2})${format}(\\d{4})$`)
const [, month, day, year] = dateReg.exec(str)
@lumixraku
lumixraku / curry.js
Last active September 11, 2020 16:01
const curring = fn => {
const { length } = fn
const curried = (...args) => {
return (args.length >= length
? fn(...args)
: (...args2) => curried(...args.concat(args2)))
}
return curried
}
@lumixraku
lumixraku / splitarr.js
Created September 11, 2020 14:48
数组分组
const listChunk = (list, size = 1, cacheList = []) => {
const tmp = [...list]
if (size <= 0) {
return cacheList
}
while (tmp.length) {
cacheList.push(tmp.splice(0, size))
}
return cacheList
}
class Http {
public static Inst(): Http {
if (null == Http._inst) {
Http._inst = new Http();
}
return Http._inst;
}
private static _inst: Http;
public constructor() {
@lumixraku
lumixraku / sleep&wake&switch.js
Last active May 18, 2020 09:29
Phaser sleep & wake (using switch)
var SceneA = new Phaser.Class({
Extends: Phaser.Scene,
initialize:
function SceneB() {
Phaser.Scene.call(this, 'sceneA');
this.pic;