Skip to content

Instantly share code, notes, and snippets.

Jia Sui jsfaint

Block or report user

Report or block jsfaint

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jsfaint
jsfaint / lsp.vim
Created Jul 11, 2019
ncm2 config for vim
View lsp.vim
"Language Server Protocol
Plug 'prabirshrestha/vim-lsp' | Plug 'prabirshrestha/async.vim'
"vim-lsp
augroup vimrc
if executable('bash-language-server')
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'bash-language-server',
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'bash-language-server start']},
\ 'whitelist': ['sh'],
@jsfaint
jsfaint / Set-ExecutionPolicy.bat
Created Apr 26, 2018
Set Windows powershell execution policy
View Set-ExecutionPolicy.bat
powershell Set-ExecutionPolicy unrestricted -Scope CurrentUser
@jsfaint
jsfaint / https_server.go
Created Apr 23, 2018
https server in go
View https_server.go
// Package main provides ...
package main
import (
"fmt"
"log"
"net/http"
)
func HelloServer(w http.ResponseWriter, req *http.Request) {
@jsfaint
jsfaint / check_space.sh
Created Sep 14, 2017
Push message to wechat via serverchan, when disk space threshold is triggered
View check_space.sh
#!/bin/bash
avail=$(df / | tail -n 1 | awk '{print $4}')
threshold=""
message="硬盘要满啦"
token=""
if [[ ${avail:?} -lt ${threshold:?} ]]; then
curl "https://sc.ftqq.com/${token:?}.send?text=${message:?}"
fi
@jsfaint
jsfaint / hwmon_temp.sh
Created Jul 11, 2017
Get hwmon temperature on Linux via sysfs
View hwmon_temp.sh
#!/bin/bash
hwmon_sysfs="/sys/class/hwmon"
list=$(find "$hwmon_sysfs"/*)
for i in $list; do
if [ -e "$i/name" ]; then
sensor="$i"
else
@jsfaint
jsfaint / mem_chk.sh
Created Apr 12, 2017
Monitor the memory usage of given process
View mem_chk.sh
#!/bin/bash
# Configure by yourself
procname="cagent"
duration=10
usage()
{
echo "$0 {process name} {duration}"
echo "By default:"
@jsfaint
jsfaint / nutstore_dav.sh
Created Mar 31, 2017
Mount jianguoyun with davfs2 via webdav
View nutstore_dav.sh
#!/bin/bash
MOUNTPOINT="$HOME/Nutstore"
sudo mount -t davfs https://dav.jianguoyun.com/dav/ "$MOUNTPOINT"
@jsfaint
jsfaint / lanconf.exp
Created Mar 24, 2017
Control lanconf with expect
View lanconf.exp
#!/usr/bin/env expect
set timeout 6
set send_slow {1 .1}
spawn ./lanconf32 textmode
expect {
"Press any key to continue." {send -s " ";}
View test.c
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
void sig_handler(int signo)
{
printf("Signal %d", signo);
exit(1);
}
@jsfaint
jsfaint / mac_update.sh
Created Mar 24, 2017
Update MAC address using ethtool
View mac_update.sh
#!/bin/bash
PATTERN='^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
print_usage() {
echo "Need NIC name"
echo "usage: $0 eth0 00:11:22:33:44:55"
}
if [ -z $1 ]; then
You can’t perform that action at this time.