In what cases do I use malloc vs new?

In what cases do I use malloc vs new?

I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the new operator you should pair with delete and it is a mistake to mix the two (e.g. Calling fr

What causes java.lang.IncompatibleClassChangeError?

What causes java.lang.IncompatibleClassChangeError?

I'm packaging a Java library as a JAR, and it's throwing many java.lang.IncompatibleClassChangeErrors when I try to invoke methods from it. These errors seem to appear at random. What kinds of problems could be causing this error? 1:This

Relative imports in Python 3

Relative imports in Python 3

I want to import a function from another file in the same directory.Sometimes it works for me with from .mymodule import myfunction but sometimes I get a:SystemError: Parent module '' not loaded, cannot perform relative importSometimes it w

Create ArrayList from array

Create ArrayList from array

I have an array that is initialized like:Element[] array = {new Element(1), new Element(2), new Element(3)};I would like to convert this array into an object of the ArrayList class.ArrayList arraylist = ???; 1:new ArrayList<>(Ar

Is there a cross-browser onload event when clicking the back button?

Is there a cross-browser onload event when clicking the back button?

For all major browsers (except IE), the JavaScript onload event doesn’t fire when the page loads as a result of a back button operation — it only fires when the page is first loaded.Can someone point me at some sample cross-browser code (Fi

Escaping HTML strings with jQuery

Escaping HTML strings with jQuery

Does anyone know of an easy way to escape HTML from strings in jQuery? I need to be able to pass an arbitrary string and have it properly escaped for display in an HTML page (preventing JavaScript/HTML injection attacks). I'm sure it's po

How do I set up NSZombieEnabled in Xcode 4?

How do I set up NSZombieEnabled in Xcode 4?

How do I set up NSZombieEnabled and CFZombieLevel for my executable in Xcode 4? 1:In Xcode 4.x press ⌥⌘R(or click Menubar > Product > Scheme > Edit Scheme) select the "Diagnostics" tab and click "Enable Zombie Objects": This turns releas

What is the difference between visibility:hidden and display:none?

What is the difference between visibility:hidden and display:none?

The CSS rules visibility:hidden and display:none both result in the element not being visible. Are these synonyms? 1:display:none means that the tag in question will not appear on the page at all (although you can still interact with it

How to pass objects to functions in C++?

How to pass objects to functions in C++?

I am new to C++ programming, but I have experience in Java. I need guidance on how to pass objects to functions in C++.Do I need to pass pointers, references, or non-pointer and non-reference values? I remember in Java there are no such iss

In jQuery, how to attach events to dynamic html elements? [duplicate]

In jQuery, how to attach events to dynamic html elements? [duplicate]

This question already has an answer here: Event binding on dynamically created elements? 19 answers Suppose I have some jQuery code that attaches an ev

Why does Date.parse give incorrect results?

Why does Date.parse give incorrect results?

Case One:new Date(Date.parse("Jul 8, 2005"));Output:Fri Jul 08 2005 00:00:00 GMT-0700 (PST)Case Two:new Date(Date.parse("2005-07-08"));Output:Thu Jul 07 2005 17:00:00 GMT-0700 (PST)Why is the second parse incorrect? 1:Until the 5th editi

Scanner is skipping nextLine() after using next() or nextFoo()?

Scanner is skipping nextLine() after using next() or nextFoo()?

I am using the Scanner methods nextInt() and nextLine() for reading input. It looks like this:System.out.println("Enter numerical value"); int option;option = input.nextInt(); // Read numerical value from inputSystem.out.println("Enter 1

Twitter Bootstrap tab shown event not firing on page load

Twitter Bootstrap tab shown event not firing on page load

In a page where I have n tabs, and the following script (coffeescript, I checked the compiled javascript and it seems to be ok)...$ -> init()init = -> $('a[data-toggle="tab"]').on 'shown', (event) -> shown = event.target

iOS : Could not build module

iOS : Could not build module

I've got Library from another team. I'm trying to use library in our project and while do so getting an error Could not build module 'Common Library' (name of framework)Below are solutions that I worked on but didn't helped :1. Delete Deriv

Is there no standard (Either a) monad instance?

Is there no standard (Either a) monad instance?

I was under the impression that there was an instance for Either a somewhere, but I can't seem to find it. I have tried importing Control.Monad, Control.Monad.Instances and Data.Either as shownmodule Main whereimport Control.Monadimport Dat

How to let SQL Server know not to use Cache in Queries?

How to let SQL Server know not to use Cache in Queries?

Just a general question:Is there a query/command I can pass to SQL Server not to use cache when executing a particularly query?I am looking for a query/command that I can set rather than a configuration setting. Is there no need to do this?

Mathematical expression in axis label

Mathematical expression in axis label

In R, I use expression(theta[l]) so that the label of my plot axis is that same as $\theta_l$ from LaTeX. For esthetic reasons, I'd rather like to display $\theta_\ell$. Can you help me?EDITBefore, I didplot(1:10, 1:10, xlab=expression(thet

Run JavaScript function when the DOM is “ready”?

Run JavaScript function when the DOM is “ready”?

I'm using a JavaScript upload script that says to run the initialize function as soon as the DOM is ready. I currently have it working just fine with either a call to the function with body.onload or directly after the function is defined.

suppress instance method override linker warning framework xcode

suppress instance method override linker warning framework xcode

I have a library that started throwing a couple linker warnings under XCode 4.4. The warnings are along the lines of "ld: warning: instance method 'methodName:' in category from overrides method from class in "The framework still work fine

Is there a bug in Ruby lookbehind assertions (1.9/2.0)?

Is there a bug in Ruby lookbehind assertions (1.9/2.0)?

Why doesn't the regex (? match foo (whereas (? does)?"foo" =~ /(? 1"foo" =~ /(? nilThis only seems to happen with singleline mode turned on (dot matches newline); without it, everything is OK:"foo" =~ /(? 1"foo" =~ /(? 2Tested on Ruby 1.9.3

Set default value on Datetime field in symfony2 form

Set default value on Datetime field in symfony2 form

I have a form containing several fields. One of them is a Datetime field. How to define a default value for that field? I've tried setting a value on the related entity, in controller, in constructor and __construct :$myEntity = new MyEntit

Play SoundCloud Track

Play SoundCloud Track

can i play a track from SoundCloud in my android app? I'm trying this code but it doesn't works: String res = "https://api.soundcloud.com/tracks/84973999/stream?client_id=cd9d2e5604410d714e32642a4ec0eed4";MediaPlayer mp = new MediaPlayer();

“Masking” an animation? iPhone SDK

“Masking” an animation? iPhone SDK

I have been looking into ways of masking images on the iPhone. I came across this solution http://iosdevelopertips.com/cocoa/how-to-mask-an-image.htmlwhich works great for still images. What I want to do is mask an animation in a UIImageVie

strcat implementation

strcat implementation

I tried to implement the strcat by myself, and I found the strcat implementation from Wiki like this......but when I use it, there is segmentation fault.What's wrong with the code below?char *strcat(char *dest, const char *src){ size_t i

More button in UILabel like in AppStore any app description

More button in UILabel like in AppStore any app description

I have a description of myObject and i show it in UILabel. I want to add 'More' button to my UILabel if a description is too long. On Github i have found TTTAttributedLabel which allows to use hyperlinks. The question is, is there some spe