Most Popular
1500 questions
1325
votes
14 answers
How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?
I have a JavaScript widget which provides standard extension points. One of them is the beforecreate function. It should return false to prevent an item from being created.
I've added an Ajax call into this function using jQuery:
beforecreate:…
Artem Tikhomirov
- 21,497
- 10
- 48
- 68
1323
votes
11 answers
How to check if a map contains a key in Go?
I know I can iterate over a map m with
for k, v := range m { ... }
and look for a key, but is there a more efficient way of testing for a key's existence in a map?
grokus
- 18,046
- 9
- 29
- 35
1321
votes
18 answers
How to call asynchronous method from synchronous method in C#?
I have a public async void Foo() method that I want to call from synchronous method. So far all I have seen from MSDN documentation is calling async methods via async methods, but my whole program is not built with async methods.
Is this even…
Tower
- 98,741
- 129
- 357
- 507
1321
votes
27 answers
How do I sort an NSMutableArray with custom objects in it?
What I want to do seems pretty simple, but I can't find any answers on the web. I have an NSMutableArray of objects, and let's say they are 'Person' objects. I want to sort the NSMutableArray by Person.birthDate which is an NSDate.
I think it has…
rustyshelf
- 44,963
- 37
- 98
- 104
1321
votes
8 answers
How do I copy a version of a single file from one Git branch to another?
I've got two branches that are fully merged together.
However, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would just be easier to change to the new version in the…
madlep
- 47,370
- 7
- 42
- 53
1320
votes
21 answers
Get the name of an object's type
Is there a JavaScript equivalent of Java's class.getName()?
Ewen Cartwright
- 15,378
- 4
- 22
- 21
1320
votes
24 answers
How can I write 'a:hover' in inline CSS?
I have a case where I must write inline CSS code, and I want to apply a hover style on an anchor.
How can I use a:hover in inline CSS inside the HTML style attribute?
E.g., you can't reliably use CSS classes in HTML emails.
Amr Elgarhy
- 66,568
- 69
- 184
- 301
1319
votes
18 answers
What is a mixin and why is it useful?
In Programming Python, Mark Lutz mentions the term mixin. I am from a C/C++/C# background and I have not heard the term before. What is a mixin?
Reading between the lines of this example (which I have linked to because it is quite long), I am…
TarkaDaal
- 18,798
- 7
- 34
- 51
1318
votes
5 answers
Putting a simple if-then-else statement on one line
How do I write an if-then-else statement in Python so that it fits on one line?
For example, I want a one line version of:
if count == N:
count = 0
else:
count = N + 1
In Objective-C, I would write this as:
count = count == N ? 0 : count +…
Abizern
- 146,289
- 39
- 203
- 257
1317
votes
5 answers
What is the in a .vimrc file?
I see in many .vimrc files, and I am wondering what does it mean?
What is it used for?
Just a general overview of the purpose and usage would be great.
Bob Martens
- 13,542
- 3
- 17
- 9
1315
votes
19 answers
Remove element by id
When removing an element with standard JavaScript, you must go to its parent first:
var element = document.getElementById("element-id");
element.parentNode.removeChild(element);
Having to go to the parent node first seems a bit odd to me, is there…
Zaz
- 46,476
- 14
- 84
- 101
1314
votes
84 answers
How to get the difference between two arrays in JavaScript?
Is there a way to return the difference between two arrays in JavaScript?
For example:
var a1 = ['a', 'b'];
var a2 = ['a', 'b', 'c', 'd'];
// need ["c", "d"]
John Adawan
- 13,329
- 4
- 20
- 11
1313
votes
9 answers
What effect does the `--no-ff` flag have for `git merge`?
Using gitk log, I could not spot a difference between the effect of git merge and git merge --no-ff. How can I observe the difference (with a git command or some tool)?
user1162226
- 13,223
- 3
- 14
- 8
1313
votes
26 answers
What is the purpose of the `self` parameter? Why is it needed?
Consider this example:
class MyClass:
def func(self, name):
self.name = name
I know that self refers to the specific instance of MyClass. But why must func explicitly include self as a parameter? Why do we need to use self in the…
richzilla
- 40,440
- 14
- 56
- 86
1312
votes
81 answers
Xcode - How to fix 'NSUnknownKeyException', Reason: "… this class is not key value coding-compliant for the key X" error?
I'm trying to link a UILabel with an IBOutlet created in my class.
My application is crashing with the following error"
***
Terminating app due to uncaught exception
'NSUnknownKeyException', reason:
'[<UIViewController 0x6e36ae0>…
Guillaume Dubois
- 2,003
- 3
- 13
- 4