Skip to content

Instantly share code, notes, and snippets.

@shangdev
shangdev / JS-MD5
Created July 22, 2020 01:00
JS版MD5实现
function(e) {
var t = function(e, t) {
return e << t | e >>> 32 - t
}
, i = function(e, t) {
var i, n, a, o, s;
return a = 2147483648 & e,
o = 2147483648 & t,
i = 1073741824 & e,
n = 1073741824 & t,
@shangdev
shangdev / detect-onscroll
Created September 7, 2019 15:56
Detect scrolling event.
let overflowX = "auto";
let overflowY = "auto";
let scrollLeft = 0;
let scrollTop = 0;
let isScrolling;
const handleScroll = e => {
const element = e.target;
window.clearTimeout(isScrolling);
@shangdev
shangdev / devExpress demo
Last active August 21, 2019 15:54
DevExpress React Grid Table 固定 Header 及 Columns 示例代码
import React, { useState } from 'react';
import Paper from '@material-ui/core/Paper';
import {
SortingState,
IntegratedSorting,
} from '@devexpress/dx-react-grid';
import {
Grid,
VirtualTable,
TableHeaderRow,
@shangdev
shangdev / ss shell
Last active April 15, 2019 15:39
SS 常规命令
# ssserver -c /etc/shadowsocks.json -d start
# ssserver -c /etc/shadowsocks.json -d stop
# ssserver -c /etc/shadowsocks.json -d restart
@shangdev
shangdev / add-custom-product-data-tab-in-woocommerce.txt
Last active November 30, 2018 07:43
Add custom product data tab with options in woocommerce
<?php
/**
* Manage product data.
*
* @link https://rudrastyh.com/woocommerce/product-data-metabox.html
*
* @package Trueniu
* @subpackage WP Rig
* @since 1.0.0
*/
@shangdev
shangdev / git-alias-for-bashrc-or-zshrc
Last active April 15, 2019 07:08
Git alias for bashrc or zshrc
# rc 表示 run command (运行命令)
# for zsh
$ vi ~/.zshrc
# for bash
$ vi ~/.bashrc
alias gs="git status"
alias gc="git commit -m "
@shangdev
shangdev / Centos6.8升级gcc到最新版v7.3.0
Last active January 26, 2018 10:35
Upgrade gcc to v7.3.0 in centos6.8
## 下载最新版gcc
wget http://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.bz2
tar jxvf gcc-7.3.0.tar.bz2
## 创建存放编译的文件
mkdir gcc-build-7.3.0
cd gcc-build-7.3.0
## 编译安装gcc
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
@shangdev
shangdev / WP metabox upload_media
Created December 13, 2017 09:52
wordpress metabox 单图像设置
### HTML结构 ###
a:html内容(未选择)
<p class="hide-if-no-js set-check-media-image">
<a href="javascript:void(0);" onclick="jQuery.metaboxCheckMedia(this,'_case_cover')">
选择图像
</a >
</p>
b:html内容(已选择)
<p class="hide-if-no-js set-check-media-image">
<a href="javascript:void(0);" onclick="jQuery.metaboxCheckMedia(this,'_case_cover')">
@shangdev
shangdev / Linux nohup task.
Created November 21, 2017 11:08
linux后台运行和关闭、查看后台任务
# 把命令放到后台执行
$ nohup sh rsync.sh &
# 正在前台执行的任务放到后台,并且处于暂停状态
$ ctrl + z
# 查看后台运行的任务
$ jobs
# 调用后台的任务至前台
@shangdev
shangdev / inotify+rsync实时同步文件
Last active November 16, 2017 17:27
Centos6.8: inotify+rsync install
1. 检查你的服务器版本是否支持inotify机制,如果输出 CONFIG_INOTIFY_USER=y 则表示支持
$ grep INOTIFY_USER /boot/config-$(uname -r)
2. 编译安装inofity-tools工具包
$ wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
$ tar -zxvf inotify-tools-3.14.tar.gz
$ ./configure --prefix=/usr --libdir=/lib64 && make && make install
3. 脚本
#!/bin/bash