Questions

Emulate ggplot2 default color palette

What function can I use to emulate ggplot2's default color palette for a desired number of colors. For example, an input of 3 would produce a character vector of HEX colors with these colors: ![enter...

19 Nov at 21:37

HTML text-overflow ellipsis detection

I have a collection of block elements on a page. They all have the CSS rules white-space, overflow, text-overflow set so that overflowing text is trimmed and an ellipsis is used. However, not all the...

12 Nov at 23:26

Java ArrayList replace at specific index

I need help with this java please. I created an ArrayList of bulbs, and I'm trying to replace a bulb at specific index with another bulb. So with the following heading, how do I proceed? ``` public v...

17 Sep at 06:23

Remove all special characters except space from a string using JavaScript

I want to remove all special characters except space from a string using JavaScript. For example, `abc's test#s` should output as `abcs tests`.

9 Dec at 16:33

Debugging WebSocket in Google Chrome

Is there a way, or an extension, that lets me watch the "traffic" going through a WebSocket? For debugging purposes I'd like to see the client and server requests/responses.

22 Apr at 01:31

Using variables inside a bash heredoc

I'm trying to interpolate variables inside of a bash heredoc: ``` var=$1 sudo tee "/path/to/outfile" > /dev/null << "EOF" Some text that contains my $var EOF ``` This isn't working as I'd expect (`...

25 Feb at 14:34

How to cancel/abort jQuery AJAX request?

I've an AJAX request which will be made every 5 seconds. But the problem is before the AJAX request if the previous request is not completed I've to abort that request and make a new request. My code...

28 Nov at 15:50

Does Spring @Transactional attribute work on a private method?

If I have a [@Transactional](http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/transaction/annotation/Transactional.html) -annotation on a private method in a Spring bean, does ...

9 Dec at 08:38

How to dynamically create a class?

I have a class which looks like this: ``` public class Field { public string FieldName; public string FieldType; } ``` And an object `List<Field>` with values: ``` {"EmployeeID","int"}, {"...

Handling click events on a drawable within an EditText

I have added an image right of the text in an `EditText` widget, using the following XML: ``` <EditText android:id="@+id/txtsearch" ... android:layout_gravity="center_vertical" android:backgr...

How can I do a case insensitive string comparison?

How can I make the line below case insensitive? ``` drUser["Enrolled"] = (enrolledUsers.FindIndex(x => x.Username == (string)drUser["Username"]) != -1); ``` I was given some advice earlier t...

Append an object to a list in R in amortized constant time, O(1)?

If I have some R list `mylist`, you can append an item `obj` to it like so: ``` mylist[[length(mylist)+1]] <- obj ``` But surely there is some more compact way. When I was new at R, I tried writi...

28 Apr at 18:22

How can I make a .NET Windows Forms application that only runs in the System Tray?

What do I need to do to make a [Windows Forms](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/overview/?view=netdesktop-5.0) application to be able to run in the System Tray? Not an applica...

4 Feb at 06:10

Using column alias in WHERE clause of MySQL query produces an error

The query I'm running is as follows, however I'm getting this error: > #1054 - Unknown column 'guaranteed_postcode' in 'IN/ALL/ANY subquery' ``` SELECT `users`.`first_name`, `users`.`last_name`, `us...

26 Apr at 03:5

Does MS SQL Server's "between" include the range boundaries?

For instance can ``` SELECT foo FROM bar WHERE foo BETWEEN 5 AND 10 ``` select 5 and 10 or they are excluded from the range?

8 Aug at 11:57

C++ display stack trace on exception

I want to have a way to report the stack trace to the user if an exception is thrown. What is the best way to do this? Does it take huge amounts of extra code? To answer questions: I'd like it to be...

6 Jan at 22:50

Is it a good practice to place C++ definitions in header files?

My personal style with C++ has always been to put class declarations in an include file and definitions in a `.cpp` file, very much like stipulated in [Loki's answer to C++ Header Files, Code Separati...

Any way to make a WPF textblock selectable?

How to allow `TextBlock`'s text to be selectable? I tried to get it to work by displaying the text using a read-only TextBox styled to look like a textblock but this will not work in my case because a...

29 Jun at 17:0

How can we generate getters and setters in Visual Studio?

By "generate", I mean auto-generation of the code necessary for a particular selected (set of) variable(s). But any more explicit explication or comment on good practice is welcome.

9 Dec at 17:56

Unsupported method: BaseConfig.getApplicationIdSuffix()

So I'm reading and the first two app examples I had no issues with the examples, this time the FlagQuiz example when loaded in Android Studio 3.0 Canary-3 I'm getting this error which isn't letting m...

23 Dec at 19:23

matplotlib: how to draw a rectangle on image

How to draw a rectangle on an image, like this: [](https://i.stack.imgur.com/KWG46.jpg) ``` import matplotlib.pyplot as plt from PIL import Image import numpy as np im = np.array(Image.open('dog.png')...

9 Jul at 16:7

How to return first 5 objects of Array in Swift?

In Swift, is there a clever way of using the higher order methods on Array to return the 5 first objects? The obj-c way of doing it was saving an index, and for-loop through the array incrementing in...

15 Feb at 15:39

REST API Best practices: args in query string vs in request body

A REST API can have arguments in several places: 1. In the request body - As part of a json body, or other MIME type 2. In the query string - e.g. /api/resource?p1=v1&p2=v2 3. As part of the URL-pat...

28 Mar at 16:46

What exactly does the Access-Control-Allow-Credentials header do?

I'm trying to understand how to use CORS and am confused about what the `Access-Control-Allow-Credentials` header does. [The documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_co...

29 Oct at 12:12

Find column whose name contains a specific string

I have a dataframe with column names, and I want to find the one that contains a certain string, but does not exactly match it. I'm searching for `'spike'` in column names like `'spike-2'`, `'hey spik...