Skip to content

Instantly share code, notes, and snippets.

@teamrun
teamrun / colorDetector.js
Last active November 23, 2023 04:14
判断颜色是深色还是浅色 可以用来做背景色检测, 决定前景色(文字等)应该用浅色还是深色
const REG_HEX = /(^#?[0-9A-F]{6}$)|(^#?[0-9A-F]{3}$)/i;
/*
* rgb字符串解析
* accepts: #333 #accded (without # is also fine)
* not accept yet: rgb(), rgba()
*/
function parseRGB(str){
if(typeof str === 'string' && REG_HEX.test(str) ){
str = str.replace('#', '');
@chrisbanes
chrisbanes / FloatLabelLayout.java
Last active December 23, 2025 06:48
FloatLabelLayout
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@callumacrae
callumacrae / build-tools.md
Last active October 25, 2023 15:14
Build tools written in JavaScript
@shepherdwind
shepherdwind / getNum.js
Created July 9, 2012 06:22
fast way to find path
/* 后端数据 */
var data = {
"10;20;30": {
price: 5,
count: 1
},
"10;20;31": {
price: 10,
count: 2
},