Questions

How to find the array index with a value?

Say I've got this ``` imageList = [100,200,300,400,500]; ``` Which gives me `[0]100 [1]200` etc. Is there any way in JavaScript to return the index with the value? I.e. I want the index for , I ...

11 Apr at 14:13

Display a decimal in scientific notation

How can I display `Decimal('40800000000.00000000000000')` as `'4.08E+10'`? I've tried this: ``` >>> '%E' % Decimal('40800000000.00000000000000') '4.080000E+10' ``` But it has those extra 0's.

How do I get the latest version of my code?

I'm using Git 1.7.4.1. I want to get the latest version of my code from the repository, but I'm getting errors: ``` $ git pull …. M selenium/ant/build.properties …. M selenium/scripts/linux/get_la...

18 Feb at 09:32

Replace only some groups with Regex

Let's suppose I have the following regex: ``` -(\d+)- ``` and I want to replace, using C#, the Group 1 `(\d+)` with `AA`, to obtain: ``` -AA- ``` Now I'm replacing it using: ``` var text = "exa...

23 Jan at 08:1

String concatenation in MySQL

I am using MySQL and MySQL Workbench 5.2 CE. When I try to concatenate 2 columns, `last_name` and `first_name`, it doesn't work : ``` select first_name + last_name as "Name" from test.student ```

2 Feb at 23:48

How to capitalize the first letter of word in a string using Java?

Example strings ``` one thousand only two hundred twenty seven ``` How do I change the first character of a string in capital letter and not change the case of any of the other letters? After the ...

11 Jul at 16:53

is there a Java equivalent to null coalescing operator (??) in C#?

Is it possible to do something similar to the following code in Java ``` int y = x ?? -1; ``` [More about ??](https://stackoverflow.com/a/446839)

Play/pause HTML 5 video using JQuery

I am trying to control HTML5 videos using JQuery. I have two clips in a tabbed interface, there are six tabs in total, the others just have images. I am trying to make the video clips play when their ...

10 Jan at 12:50

Encoding an image file with base64

I want to encode an image into a string using the base64 module. I've ran into a problem though. How do I specify the image I want to be encoded? I tried using the directory to the image, but that sim...

1 Feb at 09:32

JavaScript get window X/Y position for scroll

I'm hoping to find a way to get the current viewable window's position (relative to the total page width/height) so I can use it to force a scroll from one section to another. However, there seems to ...

13 Oct at 19:32

Ternary operators in JavaScript without an "else"

I've always had to put `null` in the else conditions that don't have anything. Is there a way around it? For example, ``` condition ? x = true : null; ``` Basically, is there a way to do the followin...

How to check if object has any properties in JavaScript?

Assuming I declare ``` var ad = {}; ``` How can I check whether this object will contain any user-defined properties?

21 Apr at 05:30

How to determine the longest increasing subsequence using dynamic programming?

I have a set of integers. I want to find the [longest increasing subsequence](https://en.wikipedia.org/wiki/Longest_increasing_subsequence) of that set using dynamic programming.

How to set JFrame to appear centered, regardless of monitor resolution?

While working with Java, I find it hard to position my main window in the center of the screen when I start the application. Is there any way I can do that? It doesn't have to be vertically centered,...

31 Aug at 13:49

Dependency Inject (DI) "friendly" library

I'm pondering the design of a C# library, that will have several different high level functions. Of course, those high-level functions will be implemented using the [SOLID](http://butunclebob.com/Arti...

Differences between fork and exec

What are the differences between `fork` and `exec`?

3 Oct at 06:19

How to use enums as flags in C++?

Treating `enum`s as flags works nicely in C# via the `[Flags]` attribute, but what's the best way to do this in C++? For example, I'd like to write: ``` enum AnimalFlags { HasClaws = 1, CanF...

19 Sep at 11:57

regex to match a single character that is anything but a space

I need to match a single character that is anything but a space but I don't know how to do that with regex.

25 Jul at 05:37

Get file name from URI string in C#

I have this method for grabbing the file name from a string URI. What can I do to make it more robust? ``` private string GetFileName(string hrefLink) { string[] parts = hrefLink.Split('/'); ...

9 Jul at 18:7

C++ STL Vectors: Get iterator from index?

So, I wrote a bunch of code that accesses elements in an stl vector by index[], but now I need to copy just a chunk of the vector. It looks like `vector.insert(pos, first, last)` is the function I wan...

25 May at 09:28

How can I set my default shell on a Mac, e.g. to Fish?

I do not like to retype `fish` every time I start terminal. I want [Fish](https://en.wikipedia.org/wiki/Fish_(Unix_shell)) on by default. How can I set the Fish shell as my default shell on a Mac?

15 Jul at 13:56

How do I do base64 encoding on iOS?

I'd like to do `base64` encoding and decoding, but I could not find any support from the iPhone `SDK`. How can I do `base64` encoding and decoding with or without a library?

4 Jan at 10:23

Difference between @click and v-on:click Vuejs

The questions should be enough clear. But I can see that someone use: ``` <button @click="function()">press</button> ``` Someone use: ``` <button v-on:click="function()">press</button> ``` But reall...

31 Oct at 02:3

How to convert Blob to File in JavaScript

I need to upload an image to NodeJS server to some directory. I am using `connect-busboy` node module for that. I had the `dataURL` of the image that I converted to blob using the following code: ``...

15 Nov at 18:13

Negate if condition in bash script

I'm stuck at trying to negate the following command: ``` wget -q --tries=10 --timeout=20 --spider http://google.com if [[ $? -eq 0 ]]; then echo "Sorry you are Offline" exit 1 ``` Thi...

29 Dec at 01:16