Skip to content

Instantly share code, notes, and snippets.

@wewindy
wewindy / FileSystemAPI.html
Created May 24, 2021 05:53
异步选择文件或文件夹 API
<button id="btn">ClickMe</button>
<script>
const btn = document.getElementById('btn')
let fileHandle
btn.addEventListener('click', async () => {
[fileHandle] = await window.showOpenFilePicker()
const file = await fileHandle.getFile()
const contents = await file.text()
console.log(contents)
})
@wewindy
wewindy / PolylineTrailLinkMaterialProperty.js
Last active June 3, 2021 09:17
Cesium Polyline Trail Material Property
import { Color, defined, Event, Material, Property } from 'cesium'
const PolylineTrailLinkType = 'PolylineTrailLink'
const PolylineTrailLinkSource = /* glsl */`
czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
@wewindy
wewindy / eclosion.frag
Created June 29, 2021 09:54
边缘羽化片元着色器
uniform sampler2D Tex;
const float size = 0.5;
void main(void)
{
vec2 realSize = vec2(textureSize(Tex, 0));
float ratio = (realSize.x > realSize.y) ? realSize.y/realSize.x : realSize.x/realSize.y;
vec2 texSize = vec2(512., 512.);
vec2 xy = gl_FragCoord.xy;
@wewindy
wewindy / using_with_expression.sql
Created July 24, 2021 21:50
postgis_sql_example
with temp_result as (
select st_point(1, 2) as test_point
)
select st_asgeojson(test_point) as final_result from temp_result;
@wewindy
wewindy / moment-demo.js
Created August 2, 2021 06:49
A simple custom moment format demo
import moment from 'moment'
moment(`2010/1/1 19:20:59.990`, 'YYYY/M/D HH:mm:ss.SSS')
// 解析到的月份是0开头的
@wewindy
wewindy / isMobile.js
Created September 12, 2021 21:36
Regexp isMobile
const isMobile = /android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm(os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent);
if (isMobile) {
location.replace('手机页面');
} else {
location.replace('PC页面');
}
/*
作者:菜鸟码农Java笔记
链接:https://www.zhihu.com/question/485560131/answer/2116400654
@wewindy
wewindy / isCCW.ts
Created December 6, 2021 02:19
is-clockwise
type Point = [number, number, number?]
const isCCW = (p1: Point, p2: Point, p3: Point) => {
return (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) * (p3[0] - p1[0]) > 0
}
@wewindy
wewindy / index.css
Created December 21, 2021 10:27
prettyScrollBar
/* 滚动槽 */
::-webkit-scrollbar {
width : .5rem;
height: .5rem;
}
::-webkit-scrollbar-track {
border-radius : .25rem;
background : rgba(0, 0, 0, 0.06);
box-shadow : inset 0 0 .4rem rgba(0, 0, 0, 0.08);
@wewindy
wewindy / snazzy.json
Created February 9, 2022 07:13
WindowsTerminal ColorSchemas
{
"background": "#1E1F29",
"black": "#000000",
"blue": "#49BAFF",
"brightBlack": "#818181",
"brightBlue": "#49BAFF",
"brightCyan": "#8BE9FE",
"brightGreen": "#50FB7C",
"brightPurple": "#FC4CB4",
"brightRed": "#FC4346",
@wewindy
wewindy / fragment.glsl
Created February 17, 2022 06:57
shader-useful-function
uniform vec2 u_resolution;
// 接受一个二维向量,返回一个伪随机值
float rand(const vec2 seed) {
float t = dot(vec2(12.9898, 78.233), seed);
return fract(sin(t) * (4375.85453 + t));
}
void main() {
vec2 st = gl_FragCoord.xy / u_resolution.xy;