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

What is an optional value in Swift?

What is an optional value in Swift?

From Apple's documentation: You can use if and let together to work with values that might be missing. These values are represented as optionals. An optional value either contains a value or contains nil to indicate that the value is missi

Need a minimal Django file upload example [closed]

Need a minimal Django file upload example [closed]

As a newbie to Django, I am having difficulty making an upload app in Django 1.3. I could not find any up-to-date example/snippets. May someone post a minimal but complete (Model, View, Template) example code to do so? 1:Phew, Django doc

How to get innerHTML of DOMNode?

How to get innerHTML of DOMNode?

What function do you use to get innerHTML of a given DOMNode in the PHP DOM implementation? Can someone give reliable solution? Of course outerHTML will do too. 1:Compare this updated variant with PHP Manual User Note #89718:<?php functi

await vs Task.Wait - Deadlock?

await vs Task.Wait - Deadlock?

I don't quite understand the difference between Task.Wait and await.I have something similar to the following functions in a ASP.NET WebAPI service:public class TestController : ApiController{ public static async Task Foo() {

How do I get the last inserted ID of a MySQL table in PHP?

How do I get the last inserted ID of a MySQL table in PHP?

I have a table into which new data is frequently inserted. I need to get the very last ID of the table. How can I do this?Is it similar to SELECT MAX(id) FROM table? 1:If you're using PDO, use PDO::lastInsertId.If you're using Mysqli, us

Question Mark in JavaScript

Question Mark in JavaScript

I came across the following linehsb.s = max != 0 ? 255 * delta / max : 0;What do the ? and : mean in this context? 1:It is called the Conditional Operator (which is a ternary operator).It has the form of: condition ? value-if-true : valu

Is there a pattern for initializing objects created via a DI container

Is there a pattern for initializing objects created via a DI container

I am trying to get Unity to manage the creation of my objects and I want to have some initialization parameters that are not known until run-time:At the moment the only way I could think of the way to do it is to have an Init method on the

Turning query errors to Exceptions in MySQLi

Turning query errors to Exceptions in MySQLi

I'm trying to turn MySQLi query errors to Exceptions, but couldn't - mysqli_sql_exception is thrown only if it failed to connect the DB.I used mysqli_report(MYSQLI_REPORT_STRICT) and procedural MySQLi functions embedded to custom wrapper cl

Remove duplicates from an array of objects in JavaScript

Remove duplicates from an array of objects in JavaScript

I have an object that contains an array of objects.things = new Object();things.thing = new Array();things.thing.push({place:"here",name:"stuff"});things.thing.push({place:"there",name:"morestuff"});things.thing.push({place:"there",name:"mo

How do I get current datetime on the Windows command line, in a suitable format for using in a filen

How do I get current datetime on the Windows command line, in a suitable format for using in a filen

Update: Now that it's 2016 I'd use PowerShell for this unless there's a really compelling backwards-compatible reason for it, particularly because of the regional settings issue with using date. See @npocmaka's https://stackoverflow.com/a/1

How to solve java.lang.NoClassDefFoundError?

How to solve java.lang.NoClassDefFoundError?

I've tried both the example in Oracle's Java Tutorials. They both compile fine, but at run-time, both come up with this error:Exception in thread "main" java.lang.NoClassDefFoundError: graphics/shapes/Square at Main.main(Main.java:7)Caus

Exception Breakpoint in Xcode

Exception Breakpoint in Xcode

How to add Exception Breakpoint in Xcode?int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); [pool release]; return r

Chrome Extension Message passing: response not sent

Chrome Extension Message passing: response not sent

I am trying to pass messages between content script and the extensionHere is what I have in content-scriptchrome.runtime.sendMessage({type: "getUrls"}, function(response) { console.log(response)});And in the background script I havechrome.

PreparedStatement IN clause alternatives?

PreparedStatement IN clause alternatives?

What are the best workarounds for using a SQL IN clause with instances of java.sql.PreparedStatement, which is not supported for multiple values due to SQL injection attack security issues: One ? placeholder represents one value, rather tha

Subscript indices must either be real positive integers or logicals, generic solution

Subscript indices must either be real positive integers or logicals, generic solution

The following error occurs quite frequently: Subscript indices must either be real positive integers or logicalsI have found many questions about this but not one with a really generic answer. Hence I would like to have the general solutio

Creating a Blob from a base64 string in JavaScript

Creating a Blob from a base64 string in JavaScript

I have base64-encoded binary data in a string.var contentType = 'image/png';var b64Data = 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';I would like to create a blob:

What is the “-->” operator in C++?

What is the “-->” operator in C++?

After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that the following snippet compiled and worked in both Visual Studio 2008 and G++ 4.4.Here's the code:#include int mai

Why is “using namespace std” considered bad practice?

Why is “using namespace std” considered bad practice?

I've been told by others that writing using namespace std in code is wrong, and that I should use std::cout and std::cin directly instead.Why is using namespace std considered a bad practice? Is it inefficient or does it risk declaring ambi

Calculate timespan in JavaScript

Calculate timespan in JavaScript

I have a .net 2.0 ascx control with a start time and end time textboxes. The data is as follows: txtStart.Text = 09/19/2008 07:00:00txtEnd.Text = 09/19/2008 05:00:00I would like to calculate the total time (hours and minutes) in JavaScript

what is the basic difference between jobconf and job?

what is the basic difference between jobconf and job?

hi i wanted to know the basic difference between jobconf and job objects,currently i am submitting my job like thisJobClient.runJob(jobconf);i saw other way of submitting jobs like thisConfiguration conf = getConf();Job job = new Job(conf,

Where is Button.DialogResult in WPF?

Where is Button.DialogResult in WPF?

In System.Windows.Forms.Button there is a property DialogResult, where is this property in the System.Windows.Controls.Button (WPF)? 1:There is no built-in Button.DialogResult, but you can create your own (if you like) using a simple att

Truncate a decimal value in Python

Truncate a decimal value in Python

I am trying to truncate a decimal value in Python. I don't want to round it, but instead just display the decimal values upto the specified accuracy. I tried the following:d = 0.989434'{:.{prec}f}'.format(d, prec=2)This rounds it to 0.99. B

Why do partial methods have to be void?

Why do partial methods have to be void?

I am currently learning C# with the book called Beginning Visual C# 2010 and I am in the chapter that discusses different aspects and characteristics of partial methods and classes.To quote the book: Consider at this point why partial meth

Python 2.5 dictionary 2 key sort

Python 2.5 dictionary 2 key sort

I have a dictionary of 200,000 items (the keys are strings and the values are integers).What is the best/most pythonic way to print the items sorted by descending value then ascending key (i.e. a 2 key sort)? a={ 'keyC':1, 'keyB':2, 'keyA':