u/dog_fister

Macro - Make lists "Restart numbering" after every heading

For posterity - I know others before me have searched in vain for such a solution.

Sub RestartAfterAnyHeading()
    Dim doc As Object, text As Object, paragraphs As Object
    Dim para As Object, styleName As String
    Dim restartNext As Boolean
    
    doc = ThisComponent
    text = doc.Text
    paragraphs = text.createEnumeration()
    restartNext = False
    
    While paragraphs.hasMoreElements()
        para = paragraphs.nextElement()
        styleName = para.ParaStyleName
        
        ' Check if the paragraph uses a heading style (starts with "Heading")
        If Left(styleName, 7) = "Heading" Then
            restartNext = True   ' Mark that next list should restart
        Else
            ' Not a heading – check if it's a list item
            On Error Resume Next
            Dim numberingLevel As Integer
            numberingLevel = para.NumberingLevel
            If Err.Number = 0 Then   ' It is a list paragraph
                If numberingLevel = 0 And restartNext Then
                    ' This is the first item of a list after a heading
                    para.NumberingStartValue = 1
                    restartNext = False   ' Only restart once
                End If
            End If
            On Error GoTo 0
        End If
    Wend
    
    MsgBox "Numbering restarted after every heading."
End Sub
reddit.com
u/dog_fister — 1 day ago

Macro - How to easily delete all "Converted##" Custom styles from .docx files imported into Writer

I regularly need to import and modify large .docx files. Doing this deletion manually would be insane. Existing macros didn't work at all. Here's a macro which does:

Sub DeleteConvertedStyles()
    ' Deletes any custom style whose name starts with "Converted" followed by digits
    Dim oDoc As Object, oFamilies As Object, aFamilyNames As Variant
    Dim i As Integer, j As Integer, oFamily As Object, aStyleNames As Variant
    Dim sStyleName As String, oStyle As Object, nDeleted As Integer, nTotal As Integer
    Dim sMsg As String
    
    oDoc = ThisComponent
    oFamilies = oDoc.StyleFamilies
    aFamilyNames = oFamilies.getElementNames()
    
    If MsgBox("Delete all custom styles named 'Converted##' ?", 4, "Delete Converted Styles") = 7 Then Exit Sub
    
    For i = 0 To UBound(aFamilyNames)
        oFamily = oFamilies.getByName(aFamilyNames(i))
        aStyleNames = oFamily.getElementNames()
        nDeleted = 0
        For j = 0 To UBound(aStyleNames)
            sStyleName = aStyleNames(j)
            ' Match "Converted" followed only by digits (e.g. Converted1, Converted42)
            If Left(sStyleName, 9) = "Converted" Then
                Dim sRest As String
                sRest = Mid(sStyleName, 10)
                If IsNumeric(sRest) Then
                    oStyle = oFamily.getByName(sStyleName)
                    If oStyle.isUserDefined Then
                        On Error Resume Next
                        oFamily.removeByName(sStyleName)
                        If Err.Number = 0 Then
                            nDeleted = nDeleted + 1
                        Else
                            MsgBox "Style '" & sStyleName & "' is in use – cannot delete."
                        End If
                        On Error GoTo 0
                    End If
                End If
            End If
        Next j
        If nDeleted > 0 Then
            sMsg = sMsg & "Deleted " & nDeleted & " from " & aFamilyNames(i) & vbCrLf
        End If
        nTotal = nTotal + nDeleted
    Next i
    
    If nTotal > 0 Then
        MsgBox "Deleted " & nTotal & " styles named 'Converted##'." & vbCrLf & sMsg
    Else
        MsgBox "No matching styles found."
    End If
End Sub

All Power to the Brotherly Chinese Communist Chatbot (which generated this code)

reddit.com
u/dog_fister — 2 days ago
▲ 424 r/redscarepod+1 crossposts

It's expected to consume 7.5-9 gigawatts of electricity per year, which is more than twice the yearly energy expenditure of the entire state. When completed, it will be the largest datacenter in the world.

The project was fasttracked through MIDA, which basically means the developers didn't have to do any environmental impact studies whatsoever. The Salt Lake Valley already has some of the worst air pollution in the country and the project will add an extra 50% emissions yearly (I can't even fathom how bad this would look. We have weeklong stretches during the winter where it looks like fucking Blade Runner 2049 outside all day). The site is located directly north of the Great Salt Lake, which has been slowly shrinking for decades and releasing toxic clouds of arsenic dust into the air because of Utah's horrible water management. Kevin O'Leary, the charlatan that he is, claims that the project won't affect the water supply or energy rates (no evidence for this obviously).

Idk man, you hear about this stuff all the time but it really hits harder when it happens close to home. I am so sick and tired of our country being raped by financial interests for a technology that objectively makes the world a worse place to live in by every metric. I just can't fathom the incentive structure we have built for ourselves where stuff like this is getting fasttracked through government without any regulations or taxes while the cost of living steadily increases and ordinary people are locked out of homeownership.

And for what? So we can live in a post-truth, post-literate society? So that Palantir can harvest and sell my data more effectively? So all art and culture can be subsumed into the satanic technocapital regurgitation machine? So that we can reduce a vast majority of the workforce to the status of cattle? I mean, really, can you imagine what could be achieved if these funds were instead redirected to build affordable housing for young families?

Sad state of affairs all around. Fuck dude. I hate rich people. I hate businessmen and smarmy governers. Kevin O Leary is the worst guy alive. Sorry for the long rant but I hate this gay ass state

reddit.com
u/Love_Takes_Miles_ — 16 days ago
▲ 2 r/docker

I'm running this container on Windows Machine A, and am trying to access it over LAN/Tailscale from Windows Machine B.

Should I change something in the compose file?

Should I bridge something afterwards? I can't make sense of this answer.

I've tried to open Machine B's firewall for the port, but it's not letting me remotely connect to Machine A from 0.0.0.0:7788, or 127.0.0.1:7788, 100.x.x.x:7788, or 192.168.x.x:7788.


 networks:
   default:
     name: stacks

 services:
   stacks:
     image: zelest/stacks:latest
     container_name: stacks
     ports:
       - "7788:7788"
(...)
       - SOLVERR_URL=flaresolverr:8191
(...)
   flaresolverr:
       image: ghcr.io/flaresolverr/flaresolverr:latest
       container_name: flaresolverr
       ports:
         - "8191:8191"
(...)
u/dog_fister — 19 days ago