Greatest Hits
25927
votes
105
answers
13.2m
views
How do I undo the most recent local commits in Git?
I accidentally committed the wrong files to Git, but didn't push the commit to the server yet.
How do I undo those commits from the local repository?
7352
votes
56
answers
10.5m
views
How to find all files containing specific text (string) on Linux?
How do I find all files containing a specific string of text within their file contents?
The following doesn't work. It seems to display every single file in the system.
find / -type f -exec grep -H '...
20305
votes
41
answers
11.1m
views
How do I delete a Git branch locally and remotely?
Failed Attempts to Delete a Remote Branch:
$ git branch -d remotes/origin/bugfix
error: branch 'remotes/origin/bugfix' not found.
$ git branch -d origin/bugfix
error: branch 'origin/bugfix' not found....
498
votes
82
answers
2.0m
views
How to solve "Error: MySQL shutdown unexpectedly"?
When I open XAMPP and click start MySQL button and it gives me an error.
I had started it just before, but now it isn't working.
12:19:12 PM [mysql] Attempting to start MySQL app...
12:19:12 PM [...
8092
votes
46
answers
4.5m
views
What does if __name__ == "__main__": do?
What does this do, and why should one include the if statement?
if __name__ == "__main__":
print("Hello, World!")
If you are trying to close a question where someone should be ...
11651
votes
149
answers
12.0m
views
How can I remove a specific item from an array in JavaScript?
How do I remove a specific value from an array? Something like:
array.remove(value);
Constraints: I have to use core JavaScript. Frameworks are not allowed.
1799
votes
64
answers
2.1m
views
Error message "error:0308010C:digital envelope routines::unsupported"
I created the default IntelliJ IDEA React project and got this:
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (...
12739
votes
50
answers
3.2m
views
What does the "yield" keyword do in Python?
What is the use of the yield keyword in Python? What does it do?
For example, I'm trying to understand this code1:
def _get_child_candidates(self, distance, min_dist, max_dist):
if self._leftchild ...
454
votes
58
answers
2.1m
views
How to solve "Error: Apache shutdown unexpectedly"?
I've just re-installed XAMPP, and when I try to start my Apache server in the XAMPP Control Panel, I now get the following errors:
16:50:25 [Apache] Status change detected: running
16:50:26 [...
114
votes
14
answers
1.8m
views
Regular expression to check if password is "8 characters including 1 uppercase letter, 1 special character, alphanumeric characters"
I want a regular expression to check that
a password must be eight characters including one uppercase letter, one special character and alphanumeric characters.
And here is my validation ...
2647
votes
35
answers
9.5m
views
How do I create an HTML button that acts like a link?
How do I create an HTML button that acts like a link? So that clicking the button redirects the user to a page.
I want it to be accessible, and with minimal extra characters or parameters in the URL.
3484
votes
30
answers
6.7m
views
How do I convert a String to an int in Java?
How can I convert a String to an int?
"1234" → 1234
4012
votes
138
answers
4.2m
views
Message 'src refspec master does not match any' when pushing commits in Git
I clone my repository with:
git clone ssh://xxxxx/xx.git
But after I change some files and add and commit them, I want to push them to the server:
git add xxx.php
git commit -m "TEST"
git push ...
27103
votes
25
answers
1.8m
views
Why is processing a sorted array faster than processing an unsorted array?
In this C++ code, sorting the data (before the timed region) makes the primary loop ~6x faster:
#include <algorithm>
#include <ctime>
#include <iostream>
int main()
{
// ...
4223
votes
39
answers
5.2m
views
How do I UPDATE from a SELECT in SQL Server?
In SQL Server, it is possible to insert rows into a table with an INSERT.. SELECT statement:
INSERT INTO Table (col1, col2, col3)
SELECT col1, col2, col3
FROM other_table
WHERE sql = 'cool'
Is it ...
9447
votes
53
answers
8.0m
views
How do I force "git pull" to overwrite local files?
How do I force an overwrite of local files on a git pull? My local repository contains a file of the same filename as on the server.
error: Untracked working tree file 'example.txt' would be ...
1555
votes
49
answers
1.7m
views
Message "Support for password authentication was removed."
I got this error on my console when I tried to use git pull:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/...
3969
votes
33
answers
6.9m
views
How to iterate over rows in a DataFrame in Pandas
I have a pandas dataframe, df:
c1 c2
0 10 100
1 11 110
2 12 120
How do I iterate over the rows of this dataframe? For every row, I want to access its elements (values in cells) by the name ...
11386
votes
39
answers
5.2m
views
How can I rename a local Git branch?
How can I rename a local branch which has not yet been pushed to a remote repository?
Related:
Rename master branch for both local and remote Git repositories
How do I rename both a Git local and ...
8489
votes
43
answers
8.2m
views
How do I check out a remote Git branch?
Somebody pushed a branch called test with git push origin test to a shared repository. I can see the branch with git branch -r. How do I check out the remote test branch? I've tried:
git checkout ...
1128
votes
33
answers
3.6m
views
"Uncaught SyntaxError: Cannot use import statement outside a module" when importing ECMAScript 6
I'm using ArcGIS JSAPI 4.12 and wish to use Spatial Illusions to draw military symbols on a map.
When I add milsymbol.js to the script, the console returns error
Uncaught SyntaxError: Cannot use ...
3412
votes
17
answers
6.0m
views
How do I select rows from a DataFrame based on column values?
How can I select rows from a DataFrame based on values in some column in Pandas?
In SQL, I would use:
SELECT *
FROM table
WHERE column_name = some_value
5193
votes
28
answers
2.6m
views
What is the difference between "INNER JOIN" and "OUTER JOIN"?
Also, how do LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN fit in?
7736
votes
91
answers
2.6m
views
Is Java "pass-by-reference" or "pass-by-value"?
I always thought Java uses pass-by-reference. However, I read a blog post which claims that Java uses pass-by-value. I don't think I understand the distinction the author is making.
What is the ...
4077
votes
59
answers
5.1m
views
How do I generate random integers within a specific range in Java?
How do I generate a random int value in a specific range?
The following methods have bugs related to integer overflow:
randomNum = minimum + (int)(Math.random() * maximum);
// Bug: `randomNum` can be ...
560
votes
42
answers
2.5m
views
'pip' is not recognized as an internal or external command
I'm running into a weird error when trying to install Django on my computer.
This is the sequence that I typed into my command line:
C:\Python34> python get-pip.py
Requirement already up-to-date: ...
3266
votes
15
answers
6.1m
views
Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error, while Postman does not?
Mod note: This question is about why XMLHttpRequest/fetch/etc. on the browser are subject to the Same Access Policy restrictions (you get errors mentioning CORB or CORS) while Postman is not. This ...
5197
votes
13
answers
2.9m
views
How do I exit Vim?
I am stuck and cannot escape. It says:
type :quit<Enter> to quit VIM
But when I type that it simply appears in the object body.
3658
votes
31
answers
2.6m
views
What is the difference between public, protected, package-private and private in Java?
In Java, are there clear rules on when to use each of access modifiers, namely the default (package private), public, protected and private, while making class and interface and dealing with ...
2788
votes
52
answers
4.3m
views
PowerShell says "execution of scripts is disabled on this system."
I am trying to run a cmd file that calls a PowerShell script from cmd.exe, but I am getting this error:
Management_Install.ps1 cannot be loaded because the execution of scripts is disabled on this ...
2334
votes
31
answers
5.7m
views
Get selected value in dropdown list using JavaScript
How do I get the selected value from a dropdown list using JavaScript?
<form>
<select id="ddlViewBy">
<option value="1">test1</option>
<option value="2" ...
3485
votes
21
answers
5.2m
views
How can I add new keys to a dictionary?
How do I add a new key to an existing dictionary? It doesn't have an .add() method.
13689
votes
37
answers
3.4m
views
What is the difference between 'git pull' and 'git fetch'?
What are the differences between git pull and git fetch?
3426
votes
38
answers
1.4m
views
Git is not working after macOS update ("xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools")
I updated to the latest OS, and/or restarted my computer (this happens on every major update, but this time all I did was restart my computer on 2022-09-13).
This morning I navigated to my work's ...
4076
votes
92
answers
4.3m
views
How to round to at most 2 decimal places, if necessary
I'd like to round at most two decimal places, but only if necessary.
Input:
10
1.7777777
9.1
Output:
10
1.78
9.1
How can I do this in JavaScript?
2514
votes
31
answers
5.7m
views
How do I declare and initialize an array in Java?
How do I declare and initialize an array in Java?
2906
votes
36
answers
6.1m
views
Renaming column names in Pandas
I want to change the column labels of a Pandas DataFrame from
['$a', '$b', '$c', '$d', '$e']
to
['a', 'b', 'c', 'd', 'e']
1868
votes
64
answers
4.3m
views
What does "Could not find or load main class" mean?
A common problem that new Java developers experience is that their programs fail to run with the error message: Could not find or load main class ...
What does this mean, what causes it, and how ...
3445
votes
69
answers
6.5m
views
How do I format a date in JavaScript?
How do I format a Javascript Date object as a string? (Preferably in the format: 10-Aug-2010)
1732
votes
14
answers
2.5m
views
What does "javascript:void(0)" mean?
<a href="javascript:void(0)" id="loginlink">login</a>
I've seen such hrefs many times, but I don't know what exactly that means.
2724
votes
56
answers
4.9m
views
How do I import an SQL file using the command line in MySQL?
I have a .sql file with an export from phpMyAdmin. I want to import it into a different server using the command line.
I have a Windows Server 2008 R2 installation. I placed the .sql file on the C ...
4327
votes
45
answers
6.1m
views
Finding the index of an item in a list
Given a list ["foo", "bar", "baz"] and an item in the list "bar", how do I get its index 1?
2
votes
1
answer
229k
views
Ionic - how to prevent error "TS2339: Property XXX does not exist on type"
I'm doing a simple loop through an Array and calling a method on each element.
this.scene.manager.scenes.forEach((scene) => {
if(scene.refresh){
scene.refresh();
}
});
This code works, but ...
2569
votes
33
answers
3.7m
views
How can I save username and password in Git?
I want to use a push and pull automatically in Git Extensions, Sourcetree or any other Git GUI without entering my username and password in a prompt, every time.
So how can I save my credentials in ...
5560
votes
27
answers
5.9m
views
Reset local repository branch to be just like remote repository HEAD
How do I reset my local branch to be just like the branch on the remote repository?
I tried:
git reset --hard HEAD
But git status claims I have modified files:
On branch master
Changes to be ...
1716
votes
36
answers
3.8m
views
Find all tables containing column with specified name - MS SQL Server
Is it possible to query for table names which contain columns being
LIKE '%myName%'
?
11168
votes
38
answers
5.3m
views
How do I undo 'git add' before commit?
I mistakenly added files to Git using the command:
git add myfile.txt
I have not yet run git commit. How do I undo this so that these changes will not be included in the commit?
1912
votes
38
answers
4.8m
views
How do I split a string in Java?
I want to split the string "004-034556" into two strings by the delimiter "-":
part1 = "004";
part2 = "034556";
That means the first string will contain the ...
1813
votes
24
answers
3.5m
views
How to redirect one HTML page to another on load
Is it possible to set up a basic HTML page to redirect to another page on load?
5557
votes
18
answers
5.7m
views
How do I push a new local branch to a remote Git repository and track it too?
How do I:
Create a local branch from another branch (via git branch or git checkout -b).
Push the local branch
to the remote repository (i.e. publish), but make it
trackable so that git pull and git ...