Skip to content

Instantly share code, notes, and snippets.

View LaughingVzr's full-sized avatar
🎯
Focusing

Laughing LaughingVzr

🎯
Focusing
View GitHub Profile
@LaughingVzr
LaughingVzr / useThis.js
Created July 11, 2018 08:56
[JavaScript This的应用] #javascript #EMACScript
document.getElementById=(function(func){
return function(){
return func.apply(document,arguments);
}
})(document.getElementById);
var getId = document.getElementById;
var div = getId('div1');
console.log(div.id);
@LaughingVzr
LaughingVzr / jsonStrConvert.go
Created July 11, 2018 08:54
[Golang原生json包[]interface转[]string] #golang #json
// 对参数进行断言,确定类型并获取参数
if targetParam, ok := params["a"].([]interface{}); ok {
for _, param := range targetParam {
switch v := param.(type) {
case string:
paramArr = append(paramArr, v)
case float64:
paramArr = append(paramArr, strconv.FormatFloat(v, 'f', 0, 64))
case int64:
paramArr = append(paramArr, strconv.FormatInt(v, 10))
@LaughingVzr
LaughingVzr / fileReadLine.go
Created July 11, 2018 08:53
[Golang 按行读取配置文件] #golang #file
// readTestFile 按行读取配置文件
func readTestFile(path string) []string {
var arr []string
file, err := os.Open(path)
if err != nil {
fmt.Println(err)
return arr
}
defer file.Close()
@LaughingVzr
LaughingVzr / sort.go
Created July 11, 2018 08:52
[Golang实现自定义sort接口(根据结构值排序)] #golang #sort
package node
type node struct {
key string // 键名
count int // 总个数
}
type nodeList []node
func (nl nodeList) Len() int {
@LaughingVzr
LaughingVzr / isChinese.java
Last active November 19, 2019 09:24
[Java判断字符是否是汉字]汉字判断 #java #character util
/**
* CharacterUtils
*
* @author Laughing
* @date 2018/7/11 15:24
* Description:
*/
public class CharacterUtils {
/**
* 判断一个字符是否是中文
@LaughingVzr
LaughingVzr / ellipsis.html
Created May 18, 2016 10:01 — forked from DeronW/ellipsis.html
CSS 将显示不完的多余字符用省略号代替兼容各主要浏览器 IE6+、FF、Chrom
单行文本方法, 通过CSS即可解决
<style>
p{
width: 100px;
display: block;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
-icab-text-overflow: ellipsis;
-khtml-text-overflow: ellipsis;