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 / mwan3_interface.sh
Last active May 28, 2022 02:46
mwan3 interface auto restart
#!/bin/sh
mwan3 interfaces | awk '{if($4 != "online" && NR > 1) print $2}' | while read line; do
if [[ "$line" == "WAN" ]]; then
echo "------ eth1"
ip link set eth1 down
ip link set eth1 up
elif [[ "$line" == "WAN1" ]];then
echo "---- veth11"
ip link set veth11 down
@binary4cat
binary4cat / compress.go
Created January 14, 2022 07:42 — forked from bussiere/compress.go
compress uncompress a string in golang
package main
import (
"bytes"
"compress/gzip"
"fmt"
"encoding/base64"
"io/ioutil"
)
--[[
lvim is the global options object
Linters should be
filled in as strings with either
a global executable or a path to
an executable
]]
-- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT
@binary4cat
binary4cat / Howto_Zsh5-6-2_Centos7.md
Created March 31, 2021 07:14 — forked from Semo/Howto_Zsh5-6-2_Centos7.md
How to install Zsh version 5.6.2 into CentOS 7

How to install Zsh version 5.6.2 into CentOS 7

Given that you have a clean installation of CentOS 7 which was already updated, by you, then you still have some dependencies to install make and install the external Zsh from the source. You must be root to get the stuff done.

Install GCC Development Tools

yum groupinstall "Development tools"

Check if it's working

@binary4cat
binary4cat / sse.go
Created April 7, 2020 06:59 — forked from ismasan/sse.go
Example SSE server in Golang
// Copyright (c) 2017 Ismael Celis
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
@binary4cat
binary4cat / use_fingerprint2.js
Created March 25, 2020 02:12
fingerprint2 demo
<script src="https://cdn.staticfile.org/fingerprintjs2/2.1.0/fingerprint2.min.js"></script>
<script>
function start() {
const start = new Date().getTime();
let view = document.querySelector('#view');
view.innerHTML = '';
let excludes = {};
if (!document.querySelector('#userAgent').checked) {
excludes.userAgent = true;
}
@binary4cat
binary4cat / DictionaryExtend.cs
Created January 31, 2019 09:00
c# Dictionary 相关扩展
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace iCTR.WeiXin.Common.Extensions
{
/// <summary>
/// 字典类扩展
/// </summary>
public static class DictionaryExtend
@binary4cat
binary4cat / System.Dynamic.ExpandoObject_create.cs
Last active January 29, 2019 01:30
动态创建c#类,以及在Csvhelper中创建动态的数据对象
// my pretend dataset
List<string> fields = new List<string>();
// my 'columns'
fields.Add("this_thing");
fields.Add("that_thing");
fields.Add("the_other");
dynamic exo = new System.Dynamic.ExpandoObject();
foreach (string field in fields)
@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("请上传图片文件!");
}