Creating a byte array from a stream

Creating a byte array from a stream

What is the prefered method for creating a byte array from an input stream? Here is my current solution with .NET 3.5. Stream s;byte[] b;using (BinaryReader br = new BinaryReader(s)){ b = br.ReadBytes((int)s.Length);}Is it still a better

How to install JDBC driver in Eclipse web project without facing java.lang.ClassNotFoundexception

How to install JDBC driver in Eclipse web project without facing java.lang.ClassNotFoundexception

There is a VERY similar question to mine but in my case I don't have any duplicate jars in my build path, so the solution does not work for me. I've searched google for a couple of hours now, but none of the solutions I've found there actu

Specifically, what's dangerous about casting the result of malloc?

Specifically, what's dangerous about casting the result of malloc?

Now before people start marking this a dup, I've read all the following, none of which provide the answer I'm looking for:C FAQ: What's wrong with casting malloc's return value?SO: Should I explicitly cast malloc()’s return value?SO: Needle

How do I parse command line arguments in Bash?

How do I parse command line arguments in Bash?

Say, I have a script that gets called with this line:./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFileor this one:./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile What's the accepted way of parsing this such that in eac

Encrypt and decrypt a string in C#?

Encrypt and decrypt a string in C#?

How can I encrypt and decrypt a string in C#? 1:EDIT 2013-Oct: Although I've edited this answer over time to address shortcomings, please see jbtule's answer for a more robust, informed solution.https://stackoverflow.com/a/10366194/18847

temporary lifetime in range-for expression

temporary lifetime in range-for expression

Consider a simple class A that can be used as a range:struct A { ~A() { std::cout << "~A "; } const char* begin() const { std::cout << "A::begin "; return s.data(); } const char* end() const { std::cout

XE4: How to change exe output name base on platform?

XE4: How to change exe output name base on platform?

Simply I need output executable names like MyApp32.exe and MyApp64.exe after compiling my project in Delphi XE4.I found a directive in the forum which is {$LIBSUFFIX '32'} but it seems it is only for dlls.Any suggestions for executable file

PyDev for Eclipse - Resolve Python dependencies (unresolved imports)

PyDev for Eclipse - Resolve Python dependencies (unresolved imports)

I am using PyDev for Eclipse as my IDE and pip as my package management tool, running virtualenv. Every time I want to use/include some new libraries or new dependencies in my project, I add them into the pip-requires file. The dependencies

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

How to view complete commits when tracking history of a single file in Git?

How to view complete commits when tracking history of a single file in Git?

I have a Git repository with about a two years of history in it. I have single file in it, for which I wish to find all the commits, and for each commit: all the other files that were committed in it. Let's assume this file is named file.tx

What should the return type be when the function might not have a value to return?

What should the return type be when the function might not have a value to return?

In the old days, you might have a function like this:const char* find_response(const char* const id) const;If the item could not be found, then a null could be returned to indicate the fact, otherwise obviously return the relevant string.Bu

Reachability and IPv6

Reachability and IPv6

One of my project uses the Apple's Reachability class in order to be monitor the network state and be notified in case of changes.After reading this article about supporting IPv6 I was wondering if were to be made to this class to make it w

std::bind lose reference when delivered as rvalue reference

std::bind lose reference when delivered as rvalue reference

I have the following code:#include #include template auto callback(T&& func) ->decltype(func()){ return func();}double test(double& value){ value=value+1.0; return value;}int main(void){ double t=1.0; printf("%f\n",t); tes

What is the difference between is_trivially_copyable and is_trivially_copy_constructible?

What is the difference between is_trivially_copyable and is_trivially_copy_constructible?

When would these give a different answer, and when would this difference be useful, if at all? 1:The former tests for the trivially copyable property, which in few words means that the type is memcpy-safe. A trivially copyable class is

Is AnkhSVN any good?

Is AnkhSVN any good?

I asked a couple of coworkers about AnkhSVN and neither one of them was happy with it. One of them went as far as saying that AnkhSVN has messed up his devenv several times.What's your experience with AnkhSVN? I really miss having an IDE in

A .bat File, “Call” or Not to “Call”, That is the

A .bat File, “Call” or Not to “Call”, That is the

If from inside a bat file you called another batch file but still had a few remaining operations to complete, how can you make sure that the call to first bat file will after completion or error, will return to the file that called it in th

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

Upload Laravel 5 to server subfolder

Upload Laravel 5 to server subfolder

I am trying to upload Laravel 5 project to subfolder as: public_html/project/ I have changed in index.php require __DIR__.'/../project/bootstrap/autoload.php';$app = require_once __DIR__.'/../project/bootstrap/app.php';in config/app.p

Different Connection Strings with Entity Framework based on Context

Different Connection Strings with Entity Framework based on Context

I have a web forms application that uses entity framework, the application is deployed on a development box, my local machine and a production box. Each of these have different connection strings.What is the best way of handling this.I use

How to modify Expander button background only? WPF

How to modify Expander button background only? WPF

I have an Expander placed on a window with a blue background and I would like to make the button for the expander another color than the default (blue, which it is receiving from the window). When I modify the background property of the ex

AF_NETLINK (netlink) sockets using boost::asio

AF_NETLINK (netlink) sockets using boost::asio

I'm writing multicast client/server application based on this and this; which work great.However, I would also need to do something when the number of active network interfaces in the computer changes, something like what the program in the

Customise the look of the Chrome web inspector

Customise the look of the Chrome web inspector

I've grown tired of the multitude of issues I seem to hit on a daily basis with Firefox and I'm trying once again to switch to Chrome.One of the things that frustrates me is the layout of the tabs in the inspector. In firebug they are all a

java outOfMemoryError with stringbuilder

java outOfMemoryError with stringbuilder

I'm getting a java outOfMemoryError when I call this method - i'm using it in a loop to parse many large files in sequence. my guess is that result.toString() is not getting garbage collected properly during the loop. if so, how should i fi

How do I get a Java resource as a File?

How do I get a Java resource as a File?

I have to read a file containing a list of strings. I'm trying to follow the advice in this post. Both solutions require using FileUtils.readLines, but use a String, not a File as the parameter.Set lines = new HashSet(FileUtils.readLines("

Generate page numbers using javascript/jquery?

Generate page numbers using javascript/jquery?

How to generate page numbers like the below using javascript/jquery?If the 5 th page is selected i have to show 3,4 and 6,7 and also 1,last page with prev,next...Any suggestion....EDIT:How to work with json data that use these pagination di