postgresql – Should I drop a btree index on a column after adding a unique constraint?

On one of my existing tables I have a btree index. I am now adding a unique constraint to this column. I know behind the scenes it will add a UNIQUE btree index to this column as well.

In this scenario, should I drop the original btree index added to the column to prevent redundant indexes?

Thanks! :]

Possibility of adding meta description to harvester engine settings ?


i have a new question. 

Is it possible to use the “Aditional header / settings”  optin in the harvester setitngs to also grab meta description/ or meta title  when harvesting urls?

And can i display it (the description) in the main window?

Why –  in my experience it is MUCH easier to understand if a site is or is not relevant from URL AND meta description than from just url alone.
so, its way faster to filter out bad results.


How do I prevent WordPress from adding a "-1" suffix to some uploaded images?

Some images that I upload to the Media Library end up with a "-1" suffix added to the file name. For example camping.jpg is renamed by WP to camping-1.jpg

  • I am using WordPress 5.6.2
  • The affected images are not already present in the Library
  • This seems to affect images around 1500px wide; smaller images are not affected
  • No resizing occurs at any time
  • No image-affecting plugins installed (shortcodes-ultimate, classic-editor)
  • Using a child theme based on the Underboot theme

Any help would be greatly appreciated. Thanks!

rendering – Adding lighting to custom vertex shader in Unity

What’s the simplest way to add shadow functionality based on the modified vertices, nothing I’ve found online seems to work

 Shader "Unlit/HyperUnlit"
         _MainTex ("Texture", 2D) = "white" {}
         _Color("Color", Color) = (1,1,1,1)
         Tags { "RenderType"="Opaque" }
         LOD 100
             #pragma vertex vert
             #pragma fragment frag
             #include "UnityCG.cginc"
             #include "Complex.cginc"
             struct appdata
                 float4 vertex : POSITION;
                 float2 uv : TEXCOORD0;
             struct v2f
                 float2 uv : TEXCOORD0;
                 float4 vertex : SV_POSITION;
             sampler2D _MainTex;
             float4 _MainTex_ST;
             fixed4 _Color;
             float Tscale;
             float3 Tpos;
             float klein;
             float Rscale;
             //Mobius Transformation (a,b,c,d)
             float2 a;
             float2 b;
             float2 c;
             float2 d;
             v2f vert (appdata v)
                 v2f o;
                 //Reduce to float3
                 float3 worldPos = mul(unity_ObjectToWorld, float4(, 1)).xyz;
                 //2. Apply linear transformations
                 worldPos *= Tscale;
                 worldPos += Tpos;
                 //3. Apply mobius transformation    
                 worldPos = MobiusXZ(a,b,c,d, worldPos);
                 //4. Klein?
                 if (klein==1)
                     worldPos = PoincareToKlein(worldPos);
                 //5. Scale to disk radius
                 worldPos *= Rscale;
                 //Convert back to ? space
                 o.vertex = mul(UNITY_MATRIX_VP, float4(worldPos, 1));
                 //transform position to clip space
                 //o.vertex = UnityObjectToClipPos(v.vertex);
                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                 return o;
             fixed4 frag (v2f i) : SV_Target
                 // sample the texture
                 fixed4 col = tex2D(_MainTex, i.uv) * _Color;
                 return col;
         UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"

performance – Copy a block of data into existing cells, adding a new line

Wondering about efficiency here – I have a bit of code that does what I want; but it is terribly slow. I structured the code in a way that made sense to me logically, but I’m wondering if someone else could take a look at the code and find a shortcut or two that might make it faster. I’m guessing that I am referencing the Worksheet too often in one of the loops, but haven’t been able to find a good way to restructure to improve performance.

Option Explicit

Sub addAlternateRevCodeLogic()
Dim WS As Worksheet
Dim rng As Range
Dim lastColumn As Long
Dim row As Long
Dim i As Long

Dim ReferenceStyle As XlReferenceStyle

'Arrays of the different Alt Rev Code fields on an EAP
Dim AltID() As String
Dim EffFrom() As String
Dim EffTo() As String
Dim ProvType() As String
Dim BCC() As String
Dim DEP() As String
Dim EAF() As String
Dim Class() As String
Dim RevCode() As String

'Alt Rev Code data from the matching rows
Dim rowAltID As String
Dim rowEffFrom As String
Dim rowEffTo As String
Dim rowProvType As String
Dim rowBCC As String
Dim rowDEP As String
Dim rowEAF As String
Dim rowClass As String
Dim rowRevCode As String

'New and old cost centers
Dim newBCC() As String
Dim oldBCC As String
Dim CostCenter As Variant
Dim userInput As String

'Columns for Rev Code Ranges
Dim AltIDcol As Long 'I EAP 2431
Dim EffFromcol As Long 'I EAP 2434
Dim EffTocol As Long 'I EAP 2435
Dim ProvTypecol As Long 'I EAP 2439
Dim BCCcol As Long 'I EAP 2438
Dim DEPcol As Long 'I EAP 2437
Dim EAFcol As Long 'I EAP 2436
Dim Classcol As Long 'I EAP 2432
Dim RevCodecol As Long 'I EAP 2433

Application.ScreenUpdating = False
ReferenceStyle = Application.ReferenceStyle
If ReferenceStyle = xlR1C1 Then Application.ReferenceStyle = xlA1 'There are certain assumptions in the ranges that don't play nicely with R1C1

'Data is Chr(10) delimited
'Define the range of the EAP Export
Set WS = Worksheets("export")
lastColumn = eap.Cells.Find("*", After:=eap.Cells(1), LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
Set rng = WS.Range("A1", WS.Columns(1).Find(what:="#LAST_ROW", LookIn:=xlComments, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Offset(0, lastColumn))

'Define all of the column IDs
AltIDcol = FindCol(2431, eap, True, 1, 1, 1, lastColumn)
EffFromcol = FindCol(2434, eap, True, 1, 1, 1, lastColumn)
EffTocol = FindCol(2435, eap, True, 1, 1, 1, lastColumn)
ProvTypecol = FindCol(2439, eap, True, 1, 1, 1, lastColumn)
BCCcol = FindCol(2438, eap, True, 1, 1, 1, lastColumn)
DEPcol = FindCol(2437, eap, True, 1, 1, 1, lastColumn)
EAFcol = FindCol(2436, eap, True, 1, 1, 1, lastColumn)
Classcol = FindCol(2432, eap, True, 1, 1, 1, lastColumn)
RevCodecol = FindCol(2433, eap, True, 1, 1, 1, lastColumn)

oldBCC = InputBox("What cost center do you want to copy?" & vbNewLine & "Select only one, and don't make typos")
If oldBCC = "" Then MsgBox "Must choose a cost center!", vbOKOnly + vbCritical: Exit Sub

    userInput = InputBox("What are the new cost centers that need added?" & vbNewLine & "You can enter multiple, just keep adding them and then leave the box blank after the last one" & vbNewLine & "Don't make typos", "New Cost Centers")
    Select Case True
        Case CostCenter = "" And userInput <> "" 'Handle the 1st cost center
            CostCenter = userInput
        Case CostCenter <> "" And userInput <> "" 'Handle each new input
            CostCenter = CostCenter & "," & userInput
        Case CostCenter = "" And userInput = "" 'Handle no input
            MsgBox "Must choose at least one new cost center!", vbOKOnly + vbCritical: Exit Sub
    End Select
Loop While userInput <> ""

'oldBCC = "10005320" 'Test Emergency Cost Center
'oldBCC = "10004320" 'Test Pediatrics Cost Center
'CostCenter = "70005320" 'Test New Emergency Cost Center
'CostCenter = "70004110,70004130,70004140,70004200,70004420,70004510,70004400,70004430,70004500" 'Test New Pediatrics Cost Centers
newBCC() = Split(CostCenter, ",")

With rng
    For row = LBound(.Value2) To UBound(.Value2) 'Loop through each row from the export
    If Not IsEmpty(.Value2(row, RevCodecol)) Then 'Find any row that contains an alternate revenue code
        If InStr(1, .Value2(row, BCCcol), oldBCC) Then 'Check if the TRH Emergency Cost Center is using one of the alternate revenue codes
            'Build an array for each Alt Rev Code data item
            RevCode() = Split(.Value2(row, RevCodecol), Chr(10))
            AltID() = Split(.Value2(row, AltIDcol), Chr(10))
            EffFrom() = Split(.Value2(row, EffFromcol), Chr(10))
            EffTo() = Split(.Value2(row, EffTocol), Chr(10))
            ProvType() = Split(.Value2(row, ProvTypecol), Chr(10))
            BCC() = Split(.Value2(row, BCCcol), Chr(10))
            DEP() = Split(.Value2(row, DEPcol), Chr(10))
            EAF() = Split(.Value2(row, EAFcol), Chr(10))
            Class() = Split(.Value2(row, Classcol), Chr(10))
            For i = LBound(RevCode()) To UBound(RevCode())
                If InStr(1, BCC(i), oldBCC) Then 'Set row data for a line with the cost center to copy
                    rowAltID = AltID(i)
                    rowEffFrom = EffFrom(i)
                    rowEffTo = EffTo(i)
                    rowProvType = ProvType(i)
                    rowBCC = BCC(i)
                    rowDEP = DEP(i)
                    rowEAF = EAF(i)
                    rowClass = Class(i)
                    rowRevCode = RevCode(i)
                    'Copy the existing value and add the new line(s)
                    For Each CostCenter In newBCC 'Copy existing lines and add a new entry for each new cost center
                        .Cells(row, AltIDcol).Value = .Value2(row, AltIDcol) & Chr(10) & rowAltID ' & Chr(10)
                        .Cells(row, EffFromcol).Value = .Value2(row, EffFromcol) & Chr(10) & rowEffFrom ' & Chr(10)
                        .Cells(row, EffTocol).Value = .Value2(row, EffTocol) & Chr(10) & rowEffTo ' & Chr(10)
                        .Cells(row, ProvTypecol).Value = .Value2(row, ProvTypecol) & Chr(10) & rowProvType ' & Chr(10)
                        .Cells(row, BCCcol).Value = .Value2(row, BCCcol) & Chr(10) & CostCenter ' & Chr(10)
                        .Cells(row, DEPcol).Value = .Value2(row, DEPcol) & Chr(10) & rowDEP ' & Chr(10)
                        .Cells(row, EAFcol).Value = .Value2(row, EAFcol) & Chr(10) & rowEAF ' & Chr(10)
                        .Cells(row, Classcol).Value = .Value2(row, Classcol) & Chr(10) & rowClass ' & Chr(10)
                        .Cells(row, RevCodecol).Value = .Value2(row, RevCodecol) & Chr(10) & rowRevCode ' & Chr(10)
                    Next CostCenter
                End If
            Next i
        End If
    End If
    Next row
End With
If ReferenceStyle = xlR1C1 Then Application.ReferenceStyle = xlR1C1
Application.ScreenUpdating = True
MsgBox "Rev Codes updated. Test the import.", vbInformation + vbOKOnly
End Sub

javascript – Adding a 404 fallback for picture Tags in Angular

We are making heavy use of the HTML5-picture Tag in our Angular 9 Application. We now want to show a fallback image, when the actual src returns 404.

I created a directive that replaces the img src like this answer suggests:

  selector: '(fallbackSrc)',
export class FallbackImageDirective {
    @Attribute('fallbackSrc') public fallbackSrc: string,
    private renderer: Renderer2,
    private el: ElementRef
  ) {}

  @HostListener('error') onError() {
    this.renderer.setAttribute(this.el.nativeElement, 'src', this.fallbackSrc);

to work in picture tags:


However, when I open the application, the request to the wepP-Image is made over and over again. I suspect that the browser notices the change in <img src= and starts evaluating the <source> tags again, then fails and onError() is called again, resulting in an infinite loop.

Is there anything I can do to stop the browser from evaluating the source Tags again?

8 – Adding an icon in a form item element

I have a form where we are displaying a static text like:

Please select the <icon> button to view X

Where the icon is a an image. I’ve added this piece to the form by doing the following:

$form['message'] = [
  '#type' => 'item',
  '#markup' => '$message'

However, when $message contains the icon like Please select the <img src=....> button to view X, the image tag appears instead of the image. I can’t do separate items because the text is translated, so how can I insert an image in the middle of a sentence like this?