648

Notes:

  • Answers will occasionally be moved to the Sandbox archive when there are too many of them. When using them to report bugs, keep an eye on the post.

  • You may also want to take a look at the Stack Exchange's Sandbox chat room

  • This site, Meta Stack Exchange, is usually used as a "test bed" for pending changes happening to the way text is rendered on all network sites. Changes to text rendering that are going to be rolled out to the network are usually deployed here first to test them out and fix any potential glitches. Currently, there are no such changes pending, but if there were, keep in mind that text posted here may render differently from the other sites until the changes roll out to them as well.

As per Jeff's suggestion in this comment:

You can use this question as a formatting sandbox. You can:

  • edit this question itself (Community Wiki questions such as this one require only 100 reputation to edit instead of 2,000)
  • post answers to this question (This question might be protected, requiring earning 10 reputation on this site to answer)
  • post comments to this question or its answers
  • test suspected bugs with the editor or the rendering
  • post ponies (only when mods are asleep)

Beware that since the changes to syntax highlighting in December 2010, and the inline hints added in March 2011, no syntax highlighting is applied unless the question's tags or an inline hint enable it. So, to test highlighting here in the sandbox:

  1. As of January 8, 2019, you can use GitHub-flavor fenced code blocks in your posts, specifying the language after the opening fence:

    ```html
    While not hinted otherwise: <html></html> source <b>goes</b> "here".
    ```
    
    ```js
    var a = 3;
    while (not (a > 0)) {
        alert("JavaScript code <b>goes</b> here.");
    }
    ```
    
  2. Or:

    • Create code blocks in any way (using the fence notation above, the four-space indent form, or using HTML <pre><code> tags).

    • Save your post!

    • Use your browser's developer tools to edit the resulting HTML. To open developer tools, press F12, or ⌥⌘ I on Mac.

    • Find the <pre> element and add the attribute class="prettyprint", or change it into one of the valid syntax hints linked above, like class="lang-vb prettyprint".

    • Run the following in the location bar: javascript:prettyPrint(); or prettyPrint() in the console.

Answers that are considered annoying or obnoxious, or that cause breakage for users, will be deleted. This is codified as a policy as of March 29, 2018.

12

303 Answers 303

1

Instead of iterating over all possible integer numbers, let's iterate over all possible sequences
a1n + a2n + a3n + .. + ann = A, where 0 ≤ ai ≤ 9
and checking corresponding sums A for "Armstrongeness".

As sum is commutative (a+b = b+a) we need to iterate only over non-decreasing sequences:
a1n ≤ a2n ≤ a3n ≤ .. ≤ ann

For example, lets find all 3-digit Armstrong numbers:
03 + 03 + 03 = 0
03 + 03 + 13 = 1
03 + 03 + 23 = 8
...
03 + 33 + 63 = 243
03 + 33 + 73 = 370 <-- Armstrong number
03 + 33 + 83 = 539
...
03 + 43 + 63 = 280
03 + 43 + 73 = 407 <-- Armstrong number
03 + 43 + 83 = 576
...
13 + 33 + 43 = 92
13 + 33 + 53 = 153 <-- Armstrong number
13 + 33 + 63 = 244
13 + 33 + 73 = 371 <-- Armstrong number
13 + 33 + 83 = 540
...
93 + 93 + 93 = 2187

There is 900 3-digit numbers, but only 178 possible 3-digit permutations. Does not sound like big deal, however for 900'000'000'000'000'000 18-digit numbers, there is only 4'515'854 permutations.

My written on Java implementation computes all numbers by ~2 sec on my machine:

package org.example;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
  private static int[] digits;
  private static long sumOfPows = 0;
  private static long[] pows;
  private static long min = 0;
  private static long max = 0;
  private static List<Long> result = new ArrayList<>();

  public static void main(String[] args) {
    for (int numOfDigits = 1; numOfDigits <= 19 ; numOfDigits++) {
      search(numOfDigits);
    }

    System.out.println(result);
  }

  private static void search(int numOfDigits) {
    digits = new int[numOfDigits];
    sumOfPows = 0;
    pows = new long[10];
    min = powerN(10, numOfDigits-1);
    max = powerN(10, numOfDigits);
    if (max < 0) { // check for overflow
      max = Long.MAX_VALUE;
    }
    for (int i = 0; i < pows.length; i++) {
      pows[i] = powerN(i, numOfDigits);
    }
    searchRecursively(0, 0);
  }

  // fast power alhorithm, not relevant here
  private static long powerN(int number, int power){
    long res = 1;
    long sq = number;
    while(power > 0){
      if(power % 2 == 1){
        res *= sq;
      }
      sq = sq * sq;
      power /= 2;
    }
    return res;
  }

  private static void searchRecursively(int curI, int minDigit) {
    if (curI == digits.length) {
      if (min <= sumOfPows && sumOfPows < max) {
        int[] digitsSorted = toDigits(sumOfPows, digits.length);
        if (Arrays.equals(digits, digitsSorted)) {
          result.add(sumOfPows); // we found it!
        }
      }
    } else {
      for (int j = minDigit; j <= 9; j++) {
        digits[curI] = j;
        sumOfPows += pows[j];
        if (sumOfPows >= 0 && sumOfPows < max) { // check for overflow
          searchRecursively(curI + 1, j);
        }
        sumOfPows -= pows[j]; // backtracking
      }
    }
  }

  private static int[] toDigits(long num, int len) {
    int[] result = new int[len];
    while(num > 0) {
      result[--len] = (int)(num % 10);
      num /= 10;
    }
    Arrays.sort(result);
    return result;
  }
}
3
  • What are you testing here? Commented Oct 7, 2023 at 9:13
  • @ShadowTheGPTWizard, typical "Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon." Unfortunately I cannot reproduce this on meta.stackexchange.com Commented Oct 8, 2023 at 19:43
  • Yeah this filter isn't active here or even in Meta Stack Overflow. Commented Oct 9, 2023 at 7:16
1

Trying to narrow down a bug. Found a post where the list renders as expected in edit preview, meaning both items have #. bullets, but when posted, they render inconsistently.

I have tried several different methods that give the same result, not suitable for me.

1)

    QMatrix4x4 mat = m_view * m_projection * m_model;
    QVector3D screenPos(p.x(),p.y(),1.0f);
1

This is a domain-relative link. And a tag:

This is the first part of testing what happens when a post contains a domain-relative link and is transcluded.

2
1

SVG flowchart embedded in HTML in Snippet:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"

 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<!-- Generated by graphviz version 9.0.0 (20230911.1827)

 -->

<!-- Title: G Pages: 1 -->

<svg width="531pt" height="456pt" viewBox="0.00 0.00 530.50 455.57" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 451.57)">

<title>G</title>

<polygon fill="white" stroke="none" points="-4,4 -4,-451.57 526.5,-451.57 526.5,4 -4,4"/>

<!-- Enter -->

<g id="node1" class="node">

<title>Enter</title>

<ellipse fill="black" stroke="black" stroke-width="1.2" cx="435.25" cy="-433.43" rx="60.63" ry="14.14"/>

<text text-anchor="start" x="400.38" y="-430.93" font-family="Georgia" font-weight="bold" font-size="10.00" fill="white">Start Process</text>

</g>

<!-- Htsrb -->

<g id="node2" class="node">

<title>Htsrb</title>

<polygon fill="#fff68f" stroke="black" stroke-width="1.2" points="435.25,-396.28 348,-352.28 435.25,-308.28 522.5,-352.28 435.25,-396.28"/>

<text text-anchor="middle" x="435.25" y="-360.78" font-family="Georgia" font-size="10.00">Check</text>

<text text-anchor="middle" x="435.25" y="-348.78" font-family="Georgia" font-size="10.00">Previous Script</text>

<text text-anchor="middle" x="435.25" y="-336.78" font-family="Georgia" font-size="10.00">Execution</text>

</g>

<!-- Enter&#45;&gt;Htsrb -->

<g id="edge1" class="edge">

<title>Enter&#45;&gt;Htsrb</title>

<path fill="none" stroke="black" stroke-width="2" d="M435.25,-419C435.25,-416.16 435.25,-413 435.25,-409.64"/>

<polygon fill="black" stroke="black" stroke-width="2" points="438.75,-409.86 435.25,-399.86 431.75,-409.86 438.75,-409.86"/>

</g>

<!-- Strfep -->

<g id="node9" class="node">

<title>Strfep</title>

<polygon fill="#bbffff" stroke="black" stroke-width="1.2" stroke-dasharray="5,2" points="491.25,-105.28 379.25,-105.28 379.25,-85.28 491.25,-85.28 491.25,-105.28"/>

<text text-anchor="middle" x="435.25" y="-91.78" font-family="Georgia" font-size="10.00">Update Last Position</text>

</g>

<!-- Htsrb&#45;&gt;Strfep -->

<g id="edge12" class="edge">

<title>Htsrb&#45;&gt;Strfep</title>

<path fill="none" stroke="red" stroke-width="2" d="M435.25,-307.81C435.25,-282.1 435.25,-254.78 435.25,-254.78 435.25,-254.78 435.25,-163.13 435.25,-118.78"/>

<polygon fill="red" stroke="red" stroke-width="2" points="438.75,-118.78 435.25,-108.78 431.75,-118.78 438.75,-118.78"/>

<text text-anchor="start" x="438.62" y="-247.23" font-family="Arial" font-weight="bold" font-size="9.00">First</text>

<text text-anchor="start" x="435.25" y="-238.23" font-family="Arial" font-weight="bold" font-size="9.00">Script</text>

<text text-anchor="start" x="439.75" y="-229.23" font-family="Arial" font-weight="bold" font-size="9.00">Run</text>

</g>

<!-- Hfsd -->

<g id="node3" class="node">

<title>Hfsd</title>

<polygon fill="#fff68f" stroke="black" stroke-width="1.2" points="69.25,-285.28 0,-241.28 69.25,-197.28 138.5,-241.28 69.25,-285.28"/>

<text text-anchor="middle" x="69.25" y="-249.78" font-family="Georgia" font-size="10.00">Check</text>

<text text-anchor="middle" x="69.25" y="-237.78" font-family="Georgia" font-size="10.00">for File Size</text>

<text text-anchor="middle" x="69.25" y="-225.78" font-family="Georgia" font-size="10.00">Decrease</text>

</g>

<!-- Hfsi -->

<g id="node4" class="node">

<title>Hfsi</title>

<polygon fill="#fff68f" stroke="black" stroke-width="1.2" points="69.25,-139.28 0,-95.28 69.25,-51.28 138.5,-95.28 69.25,-139.28"/>

<text text-anchor="middle" x="69.25" y="-103.78" font-family="Georgia" font-size="10.00">Check</text>

<text text-anchor="middle" x="69.25" y="-91.78" font-family="Georgia" font-size="10.00">for File Size</text>

<text text-anchor="middle" x="69.25" y="-79.78" font-family="Georgia" font-size="10.00">Increase</text>

</g>

<!-- Hfsd&#45;&gt;Hfsi -->

<g id="edge11" class="edge">

<title>Hfsd&#45;&gt;Hfsi</title>

<path fill="none" stroke="green" stroke-width="2" d="M69.25,-197.08C69.25,-182.98 69.25,-167.12 69.25,-152.23"/>

<polygon fill="green" stroke="green" stroke-width="2" points="72.75,-152.49 69.25,-142.49 65.75,-152.49 72.75,-152.49"/>

<text text-anchor="start" x="89.88" y="-178.73" font-family="Arial" font-weight="bold" font-size="9.00">File</text>

<text text-anchor="start" x="88.75" y="-169.73" font-family="Arial" font-weight="bold" font-size="9.00">Has</text>

<text text-anchor="start" x="89.88" y="-160.73" font-family="Arial" font-weight="bold" font-size="9.00">Not</text>

<text text-anchor="start" x="69.25" y="-151.73" font-family="Arial" font-weight="bold" font-size="9.00"> &#160;&#160;&#160;Decreased</text>

</g>

<!-- MtS -->

<g id="node6" class="node">

<title>MtS</title>

<polygon fill="#bbffff" stroke="black" stroke-width="1.2" points="365.5,-251.28 279,-251.28 279,-231.28 365.5,-231.28 365.5,-251.28"/>

<text text-anchor="middle" x="322.25" y="-237.78" font-family="Georgia" font-size="10.00">Set to File Start</text>

</g>

<!-- Hfsd&#45;&gt;MtS -->

<g id="edge14" class="edge">

<title>Hfsd&#45;&gt;MtS</title>

<path fill="none" stroke="red" stroke-width="2" d="M139.39,-241.28C179.29,-241.28 228.59,-241.28 265.94,-241.28"/>

<polygon fill="red" stroke="red" stroke-width="2" points="265.59,-244.78 275.59,-241.28 265.59,-237.78 265.59,-244.78"/>

<text text-anchor="start" x="167.12" y="-247.98" font-family="Arial" font-weight="bold" font-size="9.00">File Size Decreased</text>

</g>

<!-- MtLP -->

<g id="node7" class="node">

<title>MtLP</title>

<polygon fill="#bbffff" stroke="black" stroke-width="1.2" points="265.25,-117.28 195.25,-117.28 195.25,-73.28 265.25,-73.28 265.25,-117.28"/>

<text text-anchor="middle" x="230.25" y="-103.78" font-family="Georgia" font-size="10.00">Go to</text>

<text text-anchor="middle" x="230.25" y="-91.78" font-family="Georgia" font-size="10.00">Last Known</text>

<text text-anchor="middle" x="230.25" y="-79.78" font-family="Georgia" font-size="10.00">Position</text>

</g>

<!-- Hfsi&#45;&gt;MtLP -->

<g id="edge10" class="edge">

<title>Hfsi&#45;&gt;MtLP</title>

<path fill="none" stroke="green" stroke-width="2" d="M139.4,-95.28C153.76,-95.28 168.57,-95.28 181.96,-95.28"/>

<polygon fill="green" stroke="green" stroke-width="2" points="181.78,-98.78 191.78,-95.28 181.78,-91.78 181.78,-98.78"/>

<text text-anchor="start" x="159.75" y="-117.73" font-family="Arial" font-weight="bold" font-size="9.00">File</text>

<text text-anchor="start" x="157.88" y="-108.73" font-family="Arial" font-weight="bold" font-size="9.00">Size</text>

<text text-anchor="start" x="145.5" y="-99.73" font-family="Arial" font-weight="bold" font-size="9.00">Increased</text>

</g>

<!-- Left -->

<g id="node11" class="node">

<title>Left</title>

</g>

<!-- Hfsi&#45;&gt;Left -->

<g id="edge6" class="edge">

<title>Hfsi&#45;&gt;Left</title>

<path fill="none" stroke="red" stroke-width="2" d="M69.25,-51.01C69.25,-32.53 69.25,-15.14 69.25,-15.14"/>

</g>

<!-- GrvLP -->

<g id="node5" class="node">

<title>GrvLP</title>

<polygon fill="#bbffff" stroke="black" stroke-width="1.2" points="128.25,-362.28 10.25,-362.28 10.25,-342.28 128.25,-342.28 128.25,-362.28"/>

<text text-anchor="middle" x="69.25" y="-348.78" font-family="Georgia" font-size="10.00">Retrieve Last Position</text>

</g>

<!-- GrvLP&#45;&gt;Htsrb -->

<g id="edge9" class="edge">

<title>GrvLP&#45;&gt;Htsrb</title>

<path fill="none" stroke="green" stroke-width="2" d="M141.41,-352.28C200.41,-352.28 284.09,-352.28 347.07,-352.28"/>

<polygon fill="green" stroke="green" stroke-width="2" points="141.49,-348.78 131.49,-352.28 141.49,-355.78 141.49,-348.78"/>

<text text-anchor="start" x="191.25" y="-358.98" font-family="Arial" font-weight="bold" font-size="9.00">Script Has Run Before</text>

</g>

<!-- GrvLP&#45;&gt;Hfsd -->

<g id="edge2" class="edge">

<title>GrvLP&#45;&gt;Hfsd</title>

<path fill="none" stroke="black" stroke-width="2" d="M69.25,-341.99C69.25,-332.06 69.25,-315.47 69.25,-298.64"/>

<polygon fill="black" stroke="black" stroke-width="2" points="72.75,-298.86 69.25,-288.86 65.75,-298.86 72.75,-298.86"/>

</g>

<!-- RtE -->

<g id="node8" class="node">

<title>RtE</title>

<polygon fill="#bbffff" stroke="black" stroke-width="1.2" stroke-dasharray="5,2" points="352,-117.28 292.5,-117.28 292.5,-73.28 352,-73.28 352,-117.28"/>

<text text-anchor="middle" x="322.25" y="-103.78" font-family="Georgia" font-size="10.00">Read</text>

<text text-anchor="middle" x="322.25" y="-91.78" font-family="Georgia" font-size="10.00">New Data</text>

<text text-anchor="middle" x="322.25" y="-79.78" font-family="Georgia" font-size="10.00">to End</text>

</g>

<!-- MtS&#45;&gt;RtE -->

<g id="edge4" class="edge">

<title>MtS&#45;&gt;RtE</title>

<path fill="none" stroke="black" stroke-width="2" d="M322.25,-230.84C322.25,-210.76 322.25,-163.02 322.25,-130.16"/>

<polygon fill="black" stroke="black" stroke-width="2" points="325.75,-130.57 322.25,-120.57 318.75,-130.57 325.75,-130.57"/>

</g>

<!-- MtLP&#45;&gt;RtE -->

<g id="edge3" class="edge">

<title>MtLP&#45;&gt;RtE</title>

<path fill="none" stroke="black" stroke-width="2" d="M265.47,-95.28C270.04,-95.28 274.62,-95.28 279.19,-95.28"/>

<polygon fill="black" stroke="black" stroke-width="2" points="279.06,-98.78 289.06,-95.28 279.06,-91.78 279.06,-98.78"/>

</g>

<!-- RtE&#45;&gt;Strfep -->

<g id="edge5" class="edge">

<title>RtE&#45;&gt;Strfep</title>

<path fill="none" stroke="black" stroke-width="2" d="M352.27,-95.28C356.83,-95.28 361.4,-95.28 365.97,-95.28"/>

<polygon fill="black" stroke="black" stroke-width="2" points="365.82,-98.78 375.82,-95.28 365.82,-91.78 365.82,-98.78"/>

</g>

<!-- Right -->

<g id="node12" class="node">

<title>Right</title>

</g>

<!-- Strfep&#45;&gt;Right -->

<g id="edge7" class="edge">

<title>Strfep&#45;&gt;Right</title>

<path fill="none" stroke="black" stroke-width="2" d="M435.25,-84.89C435.25,-63.93 435.25,-15.14 435.25,-15.14"/>

</g>

<!-- Exit -->

<g id="node10" class="node">

<title>Exit</title>

<ellipse fill="black" stroke="black" stroke-width="1.2" cx="269.25" cy="-14.14" rx="57.45" ry="14.14"/>

<text text-anchor="start" x="236.62" y="-11.64" font-family="Georgia" font-weight="bold" font-size="10.00" fill="white">End Process</text>

</g>

<!-- Exit&#45;&gt;Right -->

<g id="edge8" class="edge">

<title>Exit&#45;&gt;Right</title>

<path fill="none" stroke="black" stroke-width="2" d="M339.65,-14.14C371.52,-14.14 403.38,-14.14 435.25,-14.14"/>

<polygon fill="black" stroke="black" stroke-width="2" points="339.99,-10.64 329.99,-14.14 339.99,-17.64 339.99,-10.64"/>

</g>

<!-- Left&#45;&gt;Exit -->

<g id="edge13" class="edge">

<title>Left&#45;&gt;Exit</title>

<path fill="none" stroke="red" stroke-width="2" d="M69.25,-14.14C69.25,-14.14 141.06,-14.14 198.62,-14.14"/>

<polygon fill="red" stroke="red" stroke-width="2" points="198.37,-17.64 208.37,-14.14 198.37,-10.64 198.37,-17.64"/>

<text text-anchor="start" x="146.9" y="-36.59" font-family="Arial" font-weight="bold" font-size="9.00">File</text>

<text text-anchor="start" x="145.4" y="-27.59" font-family="Arial" font-weight="bold" font-size="9.00">size</text>

<text text-anchor="start" x="130.4" y="-18.59" font-family="Arial" font-weight="bold" font-size="9.00">unchanged</text>

</g>

</g>

</svg>

1
Column A Column B
Cell 1 Cell 2
Formatting Sandbox Cell 4

Formatting Sandbox

1
alert("ACE test")

ACE does not work on Stack Exchange, because if it did you would have seen a browser alert.

3
1

<b>Test</b> t`e`st `test`

1

Testing image sizes Why huge images?

enter image description here

1

trying to make a copy button for my markdown

function test() {
  console.log("This code will have a copy button to the right of it");
}
Employee ID# Employee Name Company Orientation Date
blank space blank space blank space Lifetime
blank space blank space blank space WFD
blank space blank space blank space 5 hours
Employee ID# Employee Name Company Orientation Date
752856 Smith, John Waste LLC 12/28/2023
685273 Jones, Tracy Paint & Co 11/07/2023
385418 Ramirez, Jen Waste LLC 12/23/2023
787233 Johnson, Ted Paint & Co 10/07/2023
988534 Smith, Jane Waste LLC 10/22/2023
438541 Williams, Ken PipeFab LLC 11/18/2023
1
<sub>
test _hello_ test - newline at start and end
</sub>
test _hello_ test - newline at start and end
<sub> test _hello_ test - oneline</sub>

test hello test - oneline


<sub>
test _hello_ test - newline at start</sub>
test _hello_ test - newline at start
<sub>test _hello_ test - newline at end
</sub>

test hello test - newline at end

1

Create Markdown from T-SQL?

https://www.sqlservercentral.com/articles/creating-markdown-formatted-text-for-results-from-sql-server-tables

From Excel

ID Name Age Salary Height MaritalStatus
1 Tim 31 300 191.2 1
2 Tom 21 400 181.87 2
3 Tam 51 500 176.54 3

https://davetallett26.github.io/excel-markdown.html

Excel > Data > Get Data > From Database > From SQL Server database

From T-SQL

ID Name Age Salary Height MaritalStatus
1 Tim 31 300.00 191.20 1
2 Tom 21 400.00 181.87 2
3 Tam 51 500.00 176.54 3
USE [TestMD]
GO
/****** Object:  StoredProcedure [dbo].[Select2MD]    Script Date: 27/03/2024 07:50:32 ******/
SET ANSI_DEFAULTS ON
GO
ALTER PROCEDURE [dbo].[Select2MD]
/*
Author: Tomaz Kastrun and David Tallett
Date: 26.Mar.2024
Description: Turns result set of selected table into Markdown suitable for use on StackOverflow
Usage:
        EXEC dbo.select2MD
                @table_name = 'TestForMD'
               ,@schema_name = 'dbo'

        DECLARE @text NVARCHAR(100)
        SET @text = 'This is line 1.' + CHAR(13) + 'This is line 2.'
        SELECT @text

stackoverflow.com/questions/31057/how-to-insert-a-line-break-in-a-sql-server-varchar-nvarchar-string

Tools > Options > Query Results > SQL Server > Results to Grid > Retain CR/LF on copy or save
SQL Server Management Studio                        19.3.4.0

ToDO:
*/    @table_name VARCHAR(200)
     ,@schema_name VARCHAR(20)
AS 
BEGIN
        SET NOCOUNT ON;
    -- get the columns of the table
        SELECT 
            c.Column_name
            ,c.Ordinal_position
            ,c.is_nullable
            ,c.Data_Type
        
        INTO  #temp
        
        FROM INFORMATION_SCHEMA.TABLES AS  t
        JOIN INFORMATION_SCHEMA.COLUMNS AS c 
        ON t.table_name = c.table_name
        AND t.table_schema = c.table_schema
        AND t.table_Catalog = c.table_Catalog
        WHERE
        t.table_type = 'BASE TABLE'
        AND t.Table_name = @table_name
        AND t.table_schema = @schema_name

            DECLARE @MD NVARCHAR(MAX)

            -- header | name | name2 | name3 | name4 | name5 | name6 
            DECLARE @header VARCHAR(MAX)
            SELECT @header = COALESCE(@header + ' | ','') + column_name 
            FROM #temp
            ORDER BY Ordinal_position ASC
            SELECT @header = ' | ' + @header + ' | '

            -- delimiter | --- | --- | --- | --- | --- | --- 
            DECLARE @nof_columns INT = (SELECT MAX(Ordinal_position) FROM #temp)
            DECLARE @firstLine NVARCHAR(MAX) = (SELECT  REPLICATE('| --- ',@nof_columns) + '|')  
            SET @MD = @header + CHAR(13) + CHAR(10) + CHAR(32) + @firstLine + CHAR(13) + CHAR(10)

            -- body
            DECLARE @body_sql NVARCHAR(MAX)
            SET @body_sql = 'SELECT
            ''| '' + CAST(' 
            DECLARE @i INT = 1
            WHILE @i <= @nof_columns
            BEGIN
                DECLARE @w VARCHAR(1000) =  (SELECT column_name FROM #temp WHERE Ordinal_position = @i)
                    SET @body_sql = @body_sql + @w + ' AS VARCHAR(MAX))+ '' | '' + CAST( '
                SET @i = @i + 1
            END
            SET @body_sql  = (SELECT SUBSTRING(@body_sql,1, LEN(@body_sql)-8))
            SET @body_sql = @body_sql + ' FROM ' + @table_name

            DECLARE @bodyTable TABLE(MD VARCHAR(MAX))
            INSERT INTO @BodyTable
            EXEC sp_executesql @body_sql

            DECLARE @body2 NVARCHAR(MAX)
            SELECT @body2 = COALESCE(@body2 + ' ', ' ') + MD + CHAR(13) + CHAR(10) 
            FROM @bodyTable
            SET @MD = @MD + @body2
          
            SELECT @MD
END;
1

Testing whitespace in inline code formatting. (Seems to render different in the preview.) Edit: Confirmed, whitespace at the start of a line gets stripped, but not in preview.

Original

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'foo' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)

Inline formatted

Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'foo' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)

How that previews (preformatted):

Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: cannot import name 'foo' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)

Newlines replaced with spaces, inline formatted

Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'foo' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)

How that previews (preformatted):

Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: cannot import name 'foo' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)
1

Let's try to play with code snippets...

$("#fade-toggle").click(() => {
  $("p").fadeToggle();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<button id="fade-toggle">Show/Hide</button>
<br>
<p>text</p>

It worked. Maybe I can use ReactJS?

function MyForm() {
  return (
    <div>
      <form>
        <label>Enter your name:
          <input type="text" />
        </label>
      </form>
    </div>
  )
}

const root = ReactDOM.unstable_createRoot(document.getElementById('root'));
root.render(<MyForm />);
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

It actually works, you just have to use Babel and create a root element.

2
1

note to self: This sandbox is probably best for further reading/ comment overflow etc.. https://chat.stackoverflow.com/ seems more for -- chat.


Test whether links to Sandbox answers break on archival, created [2024-07-15]: Formatting Sandbox


Tests

https://meta.stackexchange.com/a/401417/164541
https://meta.stackexchange.com/a/401417

https://meta.stackexchange.com/q/68957/164541   
https://meta.stackexchange.com/q/68957   
https://meta.stackexchange.com/questions/68957/manually-clear-saved-question-drafts/401417#answer-401417  
https://meta.stackexchange.com/questions/68957/manually-clear-saved-question-drafts/401417  
https://meta.stackexchange.com/questions/68957/manually-clear-saved-question-drafts


Manually clear saved question drafts
Manually clear saved question drafts
Manually clear saved question drafts
Manually clear saved question drafts
Manually clear saved question drafts

  • None of these get replaced in comments.
2
  • 1
    Do note that chat markdown is different from the main sites, and comments - some basic things are same, but some things exist in one and not the other. Chat should also have sandbox rooms. Commented Jul 15 at 16:53
  • @ShadowWizard indeed, and check that stylish id x) : chat.stackexchange.com/rooms/1/sandbox Commented Jul 15 at 17:05
1

It is a “lose-lose scenario” or a “lose-lose situation”, in which, no matter which path you take, you lose.

Merriam-Webster

    presenting two options both of which put one at a disadvantage
    (example usage) a lose-lose proposition

    Recent Examples on the Web:


    During a war, NATO would face a lose-lose choice: lose a fight with conventional weapons or initiate a mutually catastrophic nuclear exchange.
    — Keir A. Lieber, Foreign Affairs, 24 Oct. 2023

Wiktionary
    Having only negative outcomes.
Wordnik
    A situation that has only negative outcomes
“lose-lose situation” at Urban Dictionary
    You lose both ways in a situation.

    I thought that lying to Mark would keep his feelings from being hurt, but really his feelings got hurt AND he doesn't trust me any more.  That's a lose-lose situation.
Cambridge English Dictionary
    A lose-lose situation or result is one that is bad for everyone who is involved:

    • He said that going ahead with the strike would be a lose-lose situation for all concerned.
1

World. Hello. World. Hello. World. Hello.

3
  • testing if I can bypass grace period using a comment
    – wjandrea
    Commented Sep 6 at 20:28
  • second edit isn't showing... test comment to see if this will kick it in
    – wjandrea
    Commented Sep 6 at 20:30
  • 1
    Oh that's so weird! I made multiple edits in quick succession but only the first one is showing! I wonder if there's a race condition or SE is using eventual consistency and either I'm just not seeing it yet or there's a conflict on the back end.
    – wjandrea
    Commented Sep 6 at 20:33
1

Testing the new highlighter changes.

This code block with the lang-console hint highlights in the preview pane:

Code block with highlighted text

Here's how it looks when rendered in a post:

% perl -lae 'BEGIN {$, = " "} scalar(grep {$_ eq $F[0]} @buf) ? print(reverse(@F)) : do {print(@F); push(@buf, $F[0])}' input
172.55.34.48 172.55.33.95
172.55.32.163 172.55.34.48
172.55.33.95 172.55.32.163

JavaScript test

Available highlighting hints:

  • Official code: lang-javascript
  • Stack Exchange alternate: lang-js
  • HL.js alternates: lang-jsx, lang-mjs, lang-cjs
No highlighting (lang-none)
console.log('Hello highlighter!');

In preview, each of the below look like this:

Highlighted JS code

lang-javascript
console.log('Hello highlighter!');
lang-js
console.log('Hello highlighter!');
lang-jsx
console.log('Hello highlighter!');
lang-mjs
console.log('Hello highlighter!');
lang-cjs
console.log('Hello highlighter!');
1

Doing some experiment with the code snippet from https://meta.stackexchange.com/a/372141

var langNameOverride = {    // when name needs some tweaking
  bash:  'Bash and other shell scripts', c: 'C and C-likes', delphi: 'Delphi, Pascal',
  http:  'HTTP request/&#8203;response',                     ini:    'INI, TOML',
  javascript:     'JavaScript',                              latex:  'LaTeX, TeX',
  mathematica:    'Mathematica / Wolfram Language',          matlab: 'MATLAB',
  ocaml: 'OCaml, F#, SML and other ML-family languages',     php:    'PHP',
  'php-template': 'PHP template (HTML+PHP)',  r: 'R, S',     scheme: 'Scheme, Racket',
  vbnet: 'Visual Basic&nbsp;(.NET), VBScript',               shell:  'Shell session',
  xml:   'XML, HTML and their derivatives'
};
var langComments = {
  plaintext:   'explicitly disables syntax highlighting',
  mathematica: 'Mathematica&nbsp;SE only'
};
var markdown = `<!-- Generated by https://meta.stackexchange.com/a/372141/578924 using Highlight.js v${hljs.versionString} on ${(new Date()).toISOString()} -->
Format: **Language name: \`lang-code\`**, custom Stack Exchange aliases, (other Highlight.js aliases)\n\n`;

var languages = hljs.listLanguages();
languages.splice(languages.indexOf('plaintext'), 1);
languages.sort().unshift('plaintext');

for (var langCode of languages) {
  var lang = hljs.getLanguage(langCode), aliasesSE = '', langProcessed = false;
  for (var alias in customAliases) {
    if (customAliases[alias] != langCode)
      // custom aliases go in blocks per language,
      // no need to search further if the block is over
      if (langProcessed) break; else continue;

    aliasesSE += ', `lang-'+alias+'`';
    if (lang.aliases && (i = lang.aliases.indexOf(alias)) > -1)
      if (lang.aliases.length > 1)
        lang.aliases.splice(i, 1);
      else
        delete lang.aliases;
    langProcessed = true;
    delete customAliases[alias];        // don't check the processed aliases again
  }

  var aliases = '';
  if (lang.aliases)
    aliases = ', (`lang-'+lang.aliases.join('`, `lang-')+'`)';

  var langName = langNameOverride[langCode] || lang.name;
  var comment = langComments[langCode] || '';
  if (comment)
    comment = '  \n  ('+comment+')';
  markdown += '- **'+langName+': `lang-'+langCode+'`**'+aliasesSE+aliases+comment+'\n';
}
markdown += '<!'+'-'.repeat(90)+'>';
document.getElementById('markdown').textContent = markdown;

function copyLangListToClipboard() {
  // Majority kindly borrowed from https://stackoverflow.com/a/987376
  const node = document.getElementById('markdown');
  const selection = window.getSelection();
  const range = document.createRange();
  range.selectNodeContents(node);
  selection.removeAllRanges();
  selection.addRange(range);
  document.execCommand('copy');
}
<script>
    var StackExchange = {};             // prevents highlightjs-loader execution error

    // hack to get custom Stack Exchange aliases
    Object._keys = Object.keys;
    Object.keys = function(obj) {
        if (obj.none) {
            window.customAliases = obj;
            Object.keys = Object._keys;
        }
        return Object._keys(obj);
    };
</script>
<script id="webpack-public-path"></script>
<script src="https://meta.stackexchange.com/Content/Js/highlightjs-loader.en.js"></script>

<button type="button" onclick="copyLangListToClipboard()">Copy to Clipboard</button>
<pre><code id="markdown"></code></pre>


Format: Language name: lang-code, custom Stack Exchange aliases, (other Highlight.js aliases)

  • Plain text: lang-plaintext, lang-none, (lang-text, lang-txt)
    (explicitly disables syntax highlighting)
  • Bash and other shell scripts: lang-bash, lang-bsh, lang-csh, lang-sh
  • C and C-likes: lang-c, lang-cyc, lang-m, lang-c-like, (lang-h)
  • Clojure: lang-clojure, lang-clj, (lang-edn)
  • CoffeeScript: lang-coffeescript, lang-coffee, (lang-cson, lang-iced)
  • C++: lang-cpp, lang-cc, lang-cxx, (lang-c++, lang-h++, lang-hpp, lang-hh, lang-hxx)
  • C#: lang-csharp, lang-cs, (lang-c#)
  • CSS: lang-css
  • Dart: lang-dart
  • Delphi, Pascal: lang-delphi, (lang-dpr, lang-dfm, lang-pas, lang-pascal)
  • Erlang: lang-erlang, lang-erl
  • Go: lang-go, (lang-golang)
  • Haskell: lang-haskell, lang-hs
  • HTTP request/​response: lang-http, (lang-https)
  • INI, TOML: lang-ini, (lang-toml)
  • Java: lang-java, (lang-jsp)
  • JavaScript: lang-javascript, lang-js, (lang-jsx, lang-mjs, lang-cjs)
  • JSON: lang-json
  • Julia: lang-julia
  • Kotlin: lang-kotlin, (lang-kt, lang-kts)
  • LaTeX, TeX: lang-latex, lang-tex
  • Less: lang-less
  • Lisp: lang-lisp, lang-cl, lang-el, lang-lsp
  • Lua: lang-lua
  • Makefile: lang-makefile, (lang-mk, lang-mak, lang-make)
  • Markdown: lang-markdown, (lang-md, lang-mkdown, lang-mkd)
  • MATLAB: lang-matlab
  • Objective-C: lang-objectivec, (lang-mm, lang-objc, lang-obj-c, lang-obj-c++, lang-objective-c++)
  • OCaml, F#, SML and other ML-family languages: lang-ocaml, lang-fs, lang-ml
  • Perl: lang-perl, lang-pl, (lang-pm)
  • PHP: lang-php
  • PHP template (HTML+PHP): lang-php-template
  • Protocol Buffers: lang-protobuf, (lang-proto)
  • Python: lang-python, lang-py, lang-cv, (lang-gyp, lang-ipython)
  • R, S: lang-r, lang-s
  • Ruby: lang-ruby, lang-rb, (lang-gemspec, lang-podspec, lang-thor, lang-irb)
  • Rust: lang-rust, lang-rc, lang-rs
  • Scala: lang-scala
  • Scheme, Racket: lang-scheme, lang-scm, lang-ss, lang-rkt
  • SCSS: lang-scss
  • Shell session: lang-shell, (lang-console, lang-shellsession)
  • SQL: lang-sql
  • Swift: lang-swift
  • TypeScript: lang-typescript, (lang-ts, lang-tsx, lang-mts, lang-cts)
  • Visual Basic (.NET), VBScript: lang-vbnet, lang-vb, lang-vbs
  • VHDL: lang-vhdl, lang-vhd
  • XML, HTML and their derivatives: lang-xml, lang-html, lang-xsl, (lang-xhtml, lang-rss, lang-atom, lang-xjb, lang-xsd, lang-plist, lang-wsf, lang-svg)
  • YAML: lang-yaml, (lang-yml)
1
  • Apparently there's no change (see revision) :S Commented Oct 11 at 6:22
1

Testing: Does markdown in edit summaries render properly in the revisions list? (See revisions list.)

1

Are multi-paragraph comments possible?

1
  • Let's see... Shift-enter just combined the whitespace, so no.
    – Anerdw
    Commented Nov 26 at 4:07
1

Very good! Fantastic! Very good! Fantastic! Very good! Fantastic!frefferfgerger

1

This is to have a known post that definitely has the text Paytm=पेटीएम in it to test searching.

2
  • Test successful, I found this post when searching for पेटीएम . Commented Dec 1 at 14:53
  • 1
    @ShadowWizard That wasn't the intended test. The intended test was to be able to differentiate between "Paytm=(something)" and just "Paytm" or "paytm" without the equals sign. While it's possible to write code to do that, there doesn't appear to be any easy way to do so.
    – Makyen
    Commented Dec 1 at 17:12
0

С#:

public string X {get; set;}

default:

public string X {get; set;}
0
0

this post is so not by Stormblessed it’s just incredible how written-by-a-different-person it is (this is going to be for a bug report)

Hi this is a person who is very non-blessed-by-the-storms.

0

.bold text after a dot works in answers

.it can also be done using HTML tags

8
0

<$ ‮ !oboRhceTehT m'I ,iH

Try editing the above sentence post to say something else (but dont remove the <$), you'll have nightmares >:)

1
  • Aha! Unicode hacks! ‮‮ Commented Jun 30, 2020 at 14:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .