Skip to content

Instantly share code, notes, and snippets.

View d1y's full-sized avatar
💤

小猫 d1y

💤
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://www.jq22.com/jquery/vue.min.js"></script>
<style>
* {
@d1y
d1y / check_localStorage_max_size.js
Created April 20, 2020 01:46
检测 localStorage 最大写入值
(function() {
//判断浏览器是否支持localStorage
if(!window.localStorage) {
console.log('当前浏览器不支持localStorage!');
return false;
}
var test = '0123456789';
//递归 加到10kb
var add = function(num) {
num += num;
@d1y
d1y / per.js
Created April 16, 2020 15:10
权限管理
//权限按钮控制指令
Vue.directive('auth', {
inserted: function (el, binding) {
let hasAuth = false;
if(Cookies.get('roles')){
let roles = JSON.parse(Cookies.get('roles'));
let value = binding.value;
roles.forEach(item => {
if (item === value) {
hasAuth = true;
@d1y
d1y / go-build-all
Created April 12, 2020 05:52 — forked from eduncan911/go-build-all
Go Cross-Compile Script
#!/bin/bash
#
# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script:
# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
#
# To use:
#
# $ cd ~/path-to/my-awesome-project
# $ go-build-all
#
@d1y
d1y / Makefile
Created April 12, 2020 05:51
go Makefile 示例
TIMESTAMP := $(shell /bin/date "+%F %T")
NAME := snowflake
VERSION := 1.0.3
LDFLAGS := -s -w \
-X 'main.BuildVersion=$(VERSION)' \
-X 'main.BuildGitBranch=$(shell git describe --all)' \
-X 'main.BuildGitRev=$(shell git rev-list --count HEAD)' \
-X 'main.BuildGitCommit=$(shell git rev-parse HEAD)' \
-X 'main.BuildDate=$(shell /bin/date "+%F %T")'
fmt:
@d1y
d1y / command_exists.go
Created April 7, 2020 07:07 — forked from miguelmota/command_exists.go
Golang check if command exists
package main
import (
"log"
"os/exec"
)
func main() {
path, err := exec.LookPath("ls")
if err != nil {
package main
import (
"fmt"
"io/ioutil"
"log"
)
func main() {
@d1y
d1y / io_cov_string_example.go
Created April 2, 2020 11:51
go [流]转为字符串
/*
** create by @d1y in 2020/04/02
** see: https://stackoverflow.com/questions/38673673/access-http-response-as-string-in-go
*/
package main
import (
"net/http"
"io/ioutil"
"log"
@d1y
d1y / ext.js
Created April 1, 2020 09:06
vscode 上下班小助手
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vscode = require("vscode");
const allConfig = vscode.workspace.getConfiguration();
const config = allConfig.gohome;
const GetOffMessage = '已经下班啦~ 赶紧滚回家去';
const NotificationMessage = '到点啦~ 该下班了!';
/** 获取提示消息 */
function getMessage() {
const now = new Date();
@d1y
d1y / readFile.go
Created March 30, 2020 09:12
go读取文件
package main
import (
"fmt"
"os"
)
func main() {
file, err := os.Open("filetoread.txt")
if err != nil {