Questions tagged [code]
Questions relating to code that appears in a question or answer, such as answers which are entirely code. Do not use this tag for questions about code formatting; use [code-formatting] instead - and NEVER EVER USE THIS TAG TO ASK A PROGRAMMING QUESTION ON META!.
133
questions
4
votes
1
answer
113
views
Can't edit a code post, but can post one?
This seems to be a problem to me. I have edited posts that have mostly or all code in them(this, for example), and I cannot edit the code alone because Stack Overflow says the edit is mostly code.
My ...
-8
votes
1
answer
90
views
URL shortner checker should not check code formatted snippets
Today while trying to salvage a question; I was prevented from doing so as the URL checker blocked the bit.ly URL.
The checker should ignore code snippets.
47
votes
0
answers
505
views
Reach out to Code Sandbox or some other mechanism for avoiding these links
I've seen a few questions where the code is all in a markdown link with an image to Code Sandbox:
[](https://codesandbox.io/s/new)
...
9
votes
2
answers
181
views
When reviewing, is it OK to accept code edits to an answer? [duplicate]
While doing reviews for suggested edits something like this occurs frequently
with comment like
... removed unused try-catch block ...
I strongly feel that if an answer "needs" code editing as ...
3
votes
1
answer
202
views
How do I tell Stack Overflow that my post DOES NOT contain code?
When I try to post my question, the interface tells me
Your post appears to contain code that is not properly formatted as code.
However, my post does not contain any code. How can I promise that ...
0
votes
0
answers
49
views
Add feature to POPUP the overflowed code [duplicate]
1) In many cases, we see the "scrolling-bar"-ed codes. It would be nice, it there was "full-screen view" button on the right bottom side, af, after clicking on it, the code should show/popup on full-...
16
votes
1
answer
658
views
Is it possible to link directly to a full-screen code snippet?
This answer is a thing of beauty. I want to share it far and wide, but I can't figure out how to link directly to the snippet in full screen mode. The helpful "Expand Snippet" button is great and ...
-12
votes
1
answer
322
views
Idea - long/wide code on Stack Overflow page - expand or open in bigger window [duplicate]
My idea is only for wide and long code, not easy to read without scroll left, right, up and down. Possibility to expand (when clicking on it or hover over) or open this code in a bigger window (button)...
-10
votes
1
answer
172
views
Can Stack Overflow release the source code for the image uploader? [duplicate]
Is it possible to open-source the Imgur image uploader you have made for profile pictures etc.?
I know this can be accomplished but it would make life just that little bit easier for so many devs. ...
-6
votes
2
answers
267
views
How to ask a question about proprietary code my company won't allow me to post? [duplicate]
I am currently struggling with a piece of code at work, but legally I am not allowed to post the code online.
This is a very specific problem, and I am sure it's not possible to create a minimal code ...
9
votes
1
answer
241
views
Would it be better to post code with or without the terminal prompt? [duplicate]
This is with regards to answering questions in scripting language tags such as Python, where you can also execute code in an interpreter/REPL session. I am talking about these kind of prompts:
In [...
0
votes
1
answer
92
views
Cannot edit post to format code [duplicate]
There has been many posts I have seen with very improper and annoying code formatting. Some code is formatted, some is not, etc. When trying to fix it I get the error:
"It looks like your post is ...
0
votes
0
answers
84
views
Should I ask programming questions without code samples on Stack Overflow? [duplicate]
If I ask any question without sample code, some members are saying this question shouldn't be on Stack Overflow; ask somewhere else. Is it not allowed to ask such question?
I would like to hear some ...
5
votes
0
answers
100
views
Button to easily copy code snippets [duplicate]
There should be a little icon in the corner of each code snippet which when clicked, copies the entire code snippet to the clipboard.
Test snippet
Currently, there is no easy way to copy this ...
32
votes
3
answers
1k
views
Is it wrong to fix mistakes in quoted material?
I found a well-received but link-only answer.
I attempted to edit the answer to copy the linked article into a blockquote but I found out that the code has a bunch of syntax errors (it looks like a ...
2
votes
1
answer
1k
views
How to add CSS on Stack Overflow like HTML to be displayed? [duplicate]
I am new to Stack Overflow so probably will make a mistake in the asking area.
I feel so stupid want to ask a question over here: Can I paste my HTML, but cannot paste my CSS? It won't display in the ...
4
votes
0
answers
86
views
Shouldn't Ctrl + A in a code-block select the block's code instead of the entire page?
When you use Ctrl + A on a Stack Overflow page, regardless of content, the default browser behavior is used -- which is to highlight everything on the page.
Other sites (like Gmail, etc.) have a ...
1
vote
0
answers
40
views
Why are code samples sometimes shown unformatted? [duplicate]
Sometime, I post questions (or answers for that matter), where code appears unformatted (without reserved words color, etc.), like the image below.
Why is that happening?
Here's an example to ...
13
votes
3
answers
545
views
Stack Exchange removes certain unicode characters from code blocks (causing some code to not work)
Bug
I answered a question recently on CodeGolf.SE and my answer included the character U+0007 in my code; however, Stack Exchange (including Stack Overflow) removed certain unicode characters from ...
1
vote
3
answers
89
views
Can I edit out irrelevant code in an old question?
I know we are generally not supposed to touch other people's code when editing, but sometimes I come across old questions that have a lot more code than is needed for understanding the problem and ...
28
votes
2
answers
1k
views
Should code from pastebin be edited into a question? [duplicate]
Sometimes when I review edits in the Suggested Edits queue, code or text from a linked pastebin is edited into the question. Is this encouraged? Should this be approved?
8
votes
1
answer
405
views
Code added in edit by unrelated user
While editing a moment ago, I came across this edit which was made by a user seemingly unrelated to the OP.
The edit however added the full code that should have been in the question, which is fine ...
45
votes
3
answers
1k
views
Are edits that insert Swift 3 code into existing Swift 2 answers acceptable?
We have received complaints about some recent edits that inserted Swift 3 code into Swift 2 answers. One such example is here. Moderators have rolled back these edits, only to have them reinstated.
...
40
votes
3
answers
2k
views
What's better: a question with no attempt or with an unfixable/irrelevant attempt?
We sometimes get downvoted on Stack Overflow by posting one-liner, working answers to some users with a very clear problem, like here.
So, OK, we're not a code-writing service, but what about the bad ...
3
votes
1
answer
99
views
Should I flag questions that appear to contain suspicious code?
In this question, the current version emphasizes not to run the code in the question, which I don't know whether it really contains potential hazards. Should I flag such kind of post to request ...
11
votes
1
answer
378
views
Is it possible to add a CSS compiler/transpiler (Sass or Less) in stack code snippets?
We need to support a CSS compiler - Sass and Less. If CSS compilers are not supported on Stack Overflow code snippet which must be included. If it can't be supported in stack code snippets, allow ...
4
votes
1
answer
70
views
Editing code snippets for changes in a framework
There's a 5 year old question on SO where the correct usage in Django was get_query_set. Since Django 1.6 (released Nov 2013) the correct usage is get_queryset. I edited the answer since I thought it'...
-4
votes
1
answer
146
views
Why is there 'CR' in Stack Overflow HTML code? [closed]
I was using Inspect Element to look through Stack Overflow's HTML code.
While doing that, I spotted 'CR' at the end of each line:
Just curious, what does this represent or is it a rendering error?
...
33
votes
1
answer
1k
views
How best to correct poor coding practice which isn't related to the answer
Inspired by this question.
How should I let a user know that the code they've written goes against Microsoft's recommended practice? In this case, instantiating an SPSite instance with a hardcoded ...
2
votes
1
answer
110
views
Is Dropbox appropriate for hosting a live demo in a post?
I often build small static sites, anywhere between 3 and 30 files, that I routinely host and demo for clients. Sometimes I'd like to link to these projects in an SE post to demonstrate some odd ...
1
vote
1
answer
147
views
What to do with this dangerous code? [duplicate]
A user posted this question.
I have answered without giving the answer purposely, and flagged the question to the attention of the moderators.
Although it doesn't seem to me that the aim of this ...
-16
votes
1
answer
100
views
Would it be possible to automatically open a code in an IDE?
I know that copying and pasting is not that difficult
but still, it would be a feature to automatically open an IDE with the code in an SO question, with its file type somehow coded and so the IDE ...
2
votes
0
answers
31
views
Tab usage in Q-A section as in Documentation [duplicate]
I've found out that I can use tab while writing Examples in Documentations. It makes writing code easier while writing a question or answering one. Are you planning to implement this in Q-A too?
-1
votes
2
answers
395
views
Is pasting code from the reference source from Microsoft legal?
When using .peek and ReSharper in Visual Studio (15) you can check the implementation of framework types. It will download a reference source debug file, and you can check the reference-only code.
...
1
vote
0
answers
33
views
Please add a "full screen view" button for code parts [duplicate]
The need for horizontal scrolling on code is very annoying. Full visibility helps to better understand.
update:
Most of the time,the focus is on asking question and giving answer,and not according to ...
43
votes
1
answer
818
views
Edited question made less readable
A co-worker posted a question and came back later to see that it had been edited.
TL;DR: a Java stacktrace was edited to wrap at 90 chars instead of scroll.
When we checked the edit my eyes glazed ...
2
votes
1
answer
113
views
Should questions be edited to remove error-checking statements that dilute the code?
In C one should rigorously perform null-checks, however doing so obfuscates the rest of the code making it more difficult to review. Is it okay to remove such statements from an original post solely ...
28
votes
0
answers
454
views
Inlining external code - copyright?
Today I came about a question in the review queue which could benefit from inlining the small code sample that was linked by OP by including it directly into the question.
But: Code hosted on Stack&...
3
votes
1
answer
101
views
Is an answer with proposed, but unadopted, code syntax low quality?
I saw someone answer a question yesterday with draft PHP RFC code
Static class initializer in PHP
It was in the LQR and I said it was OK (it does attempt to answer the question), but I went back to ...
-5
votes
1
answer
305
views
Require image of Scratch script for Scratch questions
It's hard to visualize a script in visual programming language like Scratch. Here's an example of what I mean:
The correct way to make an infinite loop without the forever block is to use the repeat ...
3
votes
1
answer
98
views
Can we make other people's code "self-contained" by cleaning up external dependencies?
I often see questions with code samples depending on external resources (libraries, images). Those code samples are not self-contained, often more complicated to understand, and cannot be turned into ...
4
votes
1
answer
79
views
Should exceptions resulting from code be inside code snippets?
I've always used block quotes to display the resulting exception from code I need help with or something I didn't understand. But for some reason people always seem to edit them and put the exception ...
42
votes
0
answers
819
views
Bad CSS on quoted code on Meta
As seen in How to include code inside a quotation?
A very quick investigation (literally, right-click, Inspect Element :D) found the cause. For some reason, the minifier has interpreted tabs to be ...
5
votes
0
answers
77
views
Why have strings within certain language-syntax code blocks gone green? [duplicate]
Strings in certain languages used to be a browny-redish colour. They're now green:
// JavaScript
"Hello, world"
// PHP
"Hello, world"
// C++
"Hello, world"
I'm very used to green representing the ...
2
votes
0
answers
72
views
Where do I ask Competitive coding questions which don't have solutions?
Where should one ask for hints and solutions regarding competitive coding problems/questions for which the author on some sites don't provide the answer, and I'm unable to solve the problem after ...
26
votes
1
answer
803
views
Typos in code snippet from a good answer? [duplicate]
I tried to edit a typo in a code snippet in answer from another user (here, 4-letter edit to make, owner fixed it) but I couldn't even submit my change for review as it is only 5 char long.
This ...
4
votes
2
answers
164
views
Stack Snippets - Using alert() vs document.write() vs console.log()
Is it bad practice to use either alert(), document.write or console.log() in Stack Snippets? I personally find alert() quite annoying, and console.log() takes time to see the output (you need to open ...
28
votes
6
answers
763
views
Should we change "void main()" to "int main()" in the OP's code?
Recently I noticed a question where a long time user edit the void main() in the OP's code to int main(). I left a comment asking how did he know that is not using void main()? I got a reply back ...
-4
votes
1
answer
85
views
Editing non functional code into .. non functional code. Editor seems unaware of the language syntax
A user has attempted to improve some answers (1, 2) by editing their code. Before the editing took place, the code wouldn't work (e.g. it would raise IndentationError) or wouldn't be formated as code ...
-40
votes
2
answers
350
views
Should we allow answers that contain hard-coded values?
I've seen answers where values in the example code are hard-coded. An example might be
if (name === "Robert") {
} else if (name === "John") {
}
It isn't considered best practice to hard-code values ...