Skip to content

Instantly share code, notes, and snippets.

View binary4cat's full-sized avatar
🤑
I may be slow to respond.

cat binary4cat

🤑
I may be slow to respond.
View GitHub Profile
@binary4cat
binary4cat / main.go
Last active November 6, 2018 14:11
Go HTTP接口简单例子
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
type UserInfo struct {
@binary4cat
binary4cat / element-upload-filetype.js
Created July 31, 2018 08:56
element ui 上传组件判断文件类型
/**
* 图片上传之前调用的事件
*/
beforeAvatarUpload(file) {
// 允许所有的图片类型
const isJPG = file.type.indexOf("image/") > -1;
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isJPG) {
this.$message.error("请上传图片文件!");
}
@binary4cat
binary4cat / windowOnfocus.js
Created April 26, 2018 07:18
js判断用户有没有操作页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js判断用户有没有操作页面</title>
</head>
<body>
<script>
@binary4cat
binary4cat / getUrlParameterByName.js
Last active April 25, 2018 03:23
JavaScript从url中获取指定query string的值
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
@binary4cat
binary4cat / HttpHelper.cs
Created March 21, 2018 08:49
c# HTTP请求帮助类
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Common
{
if(/<a[^>]*id\s*=\s*[\'"]js_btn_add_contact[\'"][^>]*style\s*=\s*[\'"]display:none;[\'"][^>]*>/i.test(serverResData.toString()) != true){
follow = '<script>var a = document.getElementById("js_btn_add_contact"); a.click(); </script>';
}
@binary4cat
binary4cat / gist:16f41a1ca3f0230431f58b9f26ec7de1
Last active April 25, 2018 03:18
微信公众号文章页自动滚动到底部
var jumpScript = '<script>'+
'function jumpIf(date=2000, jumpUrl=""){'+
'var doc = document.all[0].innerHTML;'+
'if( /<span[^>]*display\\:\\s*none[^>]*>\\.*?已无更多\\.*?<\\\/span>/i.test(doc) ){'+
'document.body.scrollTop = document.body.scrollHeight - (document.body.clientHeight && document.documentElement.clientHeight);'+
'setTimeout(jumpIf, date);'+