Skip to content

Instantly share code, notes, and snippets.

View ghostcode's full-sized avatar
🎯
Focusing

Zhuxy ghostcode

🎯
Focusing
View GitHub Profile
@ghostcode
ghostcode / WebGL-WebGPU-frameworks-libraries.md
Created November 30, 2023 05:52 — forked from dmnsgn/WebGL-WebGPU-frameworks-libraries.md
A collection of WebGL and WebGPU frameworks and libraries

A non-exhaustive list of WebGL and WebGPU frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are wip/outdated/not maintained anymore.

Engines and libraries

Name Stars Last Commit Description
three.js ![GitHub Rep
@ghostcode
ghostcode / clipboard.js
Created October 17, 2023 04:04 — forked from viclafouch/clipboard.js
How to copy an image or a text to clipboard in Javascript (new way !) See https://copy-to-clipboard.now.sh/
// @return Promise<boolean>
async function askWritePermission() {
try {
// The clipboard-write permission is granted automatically to pages
// when they are the active tab. So it's not required, but it's more safe.
const { state } = await navigator.permissions.query({ name: 'clipboard-write' })
return state === 'granted'
} catch (error) {
// Browser compatibility / Security error (ONLY HTTPS) ...
return false
@ghostcode
ghostcode / get-latest-tag-on-git.sh
Created April 23, 2023 10:47 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@ghostcode
ghostcode / async&await.js
Created February 16, 2023 12:10
async&await 并行/串行優化
function getData() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(1)
},2000)
})
}
async function get() {
@ghostcode
ghostcode / uni-app表格组件
Created January 18, 2023 08:58
表格组件
‎‎​
@ghostcode
ghostcode / getPrecision.js
Last active January 12, 2023 05:57
获取精度
function getPrecision(value) {
const valueString = value.toString();
if (valueString.indexOf('e-') >= 0) {
return parseInt(valueString.slice(valueString.indexOf('e-') + 2), 10);
}
let precision = 0;
if (valueString.indexOf('.') >= 0) {
precision = valueString.length - valueString.indexOf('.') - 1;
}
return precision;
@ghostcode
ghostcode / throttle.md
Last active December 21, 2022 01:27
throttle
  function throttle(fn,wait=3000){
		let lastTime = Date.now(),
			timeFlag = null
			
		return function(...args){
			let current = Date.now()
			
			clearTimeout(timeFlag)
 
<!DOCTYPE HTML>
<html lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Zooming via HTML5 Canvas Context</title>
<style type="text/css" media="screen">
body { background:#eee; margin:1em; text-align:center; }
canvas { display:block; margin:1em auto; background:#fff; border:1px solid #ccc }
</style>
</head><body>
@ghostcode
ghostcode / deep-merge.js
Created June 8, 2022 07:41 — forked from ahtcx/deep-merge.js
Deep-Merge JavaScript objects with ES6
// ⚠ IMPORTANT: this is old and doesn't work for many different edge cases but I'll keep it as-is for any of you want it
// ⚠ IMPORTANT: you can find more robust versions in the comments or use a library implementation such as lodash's `merge`
// Merge a `source` object to a `target` recursively
const merge = (target, source) => {
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
for (const key of Object.keys(source)) {
if (source[key] instanceof Object) Object.assign(source[key], merge(target[key], source[key]))
}
@ghostcode
ghostcode / iframe.html
Created June 7, 2022 05:44 — forked from cirocosta/iframe.html
Sending messages from child iframe to parent webpage
<!DOCTYPE html>
<html>
<head>
<title>My Iframe</title>
</head>
<body>
<button>Botão</button>
<script type="text/javascript">