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

Why does parseInt yield NaN with Array#map?

Why does parseInt yield NaN with Array#map?

From the Mozilla Developer Network:[1,4,9].map(Math.sqrt)will yield:[1,2,3]Why then does this:['1','2','3'].map(parseInt)yield this:[1, NaN, NaN]I have tested in Firefox 3.0.1 and Chrome 0.3 and just as a disclaimer, I know this is not cros

Using a dispatch_once singleton model in Swift

Using a dispatch_once singleton model in Swift

I'm trying to work out an appropriate singleton model for usage in Swift. So far, I've been able to get a non-thread safe model working as:class var sharedInstance:TPScopeManager { get { struct Static { static var insta

Twitter Bootstrap - Print all tab content

Twitter Bootstrap - Print all tab content

I have the basic bootstrap tabs set up with no dynamically inserted content and print specific media queries in my base stylesheet. When the user prints from the browser I want all the tab content to print, not just the active tab. I know t

Angular routes contain #! in the url instead of # [duplicate]

Angular routes contain #! in the url instead of # [duplicate]

This question already has an answer here: angularjs 1.6.0 (latest now) routes not working 4 answers Recently I have noticed that when using ngRoute mod

UICollectionView VS UITableview

UICollectionView VS UITableview

I have an app which will show over a 1000 items, all of those item details are local ( saved via coredaata) and will ship with the app.In researching the UI mechanisms to show those items, I am in between choosing uicollectionview or tablev

C++ “Object” class

C++ “Object” class

In Java, there is a generic class called "Object", in which all classes are a subclass of. I am trying to make a linked list library (for a school project), and I have managed it to make it work for only one type, but not multiple, so is th

Python set with the ability to pop a random element

Python set with the ability to pop a random element

I am in need of a Python (2.7) object that functions like a set (fast insertion, deletion, and membership checking) but has the ability to return a random value. Previous questions asked on stackoverflow have answers that are things like:im

Why does the 2-tuple Functor instance only apply the function to the second element?

Why does the 2-tuple Functor instance only apply the function to the second element?

import Control.Applicativemain = print $ fmap (*2) (1,2)produces (1,4). I would expect it it to produce (2,4) but instead the function is applied only to the second element of the tuple.Update I've basically figured this out almost straight

How to properly compare decimal values in C#?

How to properly compare decimal values in C#?

I come from a background in C++, and I know that you cannot accurately compare floats for equality. For C#, I simply assumed the same policy applies to decimal values, or any floating point value in general.Basically, I have two decimal val

Is BIGINT(8) the largest integer mysql can store?

Is BIGINT(8) the largest integer mysql can store?

I've got some numbers that is now larger than INT can handle.This is a bit embarassing, but I honestly don't know exactly what the BIGINT(8) means. Is the 8 in that the max bit value or the max length?So BIGINT(1) can only be one digit? Or

WCF Error : Manual addressing is enabled on this factory, so all messages sent must be pre-addressed

WCF Error : Manual addressing is enabled on this factory, so all messages sent must be pre-addressed

I've got a hosted WCF service that I created a custom factory for, so that this would work with multiple host headers:/// /// Required for hosting where multiple host headers are present/// public class MultipleHostServiceFactory : ServiceH

Find a value and shows me database,table,column,primary key of the found value

Find a value and shows me database,table,column,primary key of the found value

Consider have a table like named : People| Id | Name | Code || 1 | John | 857 || 2 | Mike | 893 || 3 | Sara | 935 |this table is in PeopleDb Table.The question is :I want to find 'Mike' keyword.Situatio

automatic installation of common magento extensions at project kickoff

automatic installation of common magento extensions at project kickoff

There are some Magento Connect extensions that I find myself installing every time I create a new project, such as Fontis_Recaptcha, Mass_Product_Relater, HM_DeveloperToolbar, ModuleCreator, Alanstormdotcom_Layoutviewer, etc. What's on you

Monodroid Javascript Call-back

Monodroid Javascript Call-back

I'm trying to use monodroid with webkit to create an app. I am having a problem with letting the html page call a javascript method, which would be an interface to a method in my app. There is a tutorial on this at http://developer.android.

Lazy loading and lazy execution patterns

Lazy loading and lazy execution patterns

I'd like to get some feedback on a class I wrote for encapsulating the lazy-load pattern. Usually, when I do lazy-loading, it looks something like this:private SomeClass _someProperty;public SomeClass SomeProperty{ get { if(thi

Base URL in ASP.net Master Pages with virtual Directories

Base URL in ASP.net Master Pages with virtual Directories

I have an ASP.net master page. In this master, I have all my css and javascript files defined. I also have a few images and a few buttons and hyperlinks.All the urls are all declared as relative ie "/scripts/ian.js"Everything works fine if

See action bar across all activities - Android

See action bar across all activities - Android

In my main activity I have my action bar. How can this stay visible even if I launch a new activity?Does the new activity have to extend my main activity for this to work? 1:If you declare the onCreateOptionMenu method, wich is the one w

Can I use the Google Maps API to display a custom map?

Can I use the Google Maps API to display a custom map?

And by custom map I mean custom map tiles, as in, mapping another planet. I've looked all around but can't see to find any resources pointing how to do this on Google's or any website.I know it's possible because I've seen it done before on

How can I modify the entire ASP.NET page content right before it's output?

How can I modify the entire ASP.NET page content right before it's output?

I have a page that has a bunch of user controls on it. I want to be able to have "macros" or "placeholders" directly in the content that will get replaced in my code. It shouldn't really matter, but I'm using Ektron as my CMS.Are there an

Can SQLAlchemy automatically create relationships from a database schema?

Can SQLAlchemy automatically create relationships from a database schema?

Starting from an existing (SQLite) database with foreign keys, can SQLAlchemy automatically build relationships?SQLAlchemy classes are automatically created via __table_args__ = {'autoload': True}.The goal would be to easily access data fro

Exclude fields in Django admin for users other than superuser

Exclude fields in Django admin for users other than superuser

I have a simple MyUser class with PermissionsMixin. user.is_superuser equals True only for superusers. I'd like to be able to do something similar to this in my admin.py: if request.user.is_superuser: fieldsets = ( (Non

position legend of a stacked bar plot

position legend of a stacked bar plot

I am trying to create a stacked bar plot, but I cannot position the legend so that it does not overlap any of the bars. I have tried adjusting the margins, setting xlim, using a separate legend statement and searching here, all without suc

WKWebView full URL

WKWebView full URL

Is there a way to get the FULL URL loaded by a WKWebView for every request.webView:didFinishNavigation:Works only for mainFrame navigations and does not provide a url request parameter.How do I get the FULL URL just like in UIWebViewDelegat

Writing a portable C program - which things to consider?

Writing a portable C program - which things to consider?

For a project at university I need to extend an existing C application, which shall in the end run on a wide variety of commercial and non-commercial unix systems (FreeBSD, Solaris, AIX, etc.).Which things do I have to consider when I want