Skip to content

Instantly share code, notes, and snippets.

@Constaline
Constaline / remove-license-file-plugin.js
Created June 14, 2023 00:38
webpack4编译移除LICENSE文件
class RemoveLicenseFilePlugin {
apply(compiler) {
compiler.hooks.emit.tap("RemoveLicenseFilePlugin", (compilation) => {
// compliation参数中有输出的资源
// console.log(compilation.assets);
for (let name in compilation.assets) {
if (name.endsWith("LICENSE.txt")) {
delete compilation.assets[name];
}
}
@Constaline
Constaline / get-latest-tag-on-git.sh
Created October 19, 2021 09:17 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@Constaline
Constaline / electron_contextmenu.html
Created August 12, 2021 02:54
electron 渲染进程右键菜单配置
<script>
var remote = require(electron).remote;
var Menu = remote.Menu;
var menuInstance = new Menu(); //new一个菜单
let template = [
{
label: 'Undo',
role: 'undo'
},
@Constaline
Constaline / wx_autoupdater.js
Last active August 12, 2021 03:07
微信小程序实现提示用户更新
/**
* 微信启动时自动升级
*
* 参考 https://developers.weixin.qq.com/miniprogram/dev/api/base/update/wx.getUpdateManager.html
*/
class autoUpdater {
constructor() {
this.updateManager = wx.getUpdateManager();
}
@Constaline
Constaline / md5_hash_decrypt.py
Created November 20, 2020 01:00 — forked from miodeqqq/md5_hash_decrypt.py
Python MD5 decrypt.
# -*- coding: utf-8 -*-
import hashlib
import sys
import time
# Using: ./hash.py hashcode
# For example: ./hash.py 9743a66f914cc249efca164485a19c5c
def timing(f):
@Constaline
Constaline / arrayBufferToString.js
Created September 24, 2019 06:42 — forked from skratchdot/arrayBufferToString.js
Array Buffer -> String and String -> ArrayBuffer conversions in javascript
// source: http://stackoverflow.com/a/11058858
function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint16Array(buf));
}
@Constaline
Constaline / gdgxk.js
Created May 26, 2019 03:33
广东公需课辅助学习
var urls=[];
var url=$('.content-learning,.content-unstart').each(function () {
    var str;
    str=$(this).parent().attr('href');
    str=str.match(/\('(.+)'\)/)[1];
    urls.push(str);
});
var ifr=$('<iframe>');
var PN=0;
var PF=false;
@Constaline
Constaline / difference.js
Created May 7, 2019 00:30 — forked from Yimiprod/difference.js
Deep diff between two object, using lodash
/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
return _.transform(object, function(result, value, key) {
if (!_.isEqual(value, base[key])) {
@Constaline
Constaline / node-md5.js
Created August 4, 2018 14:10 — forked from sakiyukiko/node-md5.js
node.js大文件MD5值计算
var fs = require('fs');
var crypto = require('crypto');
var path = '/target/file.data';
var start = new Date().getTime();
var md5sum = crypto.createHash('md5');
var stream = fs.createReadStream(path);
stream.on('data', function(chunk) {
md5sum.update(chunk);
});
@Constaline
Constaline / Shadowrocket.conf
Last active February 19, 2017 02:08
Shadowrocket.conf
[General]
bypass-system = true
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, localhost, *.local, e.crashlynatics.com
bypass-tun = 1.0.0.0/9, 1.160.0.0/11, 1.192.0.0/11, 10.0.0.0/8, 14.0.0.0/11, 14.96.0.0/11, 14.128.0.0/11, 14.192.0.0/11, 27.0.0.0/10, 27.96.0.0/11, 27.128.0.0/9, 36.0.0.0/10, 36.96.0.0/11, 36.128.0.0/9, 39.0.0.0/11, 39.64.0.0/10, 39.128.0.0/10, 42.0.0.0/8, 43.224.0.0/11, 45.64.0.0/10, 47.64.0.0/10, 49.0.0.0/9, 49.128.0.0/11, 49.192.0.0/10, 54.192.0.0/11, 58.0.0.0/9, 58.128.0.0/11, 58.192.0.0/10, 59.32.0.0/11, 59.64.0.0/10, 59.128.0.0/9, 60.0.0.0/10, 60.160.0.0/11, 60.192.0.0/10, 61.0.0.0/10, 61.64.0.0/11, 61.128.0.0/10, 61.224.0.0/11, 100.64.0.0/10, 101.0.0.0/9, 101.128.0.0/11, 101.192.0.0/10, 103.0.0.0/10, 103.192.0.0/10, 106.0.0.0/9, 106.224.0.0/11, 110.0.0.0/7, 112.0.0.0/9, 112.128.0.0/11, 112.192.0.0/10, 113.0.0.0/9, 113.128.0.0/11, 113.192.0.0/10, 114.0.0.0/9, 114.128.0.0/11, 114.192.0.0/10, 115.0.0.0/8, 116.0.0.0/8, 117.0.0.0/9, 117.128.0.0/10, 118.0.0.0/11, 118.64.0.0/10, 118.1