Prev2a.gifWelcome
Prev2a.gifReturn to Lists

[1]  

• TzaraHaiku modified to handle bulk output text production ("TzMulti")
• Cross reference internal links (WBtree)
• Backup a Wiki file (WB)
     • Image media links need special handling (WB_Include)
• Update last update timestamp file (WBupdate)
• Check for not current files in Local and Bmccedd (WBXXX)
• List all html files in a directory for use in "WB" script (WBListAll)
• Search for character strings in WB backup files (WBsearch)
• List images used (WBcount)
• List versions of script files (WBversions)
• List HTML files changed after a certain date (WBafter)
• Compare local and DreamHost ".html" files (WBDH)
• Compare local and remote image trees (WBcompare)
• CharCount
• Print contents of file in raw hexadecimal (Hexprint)
• Print Ascii character set (Ascii)
• Julia programming language String builtin function problem

TzaraHaiku modified to handle bulk output text production ("TzMulti")

using Random

print("\nHow many iterations do you want? ")
global iterations = parse(Int32, readline())
if iterations < 1
    throw(DomainError(iterations, "argument must be > 0"))
end    

APFS = "004" # TzMulti:APFS
version = "+2021.12.18 v" * APFS

global iteration = 1
global outStrings = [] 
global garbage = zeros(UInt8,0)
outFileName = ""
 
okSpecial = "#-_'.,:();!?\"" *
        "abcdefghijklmnopqrstuvwxyz" *
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ" *
        "0123456789"
okIgnore = [10, 13, 32]

OKchars = fill(false, 256)
for i = 0 : 127
    OKchars[i + 1] = Char(i) in okSpecial
end

function addToN(wrd)
    tot = 0
    for i = 1 : length(wrd)
         j = UInt64(wrd[i])
         if j > 127
             println("Character greater than 127: " , j, " \"", wrd[i], "\".")
            exit(16)
         end
         tot += j - 32
    end
    return tot
end 

function processInput(fileName, dataString)     # parameters: @ or file name, data string or nothing
    if length(fileName) < 1
        println("\n         No FileName\n\n")
        exit(16)
    end
    rawInputData = nothing
    if fileName == "@"       #  Inline character string to process, not file
        rawInputData = zeros(UInt8, length(dataString))
        for i = 1 : length(dataString)
            j = UInt8(dataString[i])
            if j > 127
                 println("Character greater than 127: " , j, " \"", dataString[i], "\".")
                exit(16)
            end
            rawInputData[i] = UInt8(dataString[i])
        end
    else
        try
            s = open(fileName)
            rawInputData = read(s)
            close(s)
        catch ex
            println("\nprocessInput exception: ", ex)
            exit(16)
        end
    end

    NaturalNumber = 0
    Sarry = String[]    # array of all words in the source file    
    shitIn = ""

    thisWord = ""
    shitInPfx = ""

    for i = 1:length(rawInputData)
        ti = rawInputData[i]
        if OKchars[ti + 1]
            thisWord *= string(Char(ti))
        else
            if !(ti in okIgnore)
                if !(ti in garbage)
                    push!(garbage, ti)
                end
            end 
            if length(thisWord) > 0
                push!(Sarry, thisWord)
                shitIn *= shitInPfx * thisWord 
                NaturalNumber += addToN(thisWord)
                thisWord = ""
                shitInPfx = " " 
            end
        end
    end
    if length(thisWord) > 0
        push!(Sarry, thisWord)
        NaturalNumber += addToN(thisWord)
        shitIn *=  shitInPfx * thisWord
    end
    return [NaturalNumber, Sarry, shitIn]
end
       
function myPrint(fileName, PIout, seedie)

#    PIout = processInput(fileName, rawInputData)
#    return [NaturalNumber, Sarry, shitIn]

    Sarray = PIout[2]
    rarrLen = 10000    # Assumed maximum number words in output poem
    randomNumbers = rand(MersenneTwister(seedie), UInt64, rarrLen)
    sLen = length(Sarray)
    pfx = "" 
    poem = ""
    ilim = nrWords == -1 ? sLen : nrWords 
    if ilim > sLen
        ilim = sLen
    end
    if iteration == 1
        println("\n        " * version * 
                #"  (", seedie, "; N=", PIout[1], ") " , fileName, ": ",  sLen , " >> " ,
               "  (N=", PIout[1], ") " , fileName, ": ",  sLen , " >> " ,  
                (nrWords == -1 ? "All" : nrWords), 
                ((ilim != nrWords && nrWords > -1) ? ("<" * string(ilim) * ">") : ""), 
                outFileName == "" ? ".\n" : ".  Log file: \033[32;1m" * outFileName * "\033[0m.\n")
    end
    for i = 1:ilim
        ix = randomNumbers[i] % length(Sarray) + 1 
        curWord = Sarray[ix]
        poem *= pfx * curWord
        if i == ilim 
            break
        elseif ix == 1
            Sarray = Sarray[2:(length(Sarray))]
        elseif ix == length(Sarray)
            Sarray = Sarray[1:(length(Sarray) - 1)]
        else
            temp1 = Sarray[1:(ix - 1)]
            temp2 = Sarray[(ix + 1):(length(Sarray))]
            Sarray = append!(temp1, temp2)
        end 
        pfx = " "
    end
        
    push!(outStrings, poem)
    if iteration == iterations && outFileName != ""
        try
            f = open(outFileName, "a") 
            write(f, "----\n\n  " * PIout[3] * "\n")
            for q = 1 : length(outStrings)
                write(f, "\n  " * outStrings[q])
            end
            write(f, "\n\n Keys:" * keys) 
#    if !Sys.iswindows()
            write(f, "\n\n")
#    end          
            close(f) 
        catch ex
            println("NOGOOD Exception: ", ex)
            return(16)
        end   
    end
        
    ppfx = "  " #  "\n<!-- " * string(seedie) * " --><span style=\"color:green;\">©</span> "

    if iteration == 1
        println("  \033[32;1m" * PIout[3] * "\n\n" * ppfx * "\033[31m" * poem * "\033[0m")
    else 
        println(ppfx * "\033[31;1m" * poem * "\033[0m")    
    end

    global iteration += 1
end

#-------- start processing here --------

global ARGZ = ARGS

# Special easter egg to randomize integers from 1 to n         seed:count
if length(ARGZ) == 1
    local sZ = findfirst(':', ARGZ[1])
    if sZ != nothing
        local maxi = tryparse(Int64, string(ARGZ[1][sZ + 1: length(ARGZ[1])]))
        local stZ = ""
        local strZ = ""
        for i = 1 : maxi
            strZ *= stZ * string(i)
            stZ = " "
        end
        ARGZ = [ARGZ[1][1 : sZ - 1], "=", "@", strZ]
    end
end

if length(ARGZ) < 3
    println("\nInput:   (seedNumber or \"N\")[:logFileName]   (length or \"=\")   f(ileName or \"@\")   [text?]\n\n" *
        "    * Take a newspaper.\n    * Take some scissors.\n    * Choose from this paper an article the length you want to make your poem.\n    * Cut out the article.\n    * Next carefully cut out each of the words that make up this article and\n              put them all in a bag.\n    * Shake gently.\n    * Next take out each cutting one after the other.\n    * Copy conscientiously in the order in which they left the bag.\n    * The poem will resemble you.\n    * And there you are--an infinitely original author of charming sensibility,\n              even though unappreciated by the vulgar herd.\n    * (Tristan Tzara)")
    exit(16)
end

# get N            #  $   [don't care]   [@ text | filename]      #   to get N
ProcessInputOut = processInput(ARGZ[3], length(ARGZ) > 3 ? ARGZ[4] : nothing)

if  ARGZ[1] == "\$"
    println("\nN=", ProcessInputOut[1], "\n")
    exit(0)
end    

qc = findfirst(':', ARGZ[1])
if qc != nothing
    s = ARGZ[1][1 : qc - 1]
    seedy = s  in ["n", "N"] ? ProcessInputOut[1] : tryparse(Int64, string(s))
    outFileName = ARGZ[1][qc + 1 : length(ARGZ[1])]
else
    seedy = ARGZ[1] in ["n", "N"] ? ProcessInputOut[1] : tryparse(Int64, string(ARGZ[1]))
end
if !isa(seedy, Number)
    println("\nBad seed number, stupid!\n")
    exit(16)
end
global nrWords = -1 
if string(ARGZ[2]) != "="
    global nrWords = tryparse(Int64, string(ARGZ[2]))
    if !(isa(nrWords, Number))
        println("\nBad or no word count, stupid!\n")
        exit(16)
    end
end
      
global r2 = (rand(MersenneTwister(seedy), UInt64, (iterations + 2)) .% (16 ^ 4)) .+ 1
global keys = " (" * string(seedy) * ")"

for i = 1 : iterations
    global keys *= " " * string(r2[i])
    myPrint(ARGZ[3], ProcessInputOut, r2[i])
end

if length(garbage) > 0
    print("\nRejected characters: ")
    for i = 1 : length(garbage)
        print("\'" , Char(garbage[i]) , "\'(", garbage[i], ").", i == length(garbage) ? "" : " ")
    end
    print("\n")
end

println("\nKeys:", keys)

Return to TOC!Return to TOC

Julia script to cross reference internal links (WBtree)

using Dates
dt = string(Dates.now())
dtx = findfirst('T', dt)
global now = dt[1: dtx - 1] * " " * dt[dtx + 1: 19]

APFS = "016" # WBTree:APFS
version = APFS
println("WBTree v", version, ".  ", now, "\n")

global fdict = Dict{String, String}()
global ildict = Dict{String, Int64}()
global linkCt = 0
global ilinkCt = 0
global pageCt = 0
global incoming = Dict{String, Array{String}}()
global externalLinks = Dict{String, Array{String}}()

global excludeds = ["Tree.html", "RTree.html", "XTree.html", "IndexOfSubjects.html"]

function makeTable(DICT, ptr)
    if ptr == "=>"
        istr = string(ilinkCt)
        if ilinkCt > 999
            listr = length(istr)
            istr = istr[1: listr - 3] * "," * istr[listr - 2: listr]
        end
        global out = "<table style=\"border-collapse:separate;font-family:sans-serif;font-weight:bold;background-color:lightyellow;padding:10px;\"><tr><td colspan=2 style=\"padding:2px 0px 22px 2px;color:gray;font-weight:normal;\"><p>Pages: " * string(pageCt) * ". Interpage links > " * lc * ".  Intrapage (\"#\") links > " * istr * ".  WBtree v" * version * ".</p><p style=\"line-height:140%;font-size:smaller;border:1px solid black;padding:0px 9px 6px 8px;background-color:white;\">{{BRMX|TooComplex|200}}.</p><p style=\"color:blue;padding-top:4px;\">" * now * "   ([[{{BRM|Tree}}|Tree]]/[[Template:BRM_Tree|T]])<p></td></tr>\n"
    elseif ptr == "<=" 
        global out = "<table style=\"border-collapse:separate;font-family:sans-serif;font-weight:bold;background-color:lightyellow;padding:10px;\"><tr><td colspan=2 style=\"padding:2px 0px 16px 2px;color:gray;font-weight:normal;\">Reverse table of incoming internal interpage links:<br /><span style=\"color:blue;\">" * now * "</span></td></tr>\n"
    else
        global out = "<table style=\"border-collapse:separate;font-family:sans-serif;font-weight:bold;background-color:lightyellow;padding:10px;\"><tr><td colspan=2 style=\"padding:2px 0px 16px 2px;color:gray;font-weight:normal;\">!QWERTY! outgoing external links (several uninteresting items excluded):<br /><span style=\"color:blue;\">" * now * "</span></td></tr>\n"
    end
    global shit = []
    for x in keys(DICT)
        push!(shit, x)
    end
    ghosts = []
    crt = 0
    shitx = sort(shit, by=lowercase)
    for s in shitx
        s2 = s[1:(length(s) - 5)]
        if length(DICT[s]) == 0
            push!(ghosts, (s2 == "IntoTheLight" ? "[https://www.bmccedd.org/IntoTheLight.html IntoTheLight]" : "[[{{BRM|" * s2 * "}}|" * s2 * "]]"))
        end
        ilss = ""
        if s2 == "Tree" || s2 == "RTree" || s2 == "XTree"
            ilss = "(n/a)"
        else 
            ils = get(ildict, s, 0)
            if ils > 0
                ilss = "(" * string(ils) * ")"
            end
        end
        if ptr != "<<="
            if s2 == "welcome"
                s2a = ""
            else
                s2a = "|" * s2
            end
            ohmygod = "[[{{BRM" * s2a * "}}|" * s2 * "]]"
            if s2 == "IntoTheLight"
                ohmygod = "[https://www.bmccedd.org/IntoTheLight.html IntotheLight]"
            end
            global out *= "<tr><td colspan=2 style=\"padding:2px;\"><span style=\"background-color:yellow;padding:2px 5px 0px 3px;\" id=\"" * s2 * "\">" * ohmygod * "</span><span style=\"font-weight:normal;color:gray;\">" * ilss * " " * ptr * "</span></td></tr>"
        else
            crt += 1
            crtx = string(crt)
            crtx = (" " ^ (4 - length(crtx))) * crtx
            global out *= "<tr" * (s == "https://www.bmccedd.org/IntoTheLight.html" ? " id=\"IntoTheLight\"" : "") * "><td colspan=2 style=\"padding:2px;\"><span style=\"font-weight:normal;\">" * crtx * ".</span> <span style=\"background-color:yellow;padding:2px 5px 0px 3px;overflow-wrap:anywhere;\">[" * s * " " * s * "]</span><span style=\"font-weight:normal;color:gray;\">" * ilss * " " * ptr * "</span></td></tr>"
        end
        global out *= "<tr><td style=\"padding:2px 2px 2px 40px;\"> </td><td style=\"padding:2px;\">" *
               (ptr == "<=" && s2 == "IntoTheLight" ? "[ [[{{BRM|XTree#IntoTheLight}}|''All incoming links remote'']] <span style=\"font-weight:normal;\">==></span> ]" : DICT[s]) *
               "</td></tr>\n"
    end
    out *= (length(ghosts) == 0 ? "" : "<tr><td colspan=2 style=\"padding:8px 0px 2px 2px;color:gray;font-weight:normal;\">Ghosts: " * string(ghosts) * "</td></tr>") * "</table>"
    out = replace(out, "!QWERTY!" => string(crt), count=1)
    return(out)
end
 
try
    global errId = 1
    a = readdir()
    for itm in a
        if findfirst(".html", itm) == nothing
            continue
        end
        incoming[itm] = []
    end
    global errId = 2
    for itm in keys(incoming)
        global pageCt += 1
        if itm in excludeds
            global fdict[itm] = "[''" * (itm == "XTree.html" ? "N/A" : "Everything") * "'']"
            continue
        end
        item = itm
        f = open(item)
        global errId = 4
        res = read(f)
        sres = String(res)
        global errId = 5
        close(f)

        if findfirst(r"aplacetostudy"i,  sres) != nothing
            println((item in ["Dashboard.html", "Images.html", "JSource.html"] ? "" : "** ") * "Aplacetostudy: " * item)
        end

        refs = findall(r"href=\"[a-zA-Z0-9-_!]+\.", sres)
        srefs = []
        for r in refs
            ss = sres[r]
            ss = ss[7: (length(ss) - 1)]
            if !(ss in srefs)
                push!(srefs, ss)
            end
            if !(ss * ".html" in a)
                println("Bad link: " * itm * " => \"" * ss * "\".")
                exit(16)
            end
            if !(itm in incoming[ss * ".html"])
                push!(incoming[ss * ".html"], itm)
            end
            global linkCt += 1 
        end
        str = ""
        for x in sort(srefs, by=lowercase)
            str *= (str != "" ? ", " : "") * "[[#" * x * "|" * x * "]]"
        end
        global fdict[itm] = str
        global ildict[itm] = iq = length(findall("<a href=\"#", sres))
        global ilinkCt += iq

        xls = findall(r"( href=\"|\|link=)http.*?[\" ]", sres)
        for xl in xls
            t = sres[xl]
            t = replace(t, r"( href=\"|\|link=)" => "", count=1)
            t = t[1:length(t) - 1]
            if get(externalLinks, t, "!") == "!"
                externalLinks[t] = [itm]
            else
                if !(itm in externalLinks[t])
                    push!(externalLinks[t], itm)
                end
            end
        end
    end
catch ex
    s = string(ex)  
    if length(s) > 200
        s = s[1:200] * "..."
    end
    println("\n      Failure[" * string(errId) * "]: ", typeof(ex), ".\n", s);
    exit(16)
end

lc = string(linkCt)
if linkCt > 999
    lenlc = length(lc)
    lc = lc[1:lenlc - 3] * "," * lc[lenlc - 2:lenlc]
end

global incoming2 = Dict{String, String}()
for k in keys(incoming)
    ary = incoming[k]
    str = ""
    for x in sort(ary, by=lowercase)
        stp = x[1:length(x)-5]
        str *= (str != "" ? ", " : "") * "[[#" * stp * "|" * stp * "]]"
    end
    global incoming2[k] = str
end

T = makeTable(fdict, "=>")

RT = makeTable(incoming2, "<=")

global incoming2 = Dict{String, String}()
for k in keys(externalLinks)
    if findfirst("https://faculty.washington.edu/walter/Killing%20Cats3.html#_edn", k) != nothing ||
            k == "https://validator.w3.org/"
        continue
    end
    ary = externalLinks[k]
    str = ""
    for x in sort(ary, by=lowercase)
        stp = x[1:length(x)-5]
        stp2 = ""
        if stp != "welcome"
            stp2 = "|" * stp
        end 
        str *= (str != "" ? ", " : "") * "\"[[{{BRM" * stp2 * "}}|" * stp * "]]\""
    end
    global incoming2[k] = str
end

XT = makeTable(incoming2, "<<=") 

TALL =  "{{#switch: {{{1}}}\n"
TALL *= " | R = " * RT * "\n"
TALL *= " | X = " * XT * "\n"
TALL *= " | #default = " * T * "\n}}"

f = open("TREE", "w")
write(f, TALL)
close(f)

Return to TOC!Return to TOC

Julia script to backup a Wiki file (WB)

#using Pkg; Pkg.add("HTTP")
using Dates
using HTTP

APFS = "151" # WB:APFS
global versionNr = APFS
global formattedLength = ""
global unToc = ""
global totalSize = 0
global wpct = 0
global vpct = 0
global MIAs = Dict()
global BRMs = 0
global nrr = 1
global line1 = ""
global testing = false
global failures = []

global keywords = Dict{String, String}([
    "Broch" => "Hermann Broch, The Sleepwalkers, The Death of Virgil",
    "PhilCris" => "Phenomenology, Vienna Lecture, Edmund Husserl",
    "Star_and_bars" => "Insignia, Star and bars, Friendly fire",
    "Circ" => "circumcision, genital mutilation, female genital mutilation, foreskin, masturbation, bris, brit milah, mohel, britmilah",
    "Darkness" => "wokeness, woke, Wokies, political correctness, anti-intellectualism, tribalism, groupthink",
    "Hungary" => "witch hunting, blacklist, McCarthyism, political correctness",
    "Mullah" => "Samuel Paty, freedom of expression, religious bigotry, decapitation, laicite, secularism",
    "" => "Husserl, Heraclitus, phenomenology, Eugen Fink, transendental philosophy, individuality, Szczepanski, laicite, secularism, agnosticism, self-accountabliity, Kandinsky, Maine Coon cat, finitude",
    "index" => "Husserl, Heraclitus, phenomenology, Enlightenment, Eugen Fink, transendental philosophy, individuality, Szczepanski, laicite, secularism, agnosticism, self-accountabliity, Kandinsky, Maine Coon cat, finitude, technology and society, lifeworld, lebenswelt, discourse ethics",
    "Thanks" => "Robbie McClintock, Robert McClintock, Robert O. McClintock, Robert O McClintock"  
]) 

global ImageCache = Dict{String, Int32}()
global countSHIT = 0

include("WB_Include")
  
function addSHIT(nbr)
    global unToc *= " P/SHIT" * string(nbr)
    global countSHIT += 1
end

# Purpose here is to find unused images in image directory
function fillImageDict()
    for (root, dirs, files) in walkdir("./w/")
        for file in files
            x = joinpath(root, file) # path to files
            if !contains(x, "images")
                continue
            end
            z = replace(x, "\\" => "/")
            global ImageCache[z[3 : length(z)]] = 0 
        end
    end
end

function addToDict(iname, fnm)
    if haskey(MIAs, iname)
        MIAs[iname] = [MIAs[iname][1]  + 1, (MIAs[iname][2] * ", " * fnm)]
        return
    end
    MIAs[iname] = [1, fnm]
end

function getNow()
    dt = string(Dates.now())
    dtx = findfirst('T', dt)
    return(dt[1: dtx - 1] * " " * dt[dtx + 1: length(dt)])
end

function doAFile(fname, seq)
    global formattedLength = ""
    global unToc = ""
    st = time()

    if length(fname) > 0 
        actionUrlPart = "User:Bradford_Robert_McCormick/" * fname
        displayUrl = fname
    else
        actionUrlPart = "User:Bradford_Robert_McCormick"
        displayUrl = "[base url]" 
    end
    actionUrl = "https://www.aplacetostudy.com/wiki/" * actionUrlPart 
    println("\n\033[30;1m[" * versionNr * "]\033[0m  Trying: " * displayUrl)
    txt = nothing 
    try
        res = HTTP.get(actionUrl);
        zb = copy(res.body)
        asshole = length(zb)
        txt = String(zb) # Never had I seen a function that destroys its input parameter. Cui bono?
        if asshole != length(txt)
            global unToc *= "  L-x(" * string(asshole - length(txt)) * ")"
        end  

        if testing
            zc = res.body
            x = ""
            for  i = 1 : length(zc)
                x *= Char(zc[i])
            end

            a = open("New_" * fname , "w")
            write(a, txt)
            close(a)

            a = open("Old_" * fname, "w")
            write(a, x)
            close(a)

            println(fname , ".  New: " , length(txt), ".  Old: " , length(x), ".")
        end
    
        strtString = "<!-- " * Char(10) * "NewPP lim"
        frst = findfirst(strtString, txt)
    
    #    println("\n        " * string(frst) * "    slash is .47., colon is .58..")
    
        if frst == nothing
            println("\n        \033[31;1m\"" * strtString * "\" not found\033[0m\n")
            exit(16)
        end
    
        txt = txt[1:frst[1]-1]

        # Get the goddamned last modified timestamp of the Wiki file. This was too goddamned hard to do!
        shit = String(res)
        shit0 = findfirst(r"Last-Modified:.*?GMT", shit)
        shit1 = shit[shit0]
        if shit1[length(shit1) - 3:length(shit1)] != " GMT"
            println("Bad time: " * fname * " \"" * shit1 * "\"")
            exit(16)
        end
        mfshit = string(Dates.DateTime(shit1[21:length(shit1) - 4], "dd u yyyy HH:MM:SS"))
        global SHIT = mfshit[1:10] * " " * mfshit[12:19]

        #---- meta tags ----
        kw = ""
        if length(fname) == 0 || fname == "BRADFORD" || fname == "index"
            kw = "\n<meta name=\"author\" content=\"Bradford McCormick\" />"
            if fname == "index"
                kw *= "\n<meta name=\"description\" content=\"Improve social interaction thru self-reflective conversation. Modernity, marxist humanism, The Bauhaus. Build good society cultivating peer-to-peer personal intelligence: dialog + technology, precision and soul.\" />"
            end
        end
        kwk = get(keywords, fname, "")
        if kwk != ""
            kw *= "\n<meta name=\"keywords\" content=\"" * kwk * "\" />"  
        end

        txt = replace(txt, "<head>" =>
                "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"./w/css/WBmiracle.css\" />" * kw, count=1) *
                "</div><div class=\"read600\"><br style=\"clear:both;\">" * 
                    "<img src=\"./w/images/5/52/Spacer.gif\" alt=\"!QWERTY!\" width=\"2\" height=\"2\" /></div></body></html>"
    
        global printhole = ""
    
        rawPrint = length(fname) > 0 ? fname : "welcome"
        for i = 1 : length(rawPrint)
            if rawPrint[i:i] == ":"
                printprtChar = "\033[32;1m" * ".58." * "\033[0m"
            elseif rawPrint[i:i] =="/"
                printprtChar = "\033[32;1m" * ".47." * "\033[0m"
            else 
                printprtChar = rawPrint[i:i]
            end
            global printhole *= printprtChar 
        end
    
        if findfirst("<div id=\"toc\" class=\"toc\" role=\"navigation\" aria-labelledby", txt) != nothing   
            q = length(txt) 
            txt = replace(txt, r"<div id=\"toc\" class=\"toc\" role=\"navigation\" aria-labelledby.+?</li>[\t\n\r]+</ul>[\t\n\r]+</div>[\t\n\r]+"s => "", count=1)
            global unToc = "  " * (q > length(txt) ? "(unToc)" : "SHITTOC")           
        end
        txt = replace(txt, r"<h1 id=\"firstHeading\" class=\"firstHeading\" lang=\"en\">[^<]+</h1>" => "", count=1)
        q = length(txt)
        txt = replace(txt, "<div class=\"mw-parser-output\">" => "", count=1)
        if length(txt) >= q
            addSHIT(0)
        end
    
        q = length(txt)
        txt = replace(txt, "<div id=\"mw-content-text\" lang=\"en\" dir=\"ltr\" class=\"mw-content-ltr\">" => "", count=1)
        if length(txt) >= q
            addSHIT(1)
        end
        q = length(txt)
        txt = replace(txt, r"[\r\n\t ]+<div id=\"bodyContent\" class=\"mw-body-content\">[\r\n\t ]+" => "", count=1)
        if length(txt) >= q
            addSHIT(2)
        end
        q = length(txt)
        txt = replace(txt, r"[\r\n\t ]+<div id=\"contentSub2\"></div>[\r\n\t ]+<div id=\"jump-to-nav\"></div>[\r\n\t ]+" => 
                    "", count=1)
        if length(txt) >= q
            addSHIT(3)
        end 
        q = length(txt)
        txt = replace(txt, r"[\r\n\t ]+<div id=\"mw-page-base\" class=\"noprint\"></div>[\r\n\t ]+<div id=\"mw-head-base\" class=\"noprint\"></div>[\r\n\t ]+" => "", count=1)
        if length(txt) >= q
            addSHIT(4)
        end 
        q = length(txt)
        txt = replace(txt, r"<body class=\"mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-2 ns-subject[^>]+>" => "<body>", count=1)
        if length(txt) >= q
            addSHIT(5)
        end 
        q = length(txt)
        txt = replace(txt, r"<a id=\"top\"></a>[\r\n\t ]+<div id=\"siteNotice\" class=\"mw-body-content\"></div>[\r\n\t ]+<div class=\"mw-indicators mw-body-content\">[\r\n\t ]+</div>" => "", count=1)
        if length(txt) >= q
            addSHIT(6)
        end
        q = length(txt)
        txt = replace(txt, " decoding=\"async\"" => "")
        r = length(txt)
        if r >= q
            addSHIT(7) 
        end

        txt = replace(txt, r"^[\r\n\t ]+" => "", count=1)

        q = length(txt)
        txt = replace(txt, r"<a href=\"/wiki/File:.+?title=\"([^\"]+)[^>]+><img.+?src=\"([^\"]+).*?></a>" => s"<img src=\"\2\" title=\"\1\" />")
        txt = replace(txt, r"<a href=\"/wiki/File:[^\"]+\" class=\"image\">(<img[^>]+>)</a>" => s"\1")

        global unToc *= "  \302\243:" * (length(txt) < q ? string(q - length(txt)) : "N/f")      
        txt = replace(txt, r"</title>(.|[\n\t\r])+?</head>" => s"</title></head>", count=1)
        txt = replace(txt, r"<a class=\"mw-jump-link\" href=\"#mw-head\"[^I]+Input\">Jump to search</a>" => 
                        "", count=1)    #    s"<!-- \1 -->")
        txt = replace(txt, r"<div id=\"siteSub\" class=\"noprint\"[^D]+Developer</div>" => "", count=1)  #  s"<!-- \1 -->")
        if (fname * "---------")[1:9]  == "ChangeLog"
            txt = replace(txt, "<li class=\"mw-empty-elt\"></li>" => "")
        end
        txt = replace(txt, r"href=\"/wiki/User:Bradford_Robert_McCormick/([^\"#]*)#([^\"]*)\"" => s"href=\"\1.html#\2\"")
        txt = replace(txt, r"href=\"/wiki/User:Bradford_Robert_McCormick/([^\"]*)\"" => s"href=\"\1.html\"") 
        txt = replace(txt, r"href=\"/wiki/User:Bradford_Robert_McCormick([^\"]*)\"" => s"href=\"welcome.html\1\"")
                                ##########           
        txt = replace(txt, r"-0\">[^<]+</a></span> <span class=\"reference-text\">" => 
                    "-0\">↑</a></span> <span class=\"reference-text\">")    # ampersand uarr semicolon  fuckup?
        txt = replace(txt, " " => " ")   # This changes ampersand poundsign 160 semicolon to HTML nbsp   fuckup
    
        if fname != ""
            txt = replace(txt, ">< " =>         #   "<" to ampersand lt semicolon fuckup
                    "><a href=\"welcome.html\"><img alt=\"Prev2a.gif\" src=\"./w/images/1/12/Prev2a.gif\" width=\"10\" height=\"12\" style=\"padding-left:4px;\" /></a>", count=1)
            txt = replace(txt, "<a href=\"welcome.html\" title=\"User:Bradford Robert McCormick\">User:Bradford Robert McCormick</a>" => 
                    "<a href=\"welcome.html\" title=\"Welcome!\">Welcome</a>", count=1)
            if fname == "index"        # ******** index ********
                txt = replace(txt, r"<div id=\"contentSub\"><span class=\"subpages\"><a href=\"welcome.html\".*? title=\"Welcome!\">Welcome</a></span></div>[ \r\n]+" => "", count=1)
                # Once again: "Goddamn Wiki!"
                txt = replace(txt, r"<body><div id=\"content\" class=\"mw-body\" role=\"main\">[ \r\n]+" => "<body><div id=\"content\" class=\"mw-body\">", count=1) 
            end
        end
    
        q = length(txt)
        txt = replace(txt, r"<body><div id=\"content\" class=\"mw-body\"[^<]+<div id=\"contentSub\">"s =>
                    "<body><div id=\"content\" class=\"mw-body\"><div id=\"contentSub\">", count=1) 
        if length(txt) >= q
            addSHIT(8)
        end
        q = length(txt)
        txt = replace(txt, r"[\t ]+<div class=\"read600\"" => "<div class=\"read600\"", count=1) 
        if length(txt) >= q
            addSHIT(9)
        end
        q = length(txt)
        txt = replace(txt, "<html class=\"client-nojs\" " => "<html ", count=1) 
        if length(txt) >= q
            addSHIT(10)
        end

        txt = replace(txt, r"<a href=\"/wiki/([^\"]+)\"" => s"<a href=\"https://www.aplacetostudy.com/wiki/\1\"")
    
        if length(fname) == 0
            txt = replace(txt, r"0px[ ]+0px[ ]+14px" => "16px 0px 14px", count=1)
            txt = replace(txt, r"<title>User:Bradford Robert McCormick.*? - A Place to Study Developer</title>" =>
                        "<title>A Place for Study|welcome</title>", count=1)
            txt = replace(txt, "<div class=\"floatright\"><a href=\"/wiki/Main_Page\" title=\"Return to: A Place for Study root page!\"><img alt=\"Return to: A Place for Study root page!\"" =>
                        "<div style=\"padding-bottom:8px;\" class=\"floatright\"><a href=\"EndOfEarth.html\" title=\"Go to the end of the rotting earth[Exclamation point]\"><img alt=\"Go to the end of the rotting earth[Exclamation point]\"", count=1)
        else
            if fname == "KillingTheCats"
                txt = replace(txt, "</font>" => "<!-- /font -->")
                txt = replace(txt, r"<font([^>]+)>" => s"<!-- font\1 -->")
            end
            txt = replace(txt, r"<title>User:Bradford Robert McCormick/(.*?) - A Place to Study Developer</title>" => 
                        s"<title>A Place for Study|\1</title>", count=1)
        end
        q = length(txt)
        #txt = replace(txt, "\n" => "\r\n")
        #txt = replace(txt, r"\r+" => "\r")
        txt = replace(txt, r"\r+" => "")
        if length(txt) >= q
            addSHIT(11)
        end

        txt = replace(txt, r"[ \n]+</p><p>" => "</p>\n<p>")
        txt = replace(txt, r"[ \n]+</p>\n" => "</p>\n")
        txt = replace(txt, r"[ \n]+</li>\n" => "</li>\n")

        # Images linked to from images
        if haskey(IIs, fname)           # Images linking to images, which Wiki does not handle nicely
            infos = IIs[fname]
            for info in infos
                txt = replace(txt, "href=\"https://www.aplacetostudy.com/wiki/Media:" * info[2] * "\"" => 
                            "href=\"./w/images/" * info[1] * "/" * info[2] * "\"", count= info[3])
            end
        end

        # Images linked to in Imagemaps
        if haskey(JJs, fname)           # Images linking to images, which Wiki does not handle nicely
            infos = JJs[fname]
            for info in infos
                txt = replace(txt, "<area href=\"/wiki/Media:" * info[2] * "\" " => 
                            "<area href=\"w/images/" * info[1] * "/" * info[2] * "\" ",count= info[3])
            end
        end 

        txt = replace(txt, "\" title=\"User:Bradford Robert McCormick\"" => "\" title=\"welcome\"")
        txt = replace(txt, "\" title=\"User:Bradford Robert McCormick#" => "\" title=\"welcome#")
        txt = replace(txt, "\" title=\"User:Bradford Robert McCormick/" => "\" title=\"")

        txt = replace(txt, "./w/images" => "../w/images")
        if fname != "JSource"
            txt = replace(txt, r"here in A place To Study"i => "here")
        end
    
        q = length(findall("\t", txt))
        if q > 0
            global unToc *= "  Tabs:" * string(q)
            txt = replace(txt, "\t" => "        ")
        end

        txt = replace(txt, r" data-file-(width|height)=\"[0-9]+\"" => "")

        txt = replace(txt, r"<a href=\"([^\.]+)\.html\" title=\"([^\"]+)\"><span style=\"vertical-align:-1px;font-size:larger;\">O</span>r else!</a>" =>
                s"<a style=\"text-decoration:none;\" href=\"\1.html\" title=\"\2\"><span style=\"vertical-align:-1px;font-size:larger;\">O</span>r else!</a>")

        txt = replace(txt, "<a href=\"IBM.html\" title=\"IBM\"><span style=\"font-weight:bold;color:blue;\">IBM</span></a>" =>
                "<a href=\"IBM.html\" title=\"IBM\" style=\"text-decoration:none;\"><span style=\"font-weight:bold;color:blue;\">IBM</span></a>")
        txt = replace(txt, "<a href=\"THINK.html\" title=\"THINK\"><span style=\"background-color:#E0E0E0;padding:1px 4px 0px 3px;font-weight:bold;border:1px solid #585858;border-radius:3px;\">THINK</span></a>" =>
                "<a href=\"THINK.html\" title=\"THINK\" style=\"text-decoration:none;\"><span style=\"background-color:#E0E0E0;padding:1px 4px 0px 3px;font-weight:bold;border:1px solid #585858;border-radius:3px;\">THINK</span></a>")
        txt = replace(txt, "<a href=\"THINK.html\" title=\"THINK\"><span style=\"background-color:#E0E0E0;padding:1px 4px 0px 3px;font-weight:bold;border:1px solid #585858;border-radius:3px;\">THINK</span>ing</a>" =>
                "<a href=\"THINK.html\" title=\"THINK\" style=\"text-decoration:none;\"><span style=\"background-color:#E0E0E0;padding:1px 4px 0px 3px;font-weight:bold;border:1px solid #585858;border-radius:3px;\">THINK</span>ing</a>")
        txt = replace(txt, "<a rel=\"nofollow\" class=\"external text\" href=\"https://www.mcdonalds.com\">" =>
                "<a rel=\"nofollow\" class=\"external text\" href=\"https://www.mcdonalds.com\" style=\"text-decoration:none;\">")
        txt = replace(txt, r"<a href=\"(Prag|Rubbish).html\" title=\"\1\"><span style=\"([^\"]+)\">☠</span></a>" =>
                s"<a href=\"\1.html\" title=\"\1\" style=\"text-decoration:none;\"><span style=\"\2\">☠</span></a>")
        txt = replace(txt, ">[<a href=\"BRADFORD.html\" title=\"BRADFORD\"><span style=\"font-weight:normal;font-size:smaller;\">18-11-46-503</span></a>]</span></span>" =>
                ">[<a href=\"BRADFORD.html\" title=\"BRADFORD\" style=\"text-decoration:none;\"><span style=\"font-weight:normal;font-size:smaller;\">18-11-46-503</span></a>]</span></span>")
        txt = replace(txt, ">[<a href=\"welcome.html\" title=\"welcome\"><span style=\"font-weight:normal;font-size:smaller;\">18-11-46-503</span></a>]</span></span>" =>
                ">[<a href=\"welcome.html\" title=\"welcome\" style=\"text-decoration:none;\"><span style=\"font-weight:normal;font-size:smaller;\">18-11-46-503</span></a>]</span></span>")

        if fname != "index" && fname != ""
            q = length(txt)
            txt = replace(txt, "<div id=\"content\" class=\"mw-body\"><div id=\"contentSub\"><span class=\"subpages\"><a href=\"welcome.html\"><img alt=\"Prev2a.gif\" src=\"../w/images/1/12/Prev2a.gif\" width=\"10\" height=\"12\" style=\"padding-left:4px;\" /></a><a href=\"welcome.html\" title=\"Welcome!\">Welcome</a></span></div>" => 
                "<div id=\"content\" class=\"mw-body\"><div id=\"contentSub\" style=\"padding-top:2px;\"><span style=\"padding:0px 0px 0px 6px;\"><span class=\"subpages\" style=\"border:1px solid black;border-radius:4px;background-color:lightyellow;padding:2px 6px 3px 1px;font-size:smaller;\"><a href=\"welcome.html\"><img alt=\"Prev2a.gif\" src=\"../w/images/1/12/Prev2a.gif\" width=\"10\" height=\"12\" style=\"padding-left:3px;\" /></a><a href=\"welcome.html\" title=\"Welcome!\">Welcome</a></span></span></div>", count=1)
            if length(txt) <= q
                addSHIT(12)
            end
        end
        #if fname == "Images"
        txt = replace(txt, " class=\"internal\"" => "")
        #end
    
        global ltxti = length(txt)
        ltxts = string(ltxti)
        ltxt = length(ltxts)
        global formattedLength = ltxti < 1000 ? ltxts : ltxts[1:ltxt - 3] * "," * ltxts[ltxt - 2 : ltxt]

        ID = SHIT * ". ~" * formattedLength
        if fname != "JSource"
            txt = replace(txt, "!QWERTY!" => ID, count=1)
        else 
            OMG = findall("!QWERTY!", txt)
            OMG2 = OMG[length(OMG)]
            till = length(txt)
            txtq = "" * txt
            txt = txt[1:OMG2.start - 1] * ID * txt[OMG2.stop + 1 : length(txt)]
            txtx = replace(txt, ID => "!QWERTY!", count=1)
            if txt[length(txt):length(txt)] != ">" || till >= length(txt) || txtq != txtx 
                println("OMG2 JSource! ", txt[length(txt):length(txt)] != ">", " ", till >= length(txt), " ", txtq != txtx)
                exit(16)
            end
        end

        z = open(length(fname) > 0 ? fname * ".html" : "welcome.html", "w")
        write(z, txt)
        close(z)

        global brms = length(findall("User:Bradford Robert McCormick", txt))
        global BRMs += brms
        global brms = brms == 0 ? "" : ("  BRMs:" * string(brms))
    
        # Find all missing images
        images = findall(r" (src|href)=\"[^\"]+", txt)
        for i = 1 : length(images)
            str0 = txt[images[i]]
            if !contains(str0, "./w/images/")
                continue
            end
            str1 = replace(str0, "%27" => "'")
            off = findfirst("\"", str0)
            str = str1[(off[1] + 3):length(str1)]

            if haskey(ImageCache, str)
                ImageCache[str] += 1
            elseif !isfile(str)
                strd = "./" * str[1:13]
                if !isdir(strd)
                    mkdir(strd)
                    println("  ", strd)
                end
                addToDict(str0 * "\"", fname);
                println("      ", str)               
            end
        end
    
    catch ex
        s = string(ex)  
        if length(s) > 200
            s = s[1:200] * "..."
        end
        println("\n      Failure: ", typeof(ex), ".\n", s);
        #exit(16)
        push!(failures, fname)
        return 0
    end

    v = "  *X-V5"
    global wpct += 1
    if findfirst("/c/ca/HTML5V.png", txt) != nothing
        v = ""
        global vpct += 1
    end
    
    println(seq * "   Done: " * printhole * ".html", " " ^ (24 - length(printhole)), 
                "e/t: " * string(round(time() - st, sigdigits=7)) * "  " * formattedLength * unToc * v * brms *
                "\n              " * SHIT * " GMT") 
    return ltxti
end

global ftp = nothing
global inputIsArray = false

if length(ARGS) == 1
    argsx = ARGS[1]
    argsx = replace(argsx, "TREE" => "Tree, RTree, XTree", count=1) 
    if findfirst(",", argsx) == nothing
        doAFile(argsx != "welcome" ? argsx : "", "     ")
        exit(0)
    end
    global ftp = split(argsx, ",")
    global inputIsArray = true
elseif length(ARGS) != 2
    println("Bad number parameters (" * string(length(ARGS)) * ")!")
    exit(16)
end

fillImageDict()

global fl = "[GKW]"
try
    gst = time()
    if ftp == nothing
        f = open(ARGS[2])
        global ftp = readlines(f)
        close(f)
    end
    for fla in ftp
        global fl = strip(fla)
        if length(fl) < 1
            continue
        end
        if nrr == 1 && fl[1:1] == "#"
            global line1 = fl * "\n"
            continue
        end
        #sleep(2)
        nrq = string(nrr) 
        global totalSize += doAFile(fl != "welcome" ? fl : "", " " ^ (4 - length(nrq)) * nrq * " ")
        global nrr += 1
        
    end

    ltxts = string(totalSize)
    ltxt = length(ltxts)
    if ltxt > 6
        xformattedLength = ltxts[1:ltxt - 6] * "," * ltxts[(ltxt - 5) : (ltxt - 3)] * "," *
                    ltxts[ltxt - 2 : ltxt]
    elseif ltxt > 3
        xformattedLength = ltxts[1:ltxt - 3] * "," * ltxts[ltxt - 2 : ltxt]
    else
        xformattedLength = ltxts
    end

    b = time() - gst
    c = floor(Int, b / 60)
    d = round(b - (c * 60), sigdigits=7)
    e = string(c) * "m" * (d < 10 ? "0" : "") * string(d) 
    println("\nTotal size: " , xformattedLength, "  (" * string(vpct) * "/" * string(wpct) *
                ": " * string(wpct - vpct) * ")  e/t: " * e * "   [" * getNow() * "]\nfailures: " * string(failures))
catch ex
    s = string(ex)  
    if length(s) > 200
        s = s[1:200] * "..."
    end
    println("\n      fl: " * fl * ". Failure: ", typeof(ex), ".\n", s);
    exit(16)
end

if inputIsArray
    exit(0)
end

global MIASMA = []

ks = keys(MIAs)
if length(ks) > 0
    println(" ")
    for k in ks
        #println(k, "  ", MIAs[k])
        push!(MIASMA, k * "  " * string(MIAs[k]))
    end
end

global dx = []
if length(MIASMA) == 0
    println("(No missing images)")
else
    MIASMA = sort(MIASMA)
    global prvxxx = MIASMA[1][2:2]
    for mk = 1 : length(MIASMA)
        mmk = MIASMA[mk]
        dxi = replace(mmk, r".*?\"([^\"]+).*" => s"\1", count=1)
        dif = ""
        if !(dxi in dx)
            dif = "*" 
            push!(dx, dxi)
        end 
        nextprv = mmk[2:2]      # This is messed up; there should not be the leading blank
                                       # but I'm not risking fixing it, so kludgiong it
        println((nextprv != prvxxx ? "\n" : "") * dif * mmk)
        global prvxxx = nextprv 
    end
end

global unused = ""
global unusedPfx = ""
global Uct = 0
ks = keys(ImageCache)
global ReverseImages = Dict{Int32, String}()
for k in ks
    if ImageCache[k] == 0
        global unused *= unusedPfx * "\"" * k * "\""
        global unusedPfx = ", "
        global Uct += 1
    else
        kn = ImageCache[k]
        kk = k[15:length(k)]
        if !(kk in ["Prev2a.gif", "Next2a.gif", "Spacer.gif", "HTML5V.png"]) 
            if haskey(ReverseImages, kn)
                global ReverseImages[kn] *= ", " * "\"" * kk * "\""
            else
                global ReverseImages[kn] = "\"" * kk * "\""
            end
        end
    end
end
if length(unused) > 0
    print("\nUnused: " * unused * "  (" * string(Uct) * ")")
end 
println("\nBRMs:" * string(BRMs) * "  SHITs: " * string(countSHIT))

println("\n--------")
global shit = []
for x in keys(ReverseImages)
    push!(shit, x)
end
shitx = sort(shit, rev=true)
global nuthin = "[nuthin]"
for i = 1 : length(shitx)
    sq = shitx[i]
    if sq < 5 && sq > 1
        continue
    end
    s = string(sq)    
    println(" " ^ (6 - length(s)) * s, "   ", ReverseImages[sq])
    global nuthin = ""
end
if nuthin != ""
    println("    " * nuthin)
end

if length(ARGS) == 2 && ARGS[2] == "WB-ALL"
    x = open("WBLOG-TS", "w")
    n = getNow()
    t = "\n" * line1 * "\n" * "WB-ALL v" * versionNr * ". " * n[1:10] * "T" * n[12:16] * ".\n" 
    write(x, t)
    close(x)
    println("\n" * t)
end
 

Return to TOC!Return to TOC

WB_Include

#APFS = "043" # WB_Include:APFS
#<span id="Table">Table for links to images in images</span>

mp1 =                   ["e/ee", "APL_1083.jpg"    ,1] 
mp2 =                   ["a/ae", "Cosmos_600.jpg"  ,1]  
mp3 =                   ["d/d3", "GoodSportspersonship.jpg",1] 
mp4 =                   ["0/08", "Buttocks.jpg"    ,1] 
mp5 =                   ["6/6b", "TalibanMadrasa.jpg"]
mp6 =                   ["1/1d", "WhatJocksGet2.gif"]
mp7 =                   ["3/3b", "HarryAndMeghanBig.jpg"]
mp8 =                   ["9/98", "Sacrifice_499.jpg",1]
mp9 =                   ["c/ca", "Dell-EMC.gif" ,1]
mp10 =                  ["8/83", "HeideggerPlayingPeasant.gif",1]
    
global IIs = Dict{String, Array{Array{Any}}}(
    "ADLB"          => [mp10],
    "AntiAnti"      => [["d/dd", "Reagan.jpg"      ,1]],
    "Arch"          => [["7/73", "VV1.png"         ,1]],
    "AS"            => [mp9],  
    "BLM"           => [mp3],
    "BRADFORD"      => [["a/ac", "Brad.jpg"        ,2],
                        ["8/88", "Knot1.jpg"       ,1]],
    "Bottom"        =>  [mp8],
    "C19C"          => [["f/fe", "IranianBoss.jpg" ,1]],
    "CCC"           => [["5/54", "Poolside.jpg"    ,1]],
    "Cats"          => [["8/8e", "Rasputin.jpg"    ,1]],
    "Cher"          => [["8/8e", "Cher.jpg"        ,1],
                        ["a/a6", "PeggyAndFrank.png",1]],
    "Circ"          => [["d/d8", "Bees_BLM.jpg"    ,1]],
    "CirceEtCie"    => [["8/8a", "PatsyOnSteroids.jpg",2]],
    "Darkness"      => [["d/df", "Geisha.jpg"      ,1], 
                        ["3/3b", "TribeswomanQ.jpg",1]],
    "Dashboard"     => [["c/c2", "Cornaro.gif"     ,1]],
    "EndOfEarth"    => [["d/d4", "RussiaMap.png"   ,1]],
    "Fopland"       => [[mp7[1], mp7[2]            ,1]],
    "GO-power"      => [["7/77", "Martha-stewart2.jpg",1]],
    "Hegel"         => [mp4],
    "Huang"         => [mp3,
                        [mp6[1], mp6[2]            ,4]],
    "Innocence"     => [mp8],
    "JustSo"        => [[mp4[1], mp4[2]            ,2]],
    "LaNotte"       => [["9/97", "Muslims.png"     ,2]],
    "LifeLite"      => [[mp7[1], mp7[2]            ,1]],
    "ManAndGod"     => [mp2],
    "Meta"          => [mp1],
    "Misc"          =>  [mp8],
    "Mullah"        => [[mp5[1], mp5[2]            ,2]],
    "NaiveArt"      => [["1/14", "WarholeSoup.jpg" ,1]],
    "NoBigDeal"     => [mp8],
    "PK"            => [["4/45", "30BMW.jpg"       ,1]],
    "Patriotism"    => [mp8],
    "Perspective"   => [["d/dc", "MarienbadGarden.gif",1],
                        ["7/71", "LT_C.jpg"        ,1]],
    "PhilosoBabble" => [["f/f7", "JFKMask.gif"     ,1]],
    "Philosophy"    => [[mp10[1], mp10[2]          ,2]],
    "Play2"         => [mp1],
    "PrepForWhat"   => [[mp6[1], mp6[2]            ,1],
                        mp4],
    "Shoulders"     => [mp10],
    "Stall"         => [["0/03", "MensRoom.jpg"    ,1]],
    "StP"           => [[mp5[1], mp5[2]            ,1]],
    "Suburbia"      => [["a/a8", "1953-Firebird-1-XP-21.jpg",1],
                        ["c/c1", "BranchOffice.gif",1]],
    "Truman"        => [mp2],          
    "TwoPaths"      => [["5/54", "Cosmogony.jpg"   ,1],
                        ["8/81", "NancyInvert.jpg" ,1]],
    "Waste"         => [[mp4[1], mp4[2]            ,5],
                        mp8],
    "isms"          => [["1/19", "Deal.gif"        ,2]],
    "passum_sub_iugum" => [mp9]      
)

global JJs = Dict{String, Array{Array{Any}}}(
    "Darkness"      => [["8/87", "Nickel_396.gif"  ,1],
                        ["8/81", "JeffersonNYT.jpg",1]],
    "Fopland"       => [["8/8d", "AOC.gif"         ,1],
                        ["3/33", "AOCDress.jpg"    ,1]],
    "PsychicDeadness"=> [["c/c5", "1950s.jpg"      ,2]],
    "Rubbish"       => [["e/e4", "LastSupper.jpg"  ,1]],
    "Suburbia"      => [["c/ca", "Despair.jpg"     ,1]]
)

Return to TOC!Return to TOC

Julia script to update last update timestamp file (WBupdate)

using Dates

APFS = "003" # WBupdate:APFS
global version = APFS

inf = "\n" * "WBupdate(" * version *"):   \033[" * "31" * ";1m" * string(now())[1:16] * "\033[0m\n"
w = open("WBLOG-TS", "a")
write(w, inf)
close(w)
println(inf)

#\033[" * string(clr) * ";1m|" * string(clr) * "|\033[0m"

Return to TOC!Return to TOC

Julia script to check for not current files in Local and Bmccedd (WBXXX)

#using Pkg; Pkg.add("HTTP")
using Dates
using HTTP

APFS = "014" # WBXXX:APFS           # VERSION STAMP
version = APFS

function getNow()
    dt = string(Dates.now())
    dtx = findfirst('T', dt)
    return(dt[1: dtx - 1] * " " * dt[dtx + 1: length(dt)])
end

function toDecimal(d)
    q = [parse(Int32, d[1:4]), parse(Int32, d[6:7]), parse(Int32, d[9:10]), 
                parse(Int32, d[12:13]), parse(Int32,d[15:16])]
    return q
end

function getDiff(xc,yc)
    x = toDecimal(xc)
    y = toDecimal(yc)
    a = Int64(Dates.value(Dates.DateTime(x[1],x[2],x[3],x[4],x[5]) - 
                Dates.DateTime(y[1],y[2],y[3],y[4],y[5]))/1000)
    b = Int64(trunc(a / (24 * 60 * 60)))
    bb = a - b * (24 * 60 * 60)
    c = Int64(trunc(bb / (60 * 60)))
    cc = bb - (c * 60 * 60)
    d = Int64(trunc(cc / 60))
    return (b > 0 ? string(b) *"d " : "") * string(c) * "h " * string(d) * "m"
end
    
if length(ARGS) != 1 || !(uppercase(ARGS[1]) == "APTS" || uppercase(ARGS[1]) == "LOCAL")
    println("Need one argument: \"APtS\" or \"Local\"")
    exit(16)
end
global APtS = uppercase(ARGS[1]) == "APTS"
println("\nWBXXX v" * version * " at: " * getNow()[1:16] * " doing: " * 
                (APtS ? "APtS => Local" : "Local => Dreamhost") * "\n") 

mos = Dict{String, String}([
    "Jan" => "01", "Feb" => "02", "Mar" => "03", "Apr" => "04", "May" => "05", "Jun" => "06",
    "Jul" => "07", "Aug" => "08", "Sep" => "09", "Oct" => "10", "Nov" => "11", "Dec" => "12"
])
global rejects = []
global nuthin = true
global todoString = ""
gst = time()

global a = readdir()
global aa = length(a) 
for q = 1 : aa
    if q % 50 == 0
        println("Processed: " , q)
    end
    f = a[q]
    lf = length(f)
    if lf < 6 || f[lf- 4 : lf] != ".html"
        push!(rejects, f)
        continue
    end
    res = "" 
    you = f[1 : lf - 5]
    you2 = ""
    if APtS
        you2 = you == "welcome" ? "" : ("/" * you)
    else
        you2 = "/" * f
    end 
    try
        fn = APtS ? "https://www.aplacetostudy.com/wiki/User:Bradford_Robert_McCormick" : 
                    "https://www.bmccedd.org"
        res = HTTP.head(fn * you2)
    catch ex
        if you == "IntoTheLight" && APtS
            println("    [IntoTheLight does not exist in APtS]")
            continue
        end
        s = string(ex)  
        if length(s) > 200
            s = s[1:200] * "..."
        end
        println("\n      Failure1: ", typeof(ex), ".\n", s);
        global nuthin = false
        continue
    end
    try
        locl = string(Dates.unix2datetime(mtime(f)))[1:16]
        res = string(res)
        # Last-Modified: Wed, 08 Dec 2021 09:05:59 GMT
        dt = findfirst(r"Last-Modified: .*?GMT", res)
        dt = res[dt][21:44]
        dtx = dt[8:11] * "-" * mos[dt[4:6]] * "-" * dt[1:2] * "T" * dt[13:17]
        if APtS
            if dtx >= locl 
                println("    APtS => Local:  " * dtx, " >= ", locl, ".   " , you, 
                            "  (" , getDiff(dtx, locl), ")")
                global nuthin = false
                global todoString *= ", " * you 
            end
        else
            if locl >= dtx
                sz = string(stat(f).size)
                lensz = length(sz)
                if lensz > 3
                    sz = sz[1:lensz - 3] * "," * sz[lensz - 2:lensz]
                end 
                println("    Local => Dreamhost:  " * locl, " >= ", dtx, ".   " , you, 
                            "  (" , getDiff(locl, dtx), ") " , sz)
                global nuthin = false                
            end
        end
    catch ex
        s = string(ex)  
        if length(s) > 200
            s = s[1:200] * "..."
        end
        println("\n      Failure2: ", typeof(ex), ".\n", s);
        continue
    end    
end

if nuthin
    println("\n[No work to do]")
end
if todoString != ""
    println("\ntodoString: \"" * todoString[3 : length(todoString)] * "\"")
end

b = time() - gst
c = floor(Int, b / 60)
d = round(b - (c * 60), sigdigits=7)
e = string(c) * "m" * (d < 10 ? "0" : "") * string(d)

println("\n", getNow(), ". [" * e * "].  " * string(rejects))

   

Return to TOC!Return to TOC

Julia script list all html files in a directory for use in "WB" script (WBListAll)

using Dates

APFS = "001" # WBListAll:APFS
version = APFS
global ctr = 0
global out = ""
global problems = ""
dict = Dict{String, Bool}()

z = open("IndexOfSubjects.html", "r")
txt = String(read(z))
close(z)

re = r"<li><a href=\"([^\.]+)\.html\" title=\"[^\"]+\">\1</a>"
z = findall(re, txt)
for zzz in z
    str = txt[zzz]
    str = replace(str, re => s"\1",count=1)
    dict[str] = false
end
txt = replace(txt, re => "")
z = findall(r"<li><a href=\"([^\"]+)\"", txt)
for zzz in z
    global problems *= "GKW: '" * txt[zzz] * "'\n"
end
 
dict["IntoTheLight"] = false

global hits = 0
a = readdir()
for itm in a
    x = findfirst(".html", itm)
    if x == nothing
        continue
    end
    itm = itm[1: (x.start - 1)]
    if haskey(dict, itm)
        if dict[itm]
            global problems *= "Duplicate: \"" * itm * "\"\n"
        else
            dict[itm] = true
            global hits += 1
        end
    else
        global problems *= "Missing: \"" * itm * "\"\n"
    end 
    global out *= itm * "\n"
    global ctr += 1
end

for x in keys(dict)
    if !dict[x]
        global problems *= "Only in IndexOfSubjects: \"" * x * "\"\n"
    end
end

OUTPUTFILE = "WB-ALL"
z = open(OUTPUTFILE, "w")

zz = "# WBListAll " * version * ". ctr: " * string(ctr) * ". hits: " * string(hits) * ". " * string(now())[1:16]
print("\n" * zz * "\n\n" * problems)
write(z, zz * "\n" * out)
close(z)

Return to TOC!Return to TOC

Julia script to search for character strings in WB backup files (WBsearch)

using Dates

APFS = "004" # WBsearch:APFS
version = APFS
global t = time();
global gotsomething = false
global SZ = Dict{String, String}()

global PRE = 18
global POST = 36

if length(ARGS) == 3
    global PRE = parse(Int32, strip(ARGS[2]))
    global POST = parse(Int32, strip(ARGS[3]))
end

OUTPUTFILE = pwd() * "\\..\\JUNK.html"
OUTPUTFILE2 = pwd() * "\\..\\JUNK2.txt"

aa = strip(ARGS[1]);

if findfirst(",", aa) != nothing
    global searchStrings = split(aa, ",")
else 
    global searchStrings = [aa]
end

global shit = []
for w in searchStrings
    ww = strip(w)
    lent = length(ww)
    if ww[1] == '[' && ww[lent] == ']'
        ww = ww[2 : lent - 1]
    end    
    ww = Regex(ww, "i")
    push!(shit, ww)
end
searchStrings = shit

global errId = 0
global ctr = 0
global cctr = 0

global out = "<table style=\"border-collapse:separate;font-family:monospace;font-weight:bold;font-size:large;padding:0px 12px 20px 6px;\">"
try
    global errId = 1
    a = readdir()
    global errId = 2
    for itm in a
        if findfirst(".html", itm) == nothing
            continue
        end
        item = itm
        f = open(item)
        global errId = 4
        res = read(f)
        global errId = 5
        close(f)
        lenRes = length(res)
        if lenRes > 49999
            lenRes = "            " * string(lenRes)
            lenLenRes = length(lenRes)
            chk = lenRes[lenLenRes - 10 : lenLenRes]
            while get(SZ, chk, "---") != "---"
                chk = chk * "-"
            end          
            SZ[chk] = item
        end
        global ctr += 1
        if ctr % 50 == 0
            println(ctr, "  " , round(time() - t, digits=4))
        end        
        txt = String(res)
        global cctr += length(txt)
        fuck = []
        quotes = ""
        ct = 1
        for s in searchStrings
            qqk = findall(s, txt)
            qq = length(qqk)
            for itm in qqk
                alpha = itm.start - PRE
                omega = itm.stop + POST
                if alpha < 1
                     omega -= alpha - 1
                     alpha = 1
                end
                if omega > length(txt)
                    omega = length(txt)
                end
                tq = txt[alpha:omega]
                aaw = findfirst(s, tq)
                tq = tq[1 : aaw.start - 1] * "WQWQWQ" * tq[aaw.start : aaw.stop] * "XQXQXQ" *
                        tq[aaw.stop + 1: length(tq)]

                tq = replace(tq, ";" => "!!!!!!!!#59;")  # Some characters here not display correct on JSource page. Use page source!
                tq = replace(tq, "&" => "&")
                tq = replace(tq, "!!!!!!!!" => "&")
                tq = replace(tq, "<" => "<")   
                tq = replace(tq, ">" => ">") 
                tq = replace(tq, "\"" => """)
                tq = replace(tq, "'" => "'")
                tq = replace(tq, "/" => "/")
                tq = replace(tq, "{" => "{")
                tq = replace(tq, "}" => "}")
                tq = replace(tq, " " => " ")

                tq = replace(tq, "WQWQWQ" => "<span style=\"border-bottom:1px solid black;font-weight:normal;color:black;\">", count=1)    # Underscore the search text!
                tq = replace(tq, "XQXQXQ" => "</span>", count=1)

                inf = "<br>" * string(ct) * ". " * string(itm)
                quotes *= inf * (" " ^ (22 - length(inf))) * "<span style=\"background-color:lightyellow;padding:1px 6px 1px 5px;color:darkred;\">" * tq * "</span>"
            end 
                
            push!(fuck,  qq)
            ct += 1
        end
        if quotes != ""
            global out *= "\n<tr><td style=\"vertical-align:top;line-height:135%;\"><a href=\"WikiBkup\\" * item * "\">**</a></td><td> </td><td style=\"vertical-align:top;line-height:135%;\">" * item * "</td><td> </td><td style=\"line-height:135%;vertical-align:top;\"><span style=\"font-weight:normal;\">" * string(fuck) * "</span> " * quotes * "</td></tr>"
            global gotsomething = true
        end
    end
catch ex
    s = string(ex)  
    if length(s) > 200
        s = s[1:200] * "..."
    end
    println("\n      Failure[" * string(errId) * "]: ", typeof(ex), ".\n", s);
    exit(16)
end
global out *= "\n" * (gotsomething ? "" : "<tr><td>[No matches]</td><tr>") * "</table></div></body></html>"

stotlen = string(cctr)
if cctr> 999
    stotlen = stotlen[1:length(stotlen) - 3] * "," *
            stotlen[length(stotlen) - 2 : length(stotlen)]
end
if cctr > 999999
    stotlen = stotlen[1:length(stotlen) - 7] * "," * 
            stotlen[length(stotlen) - 6 : length(stotlen)]
end 
pre = "<html><head></head><body><div style=\"margin:40px 0px 30px 80px;\"><p style=\"line-height:150%;font-family:sans-serif;font-weight:bold\">" 
pre *= string(searchStrings) * ".  " * OUTPUTFILE
pre *= "<br>Files: " * string(ctr) * ".  Chars: " * stotlen * ".  Time: " * string(round(time() - t, digits=4)) * 
    ".  v" *  version * "</p>"

z = open(OUTPUTFILE, "w")
write(z, pre * out)
close(z)

kk = keys(SZ)
fuck = []
for k in kk
    push!(fuck, string(k))
end
fuck = sort(fuck, rev = true)
global fu = ""
for f in fuck
    global fu *= f * "   " * SZ[f] * "\n"
end 

z = open(OUTPUTFILE2, "w")
zn = string(now())
zn = zn[1:10] * " " * zn[12 : length(zn)]    
write(z, "    " * zn * "\n\n" * fu)
close(z)

println("Output saved to: " * OUTPUTFILE* ".  Time: " * string(round(time() - t, digits=4)) * ".  v" *  version)

if length(ARGS) > 1
    run(`"C:\Program Files\Google\Chrome\Application\chrome.exe" $OUTPUTFILE`)
end

Return to TOC!Return to TOC

Julia script to show images used (WBcount)

using Dates

APFS = "045" # WBCount:APFS
version = APFS

global unhex = Dict(
    "0" => 0, "1" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5, "6" => 6, "7" => 7,
    "8" => 8, "9" => 9, "a" => 10, "b" => 11, "c" => 12, "d" => 13, "e" => 14, "f" => 15
)
global tohex = Dict(
    0 => ".", 1 => "1", 2 => "2", 3 => "3", 4 => "4", 5 => "5", 6 => "6", 7 => "7", 8 => "8", 
    9 => "9", 10 => "a", 11 => "b", 12 => "c", 13 => "d", 14 => "e", 15 => "f"
)
global distr = []
for i = 1:256
    push!(distr,0)
end

global tbl = Dict()
global maxLen = -1
global ct = 0
global rejects = []
global dshit = []

for (root, dirs, files) in walkdir(".")
    #println("Directories in $root")
    #for dir in dirs
    #    println(joinpath(root, dir)) # path to directories
    #end
    #println("Files in $root")
    for file in files
        x = joinpath(root, file) # path to files
        #if !contains(x, "images")
        if findfirst(r"^\.\\images\\([0-9a-f])\\\1[0-9a-f][\\]", x) == nothing
            push!(rejects, x)
            continue
        end
        y = length(x)
        z = x[15:y]
        zLen = length(z)
        if zLen > maxLen
            global maxLen = zLen
        end
        global tbl[z] = replace(x[1:14], r"[\\]" => "/")
        global ct += 1
        if !(tbl[z] in dshit)
            push!(dshit, tbl[z])
        end
    end
end
dt = string(Dates.now())
dtx = findfirst('T', dt)
dtx = replace(dt[1: dtx - 1] * " " * dt[dtx + 1: length(dt)], r"\.[0-9]+" => "", count=1)
global stuff = "[v" * version * "] " * pwd() * "<br>maxLen: " * string(maxLen) * ",  count: " *
           string(ct) * ",  dirs: " * string(length(dshit)) * 
           ".  ([[{{BRM|Images}}|Images]]/[[Template:BRM_Images|T]])"
println(stuff) 
global stuff *= "  [<span style=\"color:blue;\">" * dtx * "</span>]<br>\n"

kk = keys(tbl)
fuck = []

for k in kk # keys(tbl)
    push!(fuck, k)
end
fuck = sort(fuck, by=lowercase)
global stuff *= "<div style=\"height:510px;width:600px; overflow:auto; border: 1px solid black;border-radius:6px;margin:16px 0px 14px 0px;padding:0px 10px 2px 10px;background-color:lightyellow;\"><table style=\"font-family:sans-serif;border-collapse:separate;margin:8px 0px 4px 12px;\">"
for ks in fuck

    ww = tbl[ks]
    w = unhex[ww[12:12]] * 16 + unhex[ww[13:13]] + 1
    distr[w] += 1

    # <!-- td><span style=\"padding-left:16px;\">[[File:Next2a.gif|link=Media:" * ks * "|Go to Wiki record for image!]]</span></td -->

    global stuff *= "<tr><td>[[Media:" * ks * "|" * tbl[ks] * "]]</td><td><span style=\"font-weight:bold;padding-left:38px;color:blue;\">" * ks * 
            "</span></td><td style=\"text-align:right;\">--" * ks * "--</td></tr>\n"
end

for r in rejects
    println(r)
end

println("\n-------")

global ImageCache = Dict{String, Int32}()
global ict = 0
global failures = []
cd("../")                # This shit makes no sense to me, so I cheated. GODDAMNED RIGHT!

try
    for (root, dirs, files) in walkdir("./w/")
        for file in files
            x = joinpath(root, file) # path to files
            if !contains(x, "images")
                continue
            end
            z = replace(x, "\\" => "/")
            global ImageCache[z[3 : length(z)]] = 0 
            global ict += 1
        end
    end
    global errId = 1
    a = readdir()
    global errId = 2
    for itm in a
        if findfirst(".html", itm) == nothing
            continue
        end
        global item = itm
        f = open(item)
        global errId = 4
        src = read(f)
        global errId = 5
        close(f)
        txt = String(src)

        images = findall(r" (src|href)=\"[^\"]+", txt)
        for i = 1 : length(images)
            str0 = txt[images[i]]
            if !contains(str0, "./w/images/")
                if length(str0) >= 10 && str0[1:10] == " href=\"w/i"
                    str0 = replace(str0, " href=\"" => " href=\"./", count = 1)
                elseif length(str0) >= 9 && str0[1:9] == " src=\"w/i"
                    str0 = replace(str0, " src=\"" => " src=\"./", count = 1)
                else
                    continue
                end                
            end
            str1 = replace(str0, "%27" => "'")
            off = findfirst("\"", str0)
            str = str1[(off[1] + 3):length(str1)]

            if haskey(ImageCache, str)
                ImageCache[str] += 1
            elseif !isfile(str)
                strd = "./" * str[1:13]
                if !isdir(strd)
                    mkdir(strd)
                    println("  ", strd)
                end
                println("?MISSING: ", str)
            else
                println("?GODKNOWSWHAT: ", str)               
            end
        end
    end
    
catch ex
    s = string(ex)  
    if length(s) > 200
        s = s[1:200] * "..."
    end
    println("\n      Failure: ", typeof(ex), ".\n", s);
    #exit(16)
    push!(failures, item)
    return 0
end

global unused = ""
global unusedPfx = ""
global Uct = 0
ks = keys(ImageCache)
global ReverseImages = Dict{Int32, String}()
global bigsum = 0
for k in ks
    if ImageCache[k] == 0
        global unused *= unusedPfx * "\"" * k * "\""
        global unusedPfx = ", "
        global Uct += 1
    else
        kn = ImageCache[k]
        kkX = k[15:length(k)]

        global stuff = replace(stuff, "--" * kkX * "--" => string(kn), count=1)
        global bigsum += kn

        if !(kkX in ["Prev2a.gif", "Next2a.gif", "Spacer.gif", "HTML5V.png"]) 
            if haskey(ReverseImages, kn)
                global ReverseImages[kn] *= ", " * "\"" * kkX * "\""
            else
                global ReverseImages[kn] = "\"" * kkX * "\""
            end
        end
    end
end

print("Going to save ../WBCountOut : (" * pwd() * ") ")
q = open("WBCountOut", "w")
sbs = string(bigsum)
sbsLen = length(sbs)
if sbsLen > 3
    sbs = sbs[1: sbsLen - 3] * "," * sbs[sbsLen - 2: sbsLen]
end
write(q, stuff * "<tr><td colspan=3 style=\"text-align:right;\">" *
        "<span style=\"border:1px solid black;padding:1px 6px 1px 4px;background-color:white;\">Σ " * 
        sbs * "</span></td></tr></table></div>")
close(q)
println("../WBCountOut saved.")

if length(unused) > 0
    print("\nUnused: " * unused * "  (" * string(Uct) * ")")
end 

global shit = []
for x in keys(ReverseImages)
    push!(shit, x)
end
shitx = sort(shit, rev=true)
global nuthin = "[nuthin]"
println(" ")
for i = 1 : length(shitx)
    sq = shitx[i]
    if sq > 1 && sq < 5
        continue
    end
    s = string(sq)    
    println(" " ^ (6 - length(s)) * s, "   ", ReverseImages[sq])
    global nuthin = ""
end
if nuthin != ""
    println("    " * nuthin)
end

global shi = []
for s = 1:20
    append!(shi,0)
end

global crap = ""
for i = 1 : length(distr)
    if i % 64 == 1
        global crap *= "\n    "
    end
    global shi[distr[i] + 1] += 1 
    global crap *= tohex[distr[i]]
end

global mulch = 0
for i = 1: length(shi)
    global mulch += (i - 1) * shi[i]
    if shi[i] != 0
        global shi[i] = [i - 1, shi[i], mulch]
    end
end
for i = 1 : length(shi)
    if shi[length(shi)] != 0
        break
    end
    global shi = copy(shi)[1:length(shi) - 1]
end 

global shidt = 0
global shid = []
for i = 2 : length(shi)
    sh = shi[i][2] * (i - 1)
    append!(shid, sh) #  - shi[i - 1][3])
    global shidt += sh
end 

println(crap, "\n\n", shi, "\n\n", shid, " ", shidt)

Return to TOC!Return to TOC

Julia script to list versions of script files (WBversions)

using HTTP

APFS = "002" # WBversions:APFS
version = APFS
global errId
global ng = []
global ngd = []
global ngq = []
global itm
global maxlen = 16
global JSource = "?"
global digits = ["0","1","2","3","4","5","6","7","8","9"] 
println(" ")

function processADirectory(adir, sd)
    try
        global errId = 1
        for itmm in adir
            global itm = itmm
            if findfirst(".html", itm) != nothing    
                continue
            end 
            if findfirst(".", itm) != nothing || itm in ["c9", "w", "css", "pdfs", "images", "txts"]
                push!(ngq, itm)
                continue
            end
            if itm[length(itm) : length(itm)] in digits
                push!(ngd, itm)
                continue;
            end
            global errId = 2
            f = open(sd * itm)
            global errId = 3
            res = read(f)
            global errId = 4
            str = String(res) 
            global errId = 5

            magic = Regex("APFS = \"([^\"]+)\" # " * itm * ":APFS")       
            f = findfirst(magic, str)
            if f != nothing
                ff = str[f]
                f = replace(ff, magic => s"\1", count = 1)
                sditm = sd * itm
                g = findfirst(magic, JSource)
                if g == nothing
                    println(sd * itm, " " ^ (maxlen - length(sditm)), "Not found: \"", ff, "\"")
                else
                    gg = JSource[g]
                    g = replace(gg, magic => s"\1", count = 1)
                    part1 = sd * itm * (" " ^ (maxlen - length(sditm))) * " \"" * f * "\""
                    part1 = part1 * (" " ^ (28 - length(part1)))
                    if f == g 
                        println(part1, "OK")
                    else
                        println(part1, "!= \"", g, "\"")
                    end
                end
            else
                push!(ng, sd * itm)
            end
        end 
    catch ex
        s = string(ex)  
        if length(s) > 200
            s = s[1:200] * "..."
        end
        println("\n      Failure processADirectory[" * itm * " " * 
                string(errId) * "]: ", typeof(ex), ".\n", s);
        exit(16)
    end
end

try
    errId = 8
    res = HTTP.get("https://www.aplacetostudy.com/wiki/User:Bradford_Robert_McCormick/JSource");
    errId = 9
    global JSource = String(copy(res.body))

    sd = ""
    global errId = 10
    a = readdir(pwd() * sd)
    processADirectory(a, sd)
    global errId = 11
    sd = ".\\w\\"
    a = readdir(pwd() * sd)
    global errId = 12
    processADirectory(a, sd)
    global errId = 11
catch ex
    s = string(ex)  
    if length(s) > 200
        s = s[1:200] * "..."
    end
    println("\n      Failure mainline[" * string(errId) * "]: ", typeof(ex), ".\n", s);
    exit(16)
end
println("\n", ngq)
println("\n", ngd)
println("\n", ng)

Return to TOC!Return to TOC

Julia script to list HTML files changed after a certain date (WBafter)

using Dates

global nonWikis = ["IntoTheLight.html"]

APFS = "023" # WBafter:APFS
version = APFS                  #    2021-11-01T12:00
global t = time();
global deflt = false
global tot = 0
global nomatches = true
global ARGS1 = ARGS[1]

if length(ARGS1) == 1
    x = open("WBLOG-TS", "r")
    y = readlines(x)
    z = y[length(y)]
    global ARGS1 = z[findfirst(r"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}", z)]
end
    
if length(ARGS) < 3 || length(ARGS1) != 16 || length(ARGS[2]) != 2 || ARGS1[11] != 'T' || ARGS1[5] != '-' || ARGS1[8] != '-' ||
                ARGS1[14] != ':'
    println("\n** Format for input: \"2021-11-19T23:00:28 30 5 [before]\"")
    exit(16)
end

y = parse(Int,ARGS1[1:4])
m = parse(Int,ARGS1[6:7])
d = parse(Int,ARGS1[9:10])
h = parse(Int,ARGS1[12:13]) + parse(Int, ARGS[3])   # local to gmt time
if h > 23 
    h = h - 24
    d += 1;
end
if d > parse(Int, ARGS[2])
    d = 1
    m += 1
end
if m > 12
    m = 1
    y += 1
end
y = string(y)
m = string(m)
if length(m) == 1
    m = "0" * m
end
d = string(d)
if length(d) == 1
    d = "0" * d
end
h = string(h)
if length(h) == 1
    h = "0" * h
end
gmt = y * "-" * m * "-" * d * "T" * h * ARGS1[14:length(ARGS1)]

dt = "<img src=\"../w/images/5/52/Spacer.gif\" alt=\"[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,3})?\\. ~[0-9,]+\" width=\"2\" height=\"2\" />"   

global d = Regex("</div>[ \n\r]+</div><div class=\"read600\"><br style=\"clear:both;\">" *dt * "</div></body></html>")

global dx = Regex("<!-- GMT -->" * dt * "<!-- GMT -->")

global OUTPUTFILE = "..\\" * (length(ARGS) == 4 && uppercase(ARGS[4]) == "BEFORE" ? "BEFORE" : "AFTER") * ".html"

global errId = 0
global ctr = 0
global cctr = 0
global itmx
global out = ""
global ITEMS = ""
global FIRSTITEM = true

try
    global errId = 1
    a = readdir()
    global errId = 2
    for itm in a
        global itmx = itm
        if length(itm) < 6 || findfirst(".html", itm) == nothing
            continue
        end 
        f = open(itm)
        global errId = 4
        res = read(f)
        global errId = 5
        close(f)
        global ctr += 1
        if ctr % 50 == 0
            println(ctr, "  " , round(time() - t, digits=4))
        end        
        txt = String(res)
        ts = findfirst(itm in nonWikis ? dx : d, txt)
        if ts != nothing
            ts2 = txt[ts]
            ts3 = findfirst(r"[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]{1,3})?", ts2)
            ts4 = ts2[ts3][1:10] * "T" * ts2[ts3][12:16]

            global cctr += length(txt)
            if length(ARGS) == 4 && uppercase(ARGS[4]) == "BEFORE" ? ts4 <= ARGS1 : ts4 >= gmt
                global nomatches = false

                vs = findall(r"202[0-9]\.[0-9]{2}\.[0-9]{2} v[0-9\.]+", txt)
                vsl = length(vs)
                vsx = "        <span style=\"font-weight:normal;color:darkblue;\">"
                if vsl == 0
                    vsx *= "[Missing]"
                else
                    vsx *= txt[vs[vsl]]
                    if vsl > 1
                        vsx *= " (" * string(vsl) * ")"
                    end
                end   
                vsx *= "</span>"
 
                global out *= "\n<tr><td style=\"padding:3px;\"><a href=\"WikiBkup\\" * itm * "\">**</a></td><td style=\"padding:3px;\"> " * itm * "</td><td style=\"padding:3px;\">  " * string(replace(ts4, "T" =>
                       "<span style=\"font-weight:normal;\">T</span>", count=1)) * " GMT" * vsx * "</td></tr>"
                global tot += 1
                if FIRSTITEM
                    global FIRSTITEM = false
                else 
                    global ITEMS *= ", "
                end
                global ITEMS *= itm
            end
        else
            global nomatches = false
            global out *= "\n<tr><td style=\"padding:3px;\"><a href=\"WikiBkup\\" * itm * "\">**</a></td><td style=\"padding:3px;\"> GKW</td><td style=\"padding:3px;\">  GKW: \"" * itm * "\"</td></tr>"
        end
    end
catch ex
    s = string(ex)  
    if length(s) > 200
        s = s[1:200] * "..."
    end
    println("\n      Failure[" * itmx * " " * string(errId) * "]: ", typeof(ex), ".\n", s);
    exit(16)
end
if nomatches
    global out *= "\n<tr><td colspan=3>(No matches)</td></tr>"
end
global out *= "\n<tr><td colspan=3><p style=\"width:100%;text-align:right;padding-top:5px;\"><span style=\"font-weight:normal;border:1px solid black;padding:0px 4px 0px 3px;background-color:white;font-size:larger;\">Σ " * 
                string(tot) * "</span></p></td></tr></table></div></body></html>"

stotlen = string(cctr)
if cctr> 999
    stotlen = stotlen[1:length(stotlen) - 3] * "," *
            stotlen[length(stotlen) - 2 : length(stotlen)]
end
if cctr > 999999
    stotlen = stotlen[1:length(stotlen) - 7] * "," * 
            stotlen[length(stotlen) - 6 : length(stotlen)]
end

nw = string(now())
nw = nw[1:16]
pre = "<html><head></head><body><div style=\"margin:40px 0px 30px 80px;\"><p style=\"line-height:150%;font-family:sans-serif;font-weight:bold\">" 
pre *= OUTPUTFILE * "   <span style=\"color:mediumblue;border:2px solid darkblue;padding:2px 6px 1px 6px;background-color:yellow;\">" * replace(ARGS1, "T" => "<span style=\"font-weight:normal;color:black;\">T</span>", count=1) * " ·&nbsp<span style=\"font-weight:normal;color:black;\">" * ARGS[2] * " " * ARGS[3]
pre *= "</span></span>" * "   ⇒  " * 
            replace(gmt, "T" => "<span style=\"font-weight:normal;\">T</span>", count=1) * 
            " <span style=\"font-weight:normal;\">GMT</span><br>Files: " * string(ctr) * 
            ".  Chars: " * stotlen * ".  Time: " * string(round(time() - t, digits=4)) * 
            ".  v" *  version * ".<br>Now: <span style=\"font-weight:normal;\">" * nw * "</span></p>"
pre *= "<table style=\"border-collapse:separate;font-family:sans-serif;font-weight:bold;background-color:lightyellow;padding:20px;\"><tr><td colspan=3><p style=\"width:100%;text-align:right;padding-bottom:3px;\"><span style=\"font-weight:normal;border:1px solid black;padding:0px 4px 0px 3px;background-color:white;font-size:larger;\">Σ " * 
                string(tot) * "</span></p></td></tr>"

z = open(OUTPUTFILE, "w")
write(z, pre * out)         # * "\n" * "\"" * ITEMS * "\"")
close(z)


Return to TOC!Return to TOC

Julia script to compare local and DreamHost ".html" files (WBDH)

#using Pkg; Pkg.add("HTTP")
using Dates
using HTTP
APFS = "001" # WBDH:APFS
version = APFS

global Audit = false

function testOne(fileName)
    try
        fn = "http://www.bmccedd.org/" * fileName * ".html"
        res = HTTP.get(fn);
        zb = copy(res.body)
        global txt = String(zb) # Never had I seen a function that destroys its input parameter. Cui bono?  
        a = open(fileName * ".html", "r")
        ltxt = String(read(a))
        close(a)

        rx = Regex("</div>[ \r\n]{1,4}</div><div class=\"read600\"><br style=\"clear:both;\"><img src=\"../w/images/5/52/Spacer.gif\" alt=\"[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{3})?. ~[0-9,]+\" width=\"2\" height=\"2\" /></div></body></html>")
        if txt == ltxt
            #println("Files match for: \"" * fileName * "\". Length: " * string(length(txt)) * ".")
        else
            z = length(txt)
            zl = length(ltxt)
            txt = replace(txt, rx => "*GKW*",count=1)
            ltxt = replace(ltxt, rx => "*GKW*",count=1)
            if txt == ltxt
                #println("Files SIMILAR for: \"" * fileName * "\". Length: " * string(z) * ".")
            else 
                println("    MISMATCH for: \"" * fileName * "\". Lengths: " * string(z) * " / " *
                    string(zl) * " (" * string(zl - z) * ")")
                if !Audit
                    return
                end
                v = open("DHR_" * fileName, "w")
                write(v, txt)
                close(v)
                v = open("DHL_" * fileName, "w")
                write(v, ltxt)
                close(v)
            end
        end
    catch ex
        s = string(ex)  
        if length(s) > 200
            s = s[1:200] * "..."
        end
        println("\n      Failure: ", typeof(ex), ".\n", s);
    end
end

global a = readdir()
global aa = length(a)
global ct = 0
global xct = 0
global rejects = []
for q = 1 : aa
    f = a[q]
    lf = length(f)
    if lf < 6 || f[lf- 4 : lf] != ".html"
        global xct += 1
        push!(rejects, f)
        continue
    end 
    you = f[1 : lf - 5]
    testOne(you)
    global ct += 1
end
println("\n\".html\" Files processed: " * string(ct) * ".  Rejects: " * string(xct) * ".  v" * version * "\n\n" * string(rejects))
   

Return to TOC!Return to TOC

Julia script to compare local and remote images (WBcompare)

using HTTP

APFS = "006" # WBcompare:APFS
version = APFS

global big = 180000
global BIGS = []
global t = time();

if length(ARGS) < 1
    println("Argument must be \"BmccEdd\" or \"APtS\"")
    exit(16)
end
if uppercase(ARGS[1]) == "BMCCEDD" 
    global URLroot = "https://www.bmccedd.org./w/images/"
elseif uppercase(ARGS[1]) == "APTS"
    global URLroot = "https://www.aplacetostudy.com./w/images/"
else
    println("ARGS[1] unrecognized value: \"" * ARGS[1] * "\"")
    exit(16)
end
println("Remote: " * URLroot * "\n")

global tbl = Array{String}(undef, 1000)
global sz = 0
global totlen = 0

function getImage(img)
    global errId = 0
    try
        global errId = 1
        a = HTTP.get(URLroot * img)
        global errId = 2
        ab = a.body
        global errId = 3
        f = open("./images/" * img)
        global errId = 4
        fb = read(f)
        global errId = 5
        close(f)
        global errId = 6
        return([ab, fb])
    catch ex
        s = string(ex)  
        if length(s) > 200
            s = s[1:200] * "..."
        end
        println("\n      Failure[" * string(errId) * "]: ", typeof(ex), ".\n", s);
        #exit(16)
        return nothing
    end
end

global others = []

for (root, dirs, files) in walkdir(".")
    for file in files
        x = joinpath(root, file) # path to files
        if !contains(x, "images")
            push!(others,x)
            continue
        end
        global sz += 1
        tbl[sz] = replace(x[10:length(x)], "\\" => "/")

    end
end
println(" ")
for i = 1 : sz
    tbli = tbl[i]
    sleep(1)
    if i % 50 == 0
        println("---- Processed " * string(i) * " files ---- ",
                        round(time() - t, digits=4))
    end
    x = getImage(tbli)
    if x == nothing
        continue
    end
    lenx1 = length(x[1])
    lenx2 = length(x[2])
    global totlen += lenx1
    if lenx1 != lenx2 || x[1] != x[2]
        println("    Bad: " * 
            string(i) * ". " * tbli[1:5] * " " * 
            tbli[6:length(tbli)] * " " * string(lenx1) * 
            " " * string(lenx2) )
    end
    bigger = max(lenx1, lenx2)
    if bigger >= big
        push!(BIGS, string(bigger) * ":" * tbli)
    end
end

stotlen = string(totlen)
if totlen > 999
    stotlen = stotlen[1:length(stotlen) - 3] * "," *
            stotlen[length(stotlen) - 2 : length(stotlen)]
end
if totlen > 999999
    stotlen = stotlen[1:length(stotlen) - 7] * "," * 
            stotlen[length(stotlen) - 6 : length(stotlen)]
end 

println("\n" * string(sz) * " files in directories. " * 
            stotlen * " total length. v" * version * "  ",
            round(time() - t, digits=4))

println("--------\n", sort(BIGS, rev=true), "--------\n", others)

Return to TOC!Return to TOC

CharCount

C:\bradstuff\assets\Robbie>julia CharCount  metaphysics.mb.txt 100000
      metaphysics.mb.txt (484784).  +2021.01.19 v03.00

      A   7.708588     N   7.542534         A    7709     N    7543
      B   2.013061     O   7.075935         B    2013     O    7076
      C   2.879014     P   1.556776         C    2879     P    1557
      D   2.841059     Q   0.165641         D    2841     Q     166
      E  13.101505     R   5.267294         E   13102     R    5267
      F   2.599096     S   7.545629         F    2599     S    7546
      G   1.671054     T  10.792229         G    1671     T   10792
      H   6.426986     U   2.514522         H    6427     U    2515
      I   8.108766     V   0.78076          I    8109     V     781
      J   0.091381     W   1.661358         J      91     W    1661
      K   0.328806     X   0.201327         K     329     X     201
      L   3.249488     Y   1.378758         L    3249     Y    1379
      M   2.461096     Z   0.037336         M    2461     Z      37

                                                      Total: 100001

global arry = zeros(UInt64,26);    # Note that the file output of this script can be input to  
global totl = 0                               # MakeSense script to tailor letter distribution table

if (length(ARGS)) < 1
    println("\n         NO FILENAME")
    exit()
end
if (length(ARGS)) < 2
    println("\n         NO DISTRIBUTION NUMBER")
    exit()
end
a = UInt8('a')
A = UInt8('A')
z = UInt8('z')
Z = UInt8('Z')
atSign = A - 1

try
    global s = open(ARGS[1])
    t = read(s)
    for ch in t
        if ch >= A && ch <= Z 
            global arry[ch - A + 1] += 1
        elseif ch >= a && ch <= z 
            global arry[ch - a + 1] += 1
        else
            continue
        end
        global totl += 1
    end
catch ex
    println("\n         Exception: ", ex)
    exit(16)
end

totf = Float64(totl)
dstf = parse(Float64, ARGS[2])
lARGS2 = length(ARGS[2]) + 2
println("      ", ARGS[1]," (", totl, ").  +2021.03.08 v04.01\n")
global tc = UInt64(0)
global f1 = ""
global f13 = ""

for i = 1: 13
    pct1 = Float64(arry[i]) / totf
    pct13 = Float64(arry[i + 13]) / totf
    v1 = pct1 * 100.0
    v13 = pct13 * 100.0
    x1 = string(Char(atSign + i)) * (v1 >= 10.00 ? "  " : "   ") * string(round(v1, digits=6)) 
    x13 = string(Char(atSign + i +  13)) * (v13 >= 10.00 ? "  " : "   ") * string(round(v13, digits=6))

    r1 = round(dstf * pct1)
    r13 = round(dstf * pct13)
    global tc += (UInt64(r1) + UInt64(r13))

    t1 = string(UInt64(r1))
    t13 = string(UInt64(r13))
    global f1 *= t1 * "\n"
    global f13 *= t13 * "\n"

    tt1 = string(Char(atSign + i)) * " " ^ (lARGS2 - length(t1)) * t1
    tt13 = string(Char(atSign + i + 13)) * " " ^ (lARGS2 - length(t13)) * t13

    prt1 = "      " * x1 * (" " ^ (17 - length(x1))) *  x13

    global prt2 = prt1 * (" " ^ (44 - length(prt1))) * tt1 * "     " * tt13

    println(prt2)
end

global wro = ""
if length(ARGS) > 2
    if lowercase(ARGS[3]) != "charcount"
            try
                f = open(ARGS[3], "w")
                write(f, f1 * f13)
                close(f)
                global wro =  "Wrote file: " * ARGS[3] * "."
            catch ex
                println("\n      File write failed: " , ex)
                global wro = "File error: " * ARGS[3]
            end
    else
        global wro = "Can\'t overwrite CharCounts."
    end
end

totp = wro * " Total: " *string(tc)
println("\n", " " ^ (length(prt2) - length(totp)) , totp)
    

Return to TOC!Return to TOC

Julia script to print a file's contents in hexadecimal

function myPrint(fn, offshit::Int64=0, maxShit::Int64=9999999)  
    offset = Int(floor(offshit / 16)) * 16
    maxLen = Int(floor((maxShit + 15) / 16)) * 16
    if (length(fn)) < 1
        return("\n         NO ARGUMENT\n\n")
    end
    notGood = false
    hexChars = "0123456789ABCDEF"
    everything = ""
    everyin = ""
    
    try
        global s = open(fn)
        t = read(s)
        rlim = lent = length(t)
        if offset < 0
            offset = Int(floor((rlim + offset) / 16)) * 16
        end
        taboo = offset + maxLen
        if rlim > taboo
            rlim = taboo
        end
        for i = 1:rlim                                     # length(t)
            r = hexChars[1 + (Int(floor(t[i] % 16)))]    
            q = hexChars[1 + (Int(floor(t[i] / 16)))]    
            everything *= string(q,r, " ")
            if t[i] < 32 || t[i] > 127 
                everyin *= "." 
            else
                everyin *= string(Char(t[i])) 
            end
        end
        hx = string(offset, base = 16)
        println("\n         HexPrint v03.03 +2021.10.23" * "\n         " * fn *
                " (" * string(lent) * ": " * string(offset) * " ~ " * string(rlim) * ", 0x" * hx * ")\n")
        rl = 0
        shit = Int(floor(length(everyin) % 16))
        if shit > 0
            shit = 16 - shit 
            everyin *= "                                               "[1:shit]
            everything *= "                                               "[1:( 3 * shit)]
        end
        rl = offset    #    tryparse(Int64,offset) 
        while rl < rlim 
            stain = "        " * string(string(rl, base = 16))
            #staiX = "        " * string(rl)
            stain = stain[(length(stain) - 5):length(stain)]
            #staiX = staiX[(length(staiX) - 5):length(staiX)]
            println(stain * "   " * everything[(3 * rl + 1):(3 * rl + 23)] *
                     " " * everything[(3 * rl + 24):(3 * rl + 48)] *
                     "    " * everyin[(rl + 1):(rl + 16)]  * "   " * string(rl))
            rl += 16
        end
    catch ex
        println("Exception: ", ex)
        notGood = true
    finally
        if notGood == false
            close(s)
            print("\n         CLOSED: ")
        else
            print("\n         NOTGOOD: ")
        end
        println(fn) #  * "\n")
    end
end

p1 = "shit"
p2 = 0
p3 = 99999999
if length(ARGS) > 2
    p1 = ARGS[1]                    # filename
    p2 = tryparse(Int64, ARGS[2])   # offset
    p3 = tryparse(Int64, ARGS[3])   # length
elseif length(ARGS) > 1
    p1 = ARGS[1]
    p2 = tryparse(Int64, ARGS[2])
elseif length(ARGS) == 1
    p1 = ARGS[1]
end
myPrint(p1,p2,p3)

Return to TOC!Return to TOC

Julia script to print Ascii character set (Ascii)

global versionNr = "06"
global nr = 1
global clr = 30
global defaultClr = Sys.iswindows() ? "33" : "31"
global lenArgs = length(ARGS)
rng = lenArgs > 0 && lowercase(ARGS[1]) == "extended" ? [160 : 175] : [32 : 47]
println(" ") 

for i =  rng[1] 
    for j = 0 : 5
        k = i + j * 16
        print("     ", 
                k == 127 ? "[" : "\033[" * (lenArgs > 0 && lowercase(ARGS[1]) != "extended" ? ARGS[1] : defaultClr) * ";1m" * Char(k) * "\033[0m", 
                k < 100 ? "  " : k == 127 ? "v" : " " , 
                k == 127 ? versionNr * "]" : string(k))                 # for 127 show version number!
    end
    if lenArgs > 0 && lowercase(ARGS[1]) != "extended" 
        print("          \033[" * string(clr) * ";1m|" * string(clr) * "|\033[0m")
    end
    print("\n")
    if clr == 37
         global clr = 90
    else
         global clr += 1
    end
    global nr += 1
end

Return to TOC!Return to TOC

Julia programming language String builtin function problem

I do not understand why the String function modifies: no, even worse: destroys, its input parameter.



Another julia problem?

julia> a
"ssssst\\ddd"

julia> findfirst(r"[t]\\d",a)
6:8

julia> findfirst(r"[t][\\]",a)
6:7

julia> findfirst(r"[t]\\",a)
ERROR: LoadError: PCRE compilation error: \ at end of pattern at offset 4
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:33
 [2] compile(pattern::String, options::UInt32)
   @ Base.PCRE .\pcre.jl:128
 [3] compile(regex::Regex)
   @ Base .\regex.jl:79
 [4] Regex(pattern::String, compile_options::UInt32, match_options::UInt32)
   @ Base .\regex.jl:44
 [5] Regex(pattern::String)
   @ Base .\regex.jl:67
 [6] var"@r_str"(__source__::LineNumberNode, __module__::Module, pattern::Any, flags::Vararg{Any, N} where N)
   @ Base .\regex.jl:116
in expression starting at REPL[18]:1

julia>



+2022.01.17 v011
Prev2a.gifReturn to Table of contents
Prev2a.gifReturn to Lists


 

Footnotes

  1. Curse words due to the PTSD rage trying to do just about anything with a computer causes me (BMcC[18-11-46-503]). After my last years of computer programming work, I just want demand computers to obey me and not give me any problems, but that's not the way computer stuff generally works. Wiki is obtuse.


BMcC signature seal stamp. Modelled on 18th century messenger's letter box in collection of Suntory Museum, Tokyo. Japanese write poems and prayers on slips of paper which they tie into knots like this shape although with longer legs. Prayers are often tied to branches of trees which can look like they are covered with snow. "Symbol of a symbol, image of an image, emerging from the destiny that is sinking into darkness...." (H. Broch, "The Sleepwalkers", p.648) Always remember. Add value. (This image created not later than 21 May 2003)Invenit et fecit


This page has been validated as HTML 5. It is valid when removed from the Wiki environment and massaged to stand alone.

2022-01-19 21:01:33. ~111,251