Reference member variables as class members

Reference member variables as class members

In my place of work I see this style used extensively:-#include using namespace std;class A{public: A(int& thing) : m_thing(thing) {} void printit() { cout Is there a name to describe this idiom? I am assuming it is to prevent the poss

Sublime Text 2 move cursor out of parenthesis, quotes, or brackets

Sublime Text 2 move cursor out of parenthesis, quotes, or brackets

I need a fast way to make the cursor jump outside the auto wrap qoutes or other syntax elements. I don't want to have to reach down to my arrow keys each time, and definitely don't want to go to my mouse.Is there a quick and easy way to so

Common programming mistakes in .Net when handling exceptions? [closed]

Common programming mistakes in .Net when handling exceptions? [closed]

What are some of the most common mistakes you've seen made when handling exceptions?It seems like exception handling can be one of the hardest things to learn how to do "right" in .Net. Especially considering the currently #1 ranked answer

UPDATE and REPLACE part of a string

UPDATE and REPLACE part of a string

I've got a table with two columns, ID and Value. I want to change a part of some strings in the second column.Example of Table:ID Value---------------------------------1 c:\temp\123\abc\1112 c:\temp\123\ab

python append list return none

python append list return none

I have the following code to generate a list of tuples:list_of_tuples = list()for name in list_of_names: temporary_list = [name] date = function_that_return_a_list #like ['2014', '01', '20'] temporary_list = temporary_list + d

Understanding the Fibonacci sequence

Understanding the Fibonacci sequence

I have an algorithm that I found online that calculates the Fibonacci sequence. I feel a bit like a fool but I have no idea how it works! def fib(n) if n == 0 || n == 1 return n end if n >= 2 return fib(n-1) + fib(n-2) end endIf I

Reflection in Windows Universal Apps

Reflection in Windows Universal Apps

I need to use the GetProperties method so I can test whether any properties in a particular class has a specified custom attribute. However it doesn't appear as though Windows Universal Apps supports this:obj.GetType().GetProperties()Raises

want to remove action name from url CakePHP

want to remove action name from url CakePHP

i am working on a Cakephp 2.x.. i want to remove the action or controller name from url ... for example i am facing a problem is like that i have a function name index on my Messages controller in which all the mobile numbers are displayin

TypeError: 'int' object is not subscriptable

TypeError: 'int' object is not subscriptable

Why does this code snippet result in: TypeError 'int' object is not subscriptable?return (bin(int(hexdata)[2:].zfill(16)))hexdata is a hexadecimal string. For example, it may be 0x0101. 1:You're doing this:>>> int('1234')[2:]Traceback (m

R: Differences by group and adding

R: Differences by group and adding

I would like to know how to do this operation simpler.Imagine I have a data.frame like this one:set.seed(1)ID I' would like to get, for each column, the increments (differences between two consecutive elements) by groups of ID. Keeping the

How do I pass a function as parameter?

How do I pass a function as parameter?

What is the fastest and shortest way to pass a function as parameter of another function without using other libraries other than the std one in just one line?I mean let's say we have a function forloop(int x, *) {...} that run a for loop f

How do you pass parameters containing spaces in vbs

How do you pass parameters containing spaces in vbs

I have a batch script:test.batecho first arg is %1pauseThat I want to invoke from a vbscript with admin rights like so:test.vbsSet UAC = CreateObject("Shell.Application")UAC.ShellExecute "test.bat", "argument", "", "runas", 1This works ok b

Convert Double into 8-bytes array

Convert Double into 8-bytes array

I want to convert a Double variable into an 8-bytes array, this is what I've come with so far:Dim b(0 To 7) As ByteDim i As Integerdim d as doubled = 1 ' for simplicity, I sit the variable "d" to 1For i = 0 To 7 Call CopyMemor

Access xaml control inside ith item in flipview

Access xaml control inside ith item in flipview

I have a flipview which is populated by some code (I don't understand how modifying an app). From the textblock named "FeedUrl" I want to extract the u

Evaluating expressions consisting of elementwise matrix operations in Thrust

Evaluating expressions consisting of elementwise matrix operations in Thrust

I would like to use Thrust to evaluate expressions consisting of elementwise matrix operations. To make it clear, let us consider an expression like:D=A*B+3*sin(C)where A, B, C and D are matrices, of course of the same size.The Thrust Quick

How flatMap API contract transforms Optional input to Non Optional result?

How flatMap API contract transforms Optional input to Non Optional result?

This is the contract of flatMap in Swift 3.0.2public struct Array : RandomAccessCollection, MutableCollection { public func flatMap(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult]}If I take an Array of [S

Python Flask — URL Encoded Leading Slashes causing 404 or 405

Python Flask — URL Encoded Leading Slashes causing 404 or 405

My application frequently takes URL encoded strings as a URL parameter. Often these strings look like paths with a leading slash. IE /file/foo. In flask, I have an endpoint that takes a path parameter that I send a URL encoded path to. So I

How to use R for same field aggregation by multiple separate group

How to use R for same field aggregation by multiple separate group

I'm trying to perform count of an indicator on several (actually hundreds) groups separately (NOT on all combinations of all groups). I'll demonstrate it by simplified example:Assume I have that dataset data data [,1] [,2] [,3][1,]

Unable to compile an existing project because Compass can't find it

Unable to compile an existing project because Compass can't find it

I just installed the foundation in my application base directory by executing the following command:compass create myprojectname -r zurb-foundation --using foundationNow I have open the sass/_settings.scss file and I have un-comment the 66t

R: Gephi: manipulating dataframe to use with write.gexf

R: Gephi: manipulating dataframe to use with write.gexf

I am trying to manipulate a data frame. As an example: say I have a dataframe containing customers and the shops they visit:df = data.frame(customers = c("a", "b", "b", "c", "c"), shop_visited = c("X", "X", "Y", "X", "Z"

Load image into memory immediately

Load image into memory immediately

I need to open all frames from Tiff image in WPF into memory and then delete the source. And after that I eventually need to render that image (resized according to window size). My solution is quite slow and I cannot delete file source bef

R: rename subset of variables in data frame

R: rename subset of variables in data frame

I'm renaming the majority of the variables in a data frame and I'm not really impressed with my method.Therefore, does anyone on SO have a smarter or faster way then the one presented below using only base? data(mtcars) # head(mtcars)

How to get string list of Enum descriptions? [duplicate]

How to get string list of Enum descriptions? [duplicate]

Possible Duplicate: Enum ToString How can I get a List of an Enum's values?For example, I have the following:public enum ContactSubjects{ [Description("General Question")] General, [Description("Availability/Reservation")] Res

M.Map sudden expected type error

M.Map sudden expected type error

Everything was working great up until about a month or so ago...Suddenly I'm getting berkson.github.io/source/blog.hs: 333, 42 • Couldn't match type ‘unordered-containers-0.2.7.1:Data.HashMap.Base.HashMap text-1.2.2

Assign multiple functions to a single variable?

Assign multiple functions to a single variable?

In Python we can assign a function to a variable. For example, the math.sine function:sin = math.sinrad = math.radiansprint sin(rad(my_number_in_degrees))Is there any easy way of assigning multiple functions (ie, a function of a function) t