Most Popular

1500 questions
3082
votes
34 answers

How can I upload files asynchronously with jQuery?

I would like to upload a file asynchronously with jQuery. $(document).ready(function () { $("#uploadbutton").click(function () { var filename = $("#file").val(); $.ajax({ type: "POST", url:…
Sergio del Amo
  • 74,335
  • 67
  • 149
  • 178
3079
votes
18 answers

How do I disable the resizable property of a textarea?

I want to disable the resizable property of a textarea. Currently, I can resize a textarea by clicking on the bottom right corner of the textarea and dragging the mouse. How can I disable this?
user549757
  • 31,364
  • 4
  • 18
  • 20
3079
votes
13 answers

How can I make a time delay?

I would like to know how to put a time delay in a Python script.
user46646
  • 144,445
  • 43
  • 74
  • 84
3076
votes
30 answers

How to find and restore a deleted file in a Git repository

Say I'm in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I find I need to restore that file. I know I can checkout a file using git checkout HEAD^ foo.bar, but I don't really know when…
avdgaag
  • 40,022
  • 7
  • 28
  • 26
3069
votes
58 answers

How do I test a class that has private methods, fields or inner classes?

How do I use JUnit to test a class that has internal private methods, fields or nested classes? It seems bad to change the access modifier for a method just to be able to run a test.
MattGrommes
  • 11,584
  • 9
  • 35
  • 40
3068
votes
21 answers

How do I clone a list so that it doesn't change unexpectedly after assignment?

While using new_list = my_list, any modifications to new_list changes my_list every time. Why is this, and how can I clone or copy the list to prevent it?
aF.
  • 62,344
  • 41
  • 131
  • 195
3066
votes
30 answers

pretty-print JSON using JavaScript

How can I display JSON in an easy-to-read (for human readers) format? I'm looking primarily for indentation and whitespace, with perhaps even colors / font-styles / etc.
Mark
  • 62,540
  • 45
  • 115
  • 156
3063
votes
20 answers

Is it possible to apply CSS to half of a character?

What I am looking for: A way to style one HALF of a character. (In this case, half the letter being transparent) What I have currently searched for and tried (With no luck): Methods for styling half of a character/letter Styling part of a character…
Mathew MacLean
  • 24,334
  • 3
  • 22
  • 39
3047
votes
29 answers

How do I make git use the editor of my choice for commits?

I would prefer to write my commit messages in Vim, but git is opening them in Emacs. How do I configure git to always use Vim? Note that I want to do this globally, not just for a single project.
brasskazoo
  • 72,485
  • 23
  • 61
  • 74
3031
votes
11 answers

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 question is not about how to fix a "No…
Mr Jedi
  • 31,337
  • 8
  • 27
  • 38
3029
votes
46 answers

Is there an "exists" function for jQuery?

How can I check the existence of an element in jQuery? The current code that I have is this: if ($(selector).length > 0) { // Do something } Is there a more elegant way to approach this? Perhaps a plugin or a function?
Jake McGraw
  • 54,288
  • 10
  • 47
  • 63
3028
votes
29 answers

How to iterate over a dictionary?

I've seen a few different ways to iterate over a dictionary in C#. Is there a standard way?
Jake Stewart
  • 30,489
  • 3
  • 19
  • 15
3025
votes
18 answers

How to make function decorators and chain them together?

How can I make two decorators in Python that would do the following? @makebold @makeitalic def say(): return "Hello" ...which should return: "Hello"
Imran
  • 81,919
  • 23
  • 95
  • 127
3020
votes
68 answers

How can I merge properties of two JavaScript objects dynamically?

I need to be able to merge two (very simple) JavaScript objects at runtime. For example I'd like to: var obj1 = { food: 'pizza', car: 'ford' } var obj2 = { animal: 'dog' } obj1.merge(obj2); //obj1 now has three properties: food, car, and…
JC Grubbs
  • 36,791
  • 28
  • 65
  • 75
3019
votes
14 answers

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
szli
  • 33,033
  • 9
  • 29
  • 38