Automating the InvokeRequired code pattern

Automating the InvokeRequired code pattern

I have become painfully aware of just how often one needs to write the following code pattern in event-driven GUI code, whereprivate void DoGUISwitch() { // cruisin for a bruisin' through exception city object1.Visible = true; obje

using jquery $.ajax to call a PHP function

using jquery $.ajax to call a PHP function

This may be a simple answer, but I'm using jQuery's $.ajax to call a PHP script. What I want to do is basically put that PHP script inside a function and call the PHP function from javascript. <?php if(isset($_POST['something'] { //do so

Deserializing polymorphic json classes without type information using json.net

Deserializing polymorphic json classes without type information using json.net

This Imgur api call returns a list containing both Gallery Image and Gallery Album classes represented in json.I cant see how to deserialize these automatically using Json.NET given that there is no $type property telling the deserializer w

Strangest language feature

Strangest language feature

What is, in your opinion, the most surprising, weird, strange or really "WTF" language feature you have encountered?Please only one feature per answer. 1:In C, arrays can be indexed like so:a[10]which is very common.However, the lesser k

What is the difference between @staticmethod and @classmethod in Python?

What is the difference between @staticmethod and @classmethod in Python?

What is the difference between a function decorated with @staticmethod and one decorated with @classmethod? 1:Maybe a bit of example code will help: Notice the difference in the call signatures of foo, class_foo and static_foo:class A(ob

doGet and doPost in Servlets

doGet and doPost in Servlets

I've developed an HTML page that sends information to a Servlet. In the Servlet, I am using the methods doGet() and doPost():public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException { Strin

java.util.NoSuchElementException - Scanner reading user input

java.util.NoSuchElementException - Scanner reading user input

I'm new to using Java, but I have some previous experience with C#. The issue I'm having comes with reading user input from console.I'm running into the "java.util.NoSuchElementException" error with this portion of code:payment = sc.next();

Why is using a wild card with a Java import statement bad?

Why is using a wild card with a Java import statement bad?

It is much more convenient and cleaner to use a single statement likeimport java.awt.*;than to import a bunch of individual classesimport java.awt.Panel;import java.awt.Graphics;import java.awt.Canvas;...What is wrong with using a wildcard

“cannot resolve symbol R” in Android Studio

“cannot resolve symbol R” in Android Studio

In every instance in all of my classes where I reference R.id.something, the R is in red and it says "cannot resolve symbol R". Also every time there is R.layout.something it is underlined in red and says "cannot resolve method setContentV

Map two lists into a dictionary in Python

Map two lists into a dictionary in Python

Imagine that you have:keys = ('name', 'age', 'food')values = ('Monty', 42, 'spam')What is the simplest way to produce the following dictionary ?a_dict = {'name' : 'Monty', 'age' : 42, 'food' : 'spam'}This code works, but I'm not reall

Unsupported major.minor version 52.0 [duplicate]

Unsupported major.minor version 52.0 [duplicate]

This question already has an answer here: How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version 42 answers Pictures:Comman

Error java.lang.OutOfMemoryError: GC overhead limit exceeded

Error java.lang.OutOfMemoryError: GC overhead limit exceeded

I get this error message as I execute my JUnit tests:java.lang.OutOfMemoryError: GC overhead limit exceededI know what an OutOfMemoryError is, but what does GC overhead limit mean? How can I solve this? 1:This message means that for some

Collapse / concatenate / aggregate a column to a single comma separated string within each group

Collapse / concatenate / aggregate a column to a single comma separated string within each group

I want to aggregate one column in a data frame according to two grouping variables, and separate the individual values by a comma.Here is some data:data <- data.frame(A = c(rep(111, 3), rep(222, 3)), B = rep(1:2, 3), C = c(5:10))data# A

Convert Rows to columns using 'Pivot' in SQL Server

Convert Rows to columns using 'Pivot' in SQL Server

Well I guess I am really dense. I have read the stuff on MS pivot tables and I am still having problems getting this correct. I have seen some of you that seem to eat and sleep this stuff, so I just decided to sign-up and ask the question.I

Why is the order in dictionaries and sets arbitrary?

Why is the order in dictionaries and sets arbitrary?

I don't understand how looping over a dictionary or set in python is done by 'arbitrary' order.I mean, it's a programming language so everything in the language must be 100% determined, correct? Python must have some kind of algorithm that

Reshaping data.frame from wide to long format

Reshaping data.frame from wide to long format

I have some trouble to convert my data.frame from a wide table to a long table.At the moment it looks like this:Code Country 1950 1951 1952 1953 1954AFG Afghanistan 20,249 21,352 22,532 23,557 24,555ALB Albania

What are the rules about using an underscore in a C++ identifier?

What are the rules about using an underscore in a C++ identifier?

It's common in C++ to name member variables with some kind of prefix to denote the fact that they're member variables, rather than local variables or parameters. If you've come from an MFC background, you'll probably use m_foo. I've also se

how to convert LinkedHashMap to Custom java object?

how to convert LinkedHashMap to Custom java object?

I'm trying to get the data from one app to another via RESTful WS and it works, but I cannot use this data since I cannot cast it... WS returns a List of objects like this:{id=1, forename=John, surname=Bloggs, username=jbloggs, role=Graduat

from sys import argv - what is the function of “script”

from sys import argv - what is the function of “script”

I am reading "Learn Python the Hard Way" and was confused by the "script" part of the second line.from sys import argvscript, filename = argvFrom what I understand, the second line says: script and filename comprise argv.I tried running my

Download all messages from a Google group

Download all messages from a Google group

I'm in the process of developing a Google apps migration/archive system and at this point in development I'm trying to come up with a way to download all messages in all the groups that my domain users have created. I know that I can set up

C++: Create abstract class with abstract method and override the method in a subclass

C++: Create abstract class with abstract method and override the method in a subclass

How to create in C++ an abstract class with some abstract methods that I want to override in a subclass? How should the .h file look? Is there a .cpp, if so how should it look?In Java it would look like this:abstract class GameObject{ pu

std::vector as a template function argument

std::vector as a template function argument

I want to make a class method that takes a std::vector reference as an argument and I want to use it with different types of data.The function should look like:void some_function(const std::vector & vect){ //do something with vector }and I

INotifyPropertyChanged and static properties

INotifyPropertyChanged and static properties

I'm tying myself in knots over a simple problem. I have a class that implements INotifyPropertyChanged. Some of the instance properties' getters use static properties and thus their values may change if the static property changes? Here's a

How can I ensure no code uses an API?

How can I ensure no code uses an API?

I want to ban use of iostreams in a code base I have (for various reasons). Is there a way I can inspect symbol files or force the compiler to emit an error when that API is used? 1:A simple approach is provide a dummy iostream implement

Empirical data on the effects of immutability?

Empirical data on the effects of immutability?

In class today, my professor was discussing how to structure a class. The course primarily uses Java and I have more Java experience than the teacher (he comes from a C++ background), so I mentioned that in Java one should favor immutabili