Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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);
});