Questions

Determine if map contains a value for a key?

What is the best way to determine if a STL map contains a value for a given key? ``` #include <map> using namespace std; struct Bar { int i; }; int main() { map<int, Bar> m; Bar b = {0...

25 Aug at 03:48

How can I convert JSON to a HashMap using Gson?

I'm requesting data from a server which returns data in the JSON format. Casting a HashMap into JSON when making the request wasn't hard at all but the other way seems to be a little tricky. The JSON ...

10 May at 16:37

How to convert a data frame column to numeric type?

How do you convert a data frame column to a numeric type?

10 Oct at 05:54

Defining private module functions in python

According to [http://www.faqs.org/docs/diveintopython/fileinfo_private.html](http://www.faqs.org/docs/diveintopython/fileinfo_private.html): > Like most languages, Python has the concept of private el...

20 Jun at 09:12

How can I show what a commit did?

A stupid way I know is: ``` git diff commit-number1 commit-number2 ``` Is there a better way? I mean, I want to know the commit1 itself. I don't want to add the commit2 before it as a parameter.

11 Apr at 09:45

Can you get the column names from a SqlDataReader?

After connecting to the database, can I get the name of all the columns that were returned in my `SqlDataReader`?

11 Aug at 09:27

How can I convert a DOM element to a jQuery element?

I am creating an element with document.createElement(). Now how can I pass it to a function that only takes a Jquery object? ``` $("#id") ``` I can not use it, as the element has not been rendered ...

9 Mar at 12:3

What are the best JVM settings for Eclipse?

What are the best JVM settings you have found for running Eclipse?

23 Apr at 10:40

How to update an existing Conda environment with a .yml file

How can a pre-existing conda environment be updated with another .yml file. This is extremely helpful when working on projects that have multiple requirement files, i.e. `base.yml, local.yml, producti...

10 Jul at 18:36

Docker is in volume in use, but there aren't any Docker containers

EDIT (2/19/21): A lot of time has elapsed since I asked this original question years ago and I've seen a flurry of activity since then. I re-selected an answer which I think is consistent with the mos...

19 Feb at 22:53

Android Recyclerview GridLayoutManager column spacing

How do you set the column spacing with a RecyclerView using a GridLayoutManager? Setting the margin/padding inside my layout has no effect.

Error "undefined reference to 'std::cout'"

Shall this be the example: ``` #include <iostream> using namespace std; int main() { cout << "Hola, moondo.\n"; } ``` It throws the error: ``` gcc -c main.cpp gcc -o edit main.o main.o: In func...

3 Apr at 15:7

Hadoop "Unable to load native-hadoop library for your platform" warning

I'm currently configuring hadoop on a server running . When I run `start-dfs.sh` or `stop-dfs.sh`, I get the following error: > WARN util.NativeCodeLoader: Unable to load native-hadoop library for ...

Android map v2 zoom to show all the markers

I have 10 markers in the `GoogleMap`. I want to zoom in as much as possible and keep all markers in view? In the earlier version this can be achieved from `zoomToSpan()` but in v2 I have no idea how a...

List files ONLY in the current directory

In Python, I only want to list all the files in the current directory ONLY. I do not want files listed from any sub directory or parent. There do seem to be similar solutions out there, but they don'...

21 Oct at 18:19

PHP "php://input" vs $_POST

I have been directed to use the method `php://input` instead of `$_POST` when interacting with Ajax requests from JQuery. What I do not understand is the benefits of using this vs the global method of...

24 Jul at 02:1

How do you run JavaScript script through the Terminal?

For instance, if you were to run a Python script you would type or if you wanted to run a C program then . How do you do this with files?

26 May at 13:11

Float vs Decimal in ActiveRecord

Sometimes, Activerecord data types confuse me. Err, often. One of my eternal questions is, for a given case, > Should I use `:decimal` or `:float`? I've often come across this link, [ActiveRecord: :...

Find and replace with sed in directory and sub directories

I run this command to find and replace all occurrences of 'apple' with 'orange' in all files in root of my site: ``` find ./ -exec sed -i 's/apple/orange/g' {} \; ``` But it doesn't go through sub ...

9 Mar at 15:51

MySQL server startup error 'The server quit without updating PID file'

On [Mac OS X v10.6](https://en.wikipedia.org/wiki/Mac_OS_X_Snow_Leopard) (Snow Leopard), starting MySQL gives the following error: > The server quit without updating PID file ### File my.cnf ``` [m...

29 Oct at 20:37

What does it mean to inflate a view from an xml file?

I am new to android development and keep coming across references to Inflating views from a layout xml file. I googled and searched the development guide but still wasn't able to pick up a sense for ...

1 Jan at 23:39

Inserting string at position x of another string

I have two variables and need to insert string `b` into string `a` at the point represented by `position`. The result I'm looking for is "I want an apple". How can I do this with JavaScript? ``` var ...

19 May at 09:31

Is it possible to focus on a <div> using JavaScript focus() function?

Is it possible to focus on a `<div>` using JavaScript `focus()` function? I have a `<div>` tag ``` <div id="tries">You have 3 tries left</div> ``` I am trying to focus on the above `<div>` using :...

23 Jul at 15:43

Is there a way to get rid of accents and convert a whole string to regular letters?

Is there a better way for getting rid of accents and making those letters regular apart from using `String.replaceAll()` method and replacing letters one by one? Example: Input: `orčpžsíáýd` Output...

12 Oct at 15:46

How to get the current working directory's absolute path in Ruby?

I'm running Ruby on Windows though I don't know if that should make a difference. All I want to do is get the current working directory's absolute path. Is this possible from irb? Apparently from a...

4 Sep at 20:2