What are the differences between type() and isinstance()?

What are the differences between type() and isinstance()?

What are the differences between these two code fragments?Using type():import typesif type(a) is types.DictType: do_something()if type(b) in types.StringTypes: do_something_else()Using isinstance():if isinstance(a, dict): do_someth

Are global variables in PHP considered bad practice? If so, why?

Are global variables in PHP considered bad practice? If so, why?

function foo () { global $var; // rest of code}In my small PHP projects I usually go the procedural way. I generally have a variable that contains the system configuration, and when I nead to access this variable in a function, I do g

What's the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?

What's the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?

I know that the >= operator means more than or equal to, but I've seen => in some source code. What's the meaning of that operator?Here's the code:promiseTargetFile(fpParams, aSkipPrompt, relatedURI).then(aDialogAccepted => { if (!aDia

mysqli_free_result necessary?

mysqli_free_result necessary?

I was looking through my code and read that it was recommened to use mysqli_free_result when your result object is not needed anymore. But after seeing that each query is outputed to the $result variable repeatedly throughout the script, I

Implementing the command pattern

Implementing the command pattern

I am in the design process of an application, and I would like to use the command pattern for undo/redo purposes. I did some research into the command pattern but the only thing I don't get is: Should a command have the undo and redo method

visual studio right click missing find all refences and go to definition disabled

visual studio right click missing find all refences and go to definition disabled

I am using Visual Studio 2010, suddenly from right click menu Go to Defination option is disabled and even F12 does not work. Find all referneces option is missing from the menu... i use them a lot, how can I get them work 1:I had the

How to emulate a BEFORE INSERT trigger in T-SQL / SQL Server for super/subtype (Inheritance) entitie

How to emulate a BEFORE INSERT trigger in T-SQL / SQL Server for super/subtype (Inheritance) entitie

This is on Azure.I have a supertype entity and several subtype entities, the latter of which needs to obtain their foreign keys from the primary key of the super type entity on each insert. In Oracle, I use a BEFORE INSERT trigger to accomp

C++ inconsistency between gcc and clang

C++ inconsistency between gcc and clang

I came across a C++ inconsistency between gcc (versions 4.8.1, 4.8.2) and clang (versions 3.3, 3.4). I wonder which one is correct. Here's the program:template struct Result {};template struct Empty {};template struct Bad_Type_Fcn { ty

Setting a 's display as table-cell

Setting a 's display as table-cell

I'm trying to set a button's display property as table-cell but it doesn't behave like one. Any help would be appreciated. jsFiddle Demo (The demo contains a fixed container height, but I need it to work without it).No fixed sizes Demo.DOM:

How do you determine a processing time in Python?

How do you determine a processing time in Python?

I'm new to Python, and confused by the date/time documentation. I want to compute the time that it takes to perform a computation.In java, I would write:long timeBefore = System.currentTimeMillis();doStuff();long timeAfter = System.current

Isotope: combination filtering + multiple selection

Isotope: combination filtering + multiple selection

To all jQuery heros out there, I need help! (again) I found similar questions to mine on the internet but there were no answers so far :-/I want to filter a bunch of items with jquery isotope. I adapted the combination filter example from t

iPhone What happens to previous data when app is upgraded to new version

iPhone What happens to previous data when app is upgraded to new version

I have a query regarding What happens to previous data when app is upgraded to new version .I have a current application having a local database.The user can modify the database.Now If I upgrade the application to next version with some new

Implement Airplay Software Receiver in Android OS

Implement Airplay Software Receiver in Android OS

Can we develop any app in Android which will play a role of Airplay Receiver? Following provides support for MAC and Windows desktop version now. http://www.airsquirrels.com/reflector/I found a similar question with no reply. How can I make

Restrict WCF Web Service functionality based on User Group

Restrict WCF Web Service functionality based on User Group

I have a WCF Web Service which is consuming by C# client application. I’m also having 4 groups stored in Active Directory. Client application is passing user credentials to connect this web service.Web service exposing multiple APIs or Meth

How can I make external code 'safe' to run? Just ban eval()?

How can I make external code 'safe' to run? Just ban eval()?

I'd like to be able to allow community members to supply their own javascript code for others to use, because the users' imaginations are collectively far greater than anything I could think of.But this raises the inherent question of secur

Simplest way to play mp3 from Visual C++

Simplest way to play mp3 from Visual C++

A few years back, I wrote some util library around DShow/DSound to let me play MP3s in a Windows C++ application. Is that still the normal way to do it in a C++/MFC app, or is that an area of DirectX that has been subsumed into the general

How to Automate Mouse scrolling event in Selenium IDE

How to Automate Mouse scrolling event in Selenium IDE

I am trying to capture/automate mouse scrolling event in selenium IDE.Like in Facebook friend list page, we have to scroll to the end to list all friends.I want to automate that functionality using Selenium IDE .What i have done : with

React: leave the contents of a component alone

React: leave the contents of a component alone

Is it possible to have React ignore a subtree? i.e., don't compare or update it?My use case is migrating to React. Re-writing all our Handlebars templates at once isn't feasible, but if we could use our existing templates for some subcompon

destructors in Qt4

destructors in Qt4

I'm very confused about using destructors in Qt4 and hope, you guys can help me.When I have a method like this (with "Des" is a class):void Widget::create() { Des *test = new Des; test->show();}how can I make sure that this widget is

Celery Task Chain and Accessing **kwargs

Celery Task Chain and Accessing **kwargs

I have a situation similar to the one outlined here, except that instead of chaining tasks with multiple arguments, I want to chain tasks that return a dictionary with multiple entries. This is -- very loosely and abstractly --- what I'm t

ASP.NET MVC 2 - HTML.EditorFor() and Custom EditorTemplates

ASP.NET MVC 2 - HTML.EditorFor() and Custom EditorTemplates

With MVC 2's addition of the HtmlHelper EditorFor() it is not possible to create strongly typed Display and Editor templates for a given Model object and after fiddling with it I am a bit stumped as to how to pass additional Model data to t

Rails model “before_filter”?

Rails model “before_filter”?

I know that before_filter is only for controllers in Rails, but I would like something like this for a model: any time a method in my model is called, I'd like to run a method that determines whether the called method should run. Conceptual

Duplicate symbol: Include static lib A in static lib B, also include lib A and B in XCode Project

Duplicate symbol: Include static lib A in static lib B, also include lib A and B in XCode Project

I've been trying to build up a set of reusable libraries for app development, but I'm starting to run into a problem.One of my static libs is a set of general use methods (categories on Objective-C Foundation classes to improve their usabil

Is it possible to organize c++ header and cpp files?

Is it possible to organize c++ header and cpp files?

I'm not sure if i'm asking a valid question, but here goes.I have c++ solution with a structure of[folder] Header files -... 200 header files ..[folder] Source files -... 200 soure files ..... restIs it possible to organize header and soure

How to Create “Add to Calendar” Link on Web Page for iPhone

How to Create “Add to Calendar” Link on Web Page for iPhone

Many calendaring programs (Outlook, iCal) support vCal for downloading event information and adding it to your calendar. Others can use the vCalendar microformat to extract data. Neither of these, however, seems to be supported on the iPhon