Questions

Bytes of a string in Java

In Java, if I have a String `x`, how can I calculate the number of bytes in that string?

7 Feb at 17:7

Java switch statement: Constant expression required, but it IS constant

So, I am working on this class that has a few static constants: ``` public abstract class Foo { ... public static final int BAR; public static final int BAZ; public static final int B...

30 Sep at 03:2

"A project with an Output type of Class Library cannot be started directly"

I downloaded a C# project and I wish to debug the project to see how an algorithm implementation works. The project has come in a Folder, inside this folder there are - 1. .sln file and 2. a folder...

5 Nov at 01:29

Convert XML String to Object

I am receiving XML strings over a socket, and would like to convert these to C# objects. The messages are of the form: ``` <msg> <id>1</id> <action>stop</action> </msg> ``` How can this be done...

16 Jun at 17:13

ToList()-- does it create a new list?

Let's say I have a class ``` public class MyObject { public int SimpleInt{get;set;} } ``` And I have a `List<MyObject>`, and I `ToList()` it and then change one of the `SimpleInt`, will my chang...

7 May at 11:48

How to initialize std::vector from C-style array?

What is the cheapest way to initialize a `std::vector` from a C-style array? Example: In the following class, I have a `vector`, but due to outside restrictions, the data will be passed in as C-style...

9 Mar at 18:57

What exactly does the .join() method do?

I'm pretty new to Python and am completely confused by `.join()` which I have read is the preferred method for concatenating strings. I tried: ``` strid = repr(595) print array.array('c', random.sam...

20 Nov at 03:20

Which is faster: multiple single INSERTs or one multiple-row INSERT?

I am trying to optimize one part of my code that inserts data into MySQL. Should I chain INSERTs to make one huge multiple-row INSERT or are multiple separate INSERTs faster?

29 Apr at 13:56

CSS How to set div height 100% minus nPx

I have a wrapper div which contans 2 divs next to each other. Above this container I have a div that contains my header. The wrapper div must be 100% minus the height of the header. The header is abou...

28 Jul at 08:50

How should I use Outlook to send code snippets?

As a programmer at a big corporation, I frequently send Outlook emails that contain code samples. I'll actually type code directly into an email. This inevitably causes problems, as Outlook really l...

2 Oct at 18:6

CSS Div stretch 100% page height

I have a navigation bar on the left hand side of my page, and I want it to stretch to 100% of the page height. Not just the height of the viewport, but including the areas hidden until you scroll. I d...

3 Apr at 05:50

How to initialize static variables

I have this code: ``` private static $dates = array( 'start' => mktime( 0, 0, 0, 7, 30, 2009), // Start date 'end' => mktime( 0, 0, 0, 8, 2, 2009), // End date 'close' => mktime(23, ...

12 May at 17:18

Catch paste input

I'm looking for a way to sanitize input that I paste into the browser, is this possible to do with jQuery? I've managed to come up with this so far: ``` $(this).live(pasteEventName, function(e) { /...

2 Jan at 17:5

Search for all occurrences of a string in a mysql database

I'm trying to figure out how to locate all occurrences of a url in a database. I want to search all tables and all fields. But I have no idea where to start or if it's even possible.

20 Mar at 01:58

Is there a replacement for unistd.h for Windows (Visual C)?

I'm porting a relatively simple console program written for Unix to the Windows platform ([Visual C++ 8.0](http://en.wikipedia.org/wiki/Visual_C++#32-bit_versions)). All the source files include "unis...

11 Aug at 21:48

Converting XML to JSON using Python?

I've seen a fair share of ungainly XML->JSON code on the web, and having interacted with Stack's users for a bit, I'm convinced that this crowd can help more than the first few pages of Google results...

9 Jun at 23:47

Cropping an UIImage

I've got some code that resizes an image so I can get a scaled chunk of the center of the image - I use this to take a `UIImage` and return a small, square representation of an image, similar to what'...

ProcessStartInfo hanging on "WaitForExit"? Why?

I have the following code: ``` info = new System.Diagnostics.ProcessStartInfo("TheProgram.exe", String.Join(" ", args)); info.CreateNoWindow = true; info.WindowStyle = System.Diagnostics.ProcessWindow...

26 May at 16:43

Accessing Object Memory Address

When you call the `object.__repr__()` method in Python you get something like this back: > ``` <__main__.Test object at 0x2aba1c0cf890> ``` Is there any way to get a hold of the memory address if ...

13 Jan at 04:44

How can I send an email by Java application using GMail, Yahoo, or Hotmail?

Is it possible to send an email from my Java application using a GMail account? I have configured my company mail server with Java app to send email, but that's not going to cut it when I distribute ...

TypeScript error: Property 'X' does not exist on type 'Window'

I have added TS to my React/Redux app. I use `window` object in my app like this: ``` componentDidMount() { let FB = window.FB; } ``` TS throws an error: > TypeScript error: Property 'FB' does ...

5 Jun at 09:47

Why is useState not triggering re-render?

I've initialized a state that is an array, and when I update it my component does not re-render. Here is a minimal proof-of-concept: ``` function App() { const [numbers, setNumbers] = React.useState...

25 Jul at 18:39

How to update existing images with docker-compose?

I have multiple microservices and I am using docker-compose for development deployments. When there are some changes in the microservices code base, I am triggering ci job to re-deploy them. I have be...

20 Oct at 08:55

Force retesting or disable test caching

When I run the same go test twice the second run is not done at all. The results are the cached ones from the first run. ``` PASS ok tester/apitests (cached) ``` I already checked [...

20 Feb at 10:13

Fetch API request timeout?

I have a `fetch-api` `POST` request: ``` fetch(url, { method: 'POST', body: formData, credentials: 'include' }) ``` I want to know what is the default timeout for this? and how can we set it to...

9 Jul at 11:39