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

Convert string to title case with JavaScript

Convert string to title case with JavaScript

Is there a simple way to convert a string to title case? E.g. john smith becomes John Smith. I'm not looking for something complicated like John Resig's solution, just (hopefully) some kind of one- or two-liner. 1:Try this:function toTi

What is the most efficient method to groupby on a JavaScript array of objects?

What is the most efficient method to groupby on a JavaScript array of objects?

What is the most efficient way to groupby objects in an array?For example, given this array of objects:[ { Phase: "Phase 1", Step: "Step 1", Task: "Task 1", Value: "5" }, { Phase: "Phase 1", Step: "Step 1", Task: "Task 2", Value: "10

How do I perform the SQL Join equivalent in MongoDB?

How do I perform the SQL Join equivalent in MongoDB?

How do I perform the SQL Join equivalent in MongoDB?For example say you have two collections (users and comments) and I want to pull all the comments with pid=444 along with the user info for each. comments { uid:12345, pid:444, comment="b

Add table row in jQuery

Add table row in jQuery

What is the best method in jQuery to add an additional row to a table as the last row?Is this acceptable?$('#myTable').append('my datamore data');Are there limitations to what you can add to a table like this (suc

ROW_NUMBER() in MySQL

ROW_NUMBER() in MySQL

Is there a nice way in MySQL to replicate the SQL Server function ROW_NUMBER()?For example:SELECT col1, col2, ROW_NUMBER() OVER (PARTITION BY col1, col2 ORDER BY col3 DESC) AS intRowFROM Table1Then I could, for example, add a condit

Java: Adding fields and methods to existing Class?

Java: Adding fields and methods to existing Class?

Is there, in Java, a way to add some fields and methods to an existing class?What I want is that I have a class imported to my code, and I need to add some fields, derived from the existing fields, and their returning methods.Is there any w

What are the good Scala IDEs at the start of 2010?

What are the good Scala IDEs at the start of 2010?

I know this is an exact duplicate, but a year has gone by and Scala seems to be a fast moving thing, so I figure it might be acceptable to ask again:What is the best IDE for Scala development right now? 1:I know the Eclipse plugin is a w

Get a random number between 0.0200 and 0.120 (float numbers) [duplicate]

Get a random number between 0.0200 and 0.120 (float numbers) [duplicate]

This question already has an answer here: Generating random whole numbers in JavaScript in a specific range? 21 answers I need to create a random numbe

Can I get copy/paste functionality from a C# Console Window?

Can I get copy/paste functionality from a C# Console Window?

I am developing a console application in C#, and was wondering if there was a way to get the "copy-paste" or "mark-paste" functionality into my application, similar or identical to that of the standard Windows command prompt. Is this a wild

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

OpenShift webapps mysql java connection

OpenShift webapps mysql java connection

I have a JBoss EWS Tomcat 7 Java application on openshift, installed with the MySQL 5.5 and PhpMyAdmin 4.0 cartridges. I have copied the repository locally, and deleted the source folder. Instead, I simply have a compiled Java application,

SpriteKit: detect complete node overlap

SpriteKit: detect complete node overlap

I have two SKShapeNodes – one with an edge-based SKPhysicsBody, one volume-based – and I want to detect their intersection without collision. I've got this working fine, with the SKPhysicsContactDelegate contact methods getting called as on

How Do You Delete Duplicate Records In SQL

How Do You Delete Duplicate Records In SQL

How to delete duplicate records in sql? 1:In SQL Server 2005 and above:WITH q AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY dup_column ORDER BY dup_column) AS rn FROM mytable )DELETEFROM qWHERE rn

Writing memory of the traced process.

Writing memory of the traced process.

I am playing around with ptrace in linux. I am trying to write the memory of the traced process using /proc/pid/mem interface. the function I ma using for accomplish this task is :void write_proc(pid_t child, unsigned long int addr) { cha

Applying a angularjs filter after “Apply” button click

Applying a angularjs filter after “Apply” button click

I have a big list of data (4000+ items). When start typing - my browser freezes (up to 15 sec). So i need to turn off auto-filter feature, and bind filter function to the button click.Looking for answer via Google gave no results. How i can

How do I list and fetch remote branches after SVN to Git migration? [duplicate]

How do I list and fetch remote branches after SVN to Git migration? [duplicate]

This question already has an answer here: How do I migrate an SVN repository with history to a new Git repository? 32 answers I migrated our SVN repos

Receiving push notification even after the app is deleted iPhone

Receiving push notification even after the app is deleted iPhone

I implemented push notification in my app.It is working fine.Now the problem is even after i deleted my app from device it is getting the push notifications.So is there any way to unregister the app from push notification when it is delet

Get system command output in C program

Get system command output in C program

Is there a better way to do it?int numOfCPU;system("grep -c ^processor /proc/cpuinfo >> /tmp/cpuinfo");FILE *fp = fopen("/tmp/cpuinfo", "r");fscanf(fp, "%d", &numOfCPU);fclose(fp);system("rm /tmp/cpuinfo");I don't want to create an intermed

JAXB Marshalling with xmldsig Signature

JAXB Marshalling with xmldsig Signature

Is it possible to create jaxb marshaller which automatically adds digital signature to xml content. For example if I have a class which is defined:@[email protected](XmlAccessType.FIELD)public class Test { @XmlElement pri

Sharing audio file

Sharing audio file

I'm trying to make a button for sharing an audio file. This is not working. First I tried to send the file right from my raw folder without copying it to the card of the phone. That didn't solve my problem. The second thing I tried, is savi

Variable inside setTimeout says it is undefined, but when outside it is defined [duplicate]

Variable inside setTimeout says it is undefined, but when outside it is defined [duplicate]

This question already has an answer here: Pass correct “this” context to setTimeout callback? [duplicate] 5 answers I have a class. I need

Capistrano 'Bundle Not Found' Error During Deployment

Capistrano 'Bundle Not Found' Error During Deployment

When I run cap deploy:update I get the error below, indicating that bundle is not found. When I run echo $PATH from cap shell the /var/lib/gems/1.9.1/bin path which contains bundle is missing, however, this path is in both /etc/profile and

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

C# split, return key/value pairs in an array

C# split, return key/value pairs in an array

I'm new to C#, and thus am looking for layman's terms regarding this. Essentially, what I would like to do is turn: key1=val1|key2=val2|...|keyN=valN into a database array where, you guessed it, key1 returns val1, key2 returns val2, etc.