# fix image links generated by migrate # they will look like this: [](link to larg img) # this is an image that is the anchor text to the big immage # this perl command replaces the anchor and inserts a new image tag that points to the large one # # regex broken down # # \[!\[]\(http.*?\)] # matches the start of the anchor tag like: [![] (http:...)] # # (\(http.*?\)) # matches the second part (http:....) including the brackets and captures it in group 1 # # this part of the regex produces the new image tag with the matched group 1 # ![]\1 # perl -p -i -e 's/\[!\[]\(http.*?\)](\(http.*?\))/![]\1/g' source/_posts/*
# download the images to the local folder node_modules/.bin/hexo migrate image
# strip all html tags and their attributes perl -p -i -e 's/<.*?>//g' source/_posts/*
# replace all occurances of mor than 3 empty lines with just two of them # this is required because the blogger migrate creates a lot of empty lines # the tag replacement from above then creates even more perl -0 -p -i -e 's/\n{3,}/\n\n/g' source/_posts/*
# remove all generated .bak files rm source/_posts/*.bak
functionanonIp($ip) { if (strpos($ip, ".") !== false) { // detect IP type by dots instead of length $pieces = explode(".", $ip); $nPieces = count($pieces);
old hexo gist
plaintext
1
{% gist 996818 %}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// by design, this returns the same values as .NET's System.Random exportdefaultclassRandom { privatestaticreadonlyINT_MAX_VALUE: number = 0x7fffffff; privatestaticreadonlyINT_MIN_VALUE: number = 0x80000000; privatestaticreadonlyMSEED = 161803398;
public nextInteger = () =>this.internalSample(); public nextIntegerBetween = (minValue: number, maxValue: number) =>Math.floor(this.nextNumberBetween(minValue, maxValue)); public nextIntegerLessThan = (maxValue: number) =>Math.floor(this.nextNumberLessThan(maxValue)); public nextNumber = () =>this.sample(); publicnextNumberBetween(minValue: number, maxValue: number) { if (minValue > maxValue) thrownewError("Argument out of range.");
var range = maxValue - minValue; if (range <= Random.INT_MAX_VALUE) returnthis.sample() * range + minValue;
returnthis.getSampleForLargeRange() * range + minValue; }
publicnextNumberLessThan(maxValue: number) { if (maxValue < 0) thrownewError("Argument out of range.");
returnthis.sample() * maxValue; }
privategetSampleForLargeRange() { var result = this.internalSample(); var negative = this.internalSample() % 2 == 0; if (negative) { result = -result; }
let d = result; d += Random.INT_MAX_VALUE - 1; d /= 2 * Random.INT_MAX_VALUE - 1; return d; }
privateinternalSample() { var locINext = this.inext; var locINextp = this.inextp;
if (++locINext >= 56) { locINext = 1; }
if (++locINextp >= 56) { locINextp = 1; }
let retVal = this.seedArray[locINext] - this.seedArray[locINextp]; if (retVal == Random.INT_MAX_VALUE) { retVal--; }
if (retVal < 0) { retVal += Random.INT_MAX_VALUE; }