Questions

How do I reverse an int array in Java?

I am trying to reverse an int array in Java. This method does not reverse the array. ``` for(int i = 0; i < validData.length; i++) { int temp = validData[i]; validData[i] = validData[valid...

8 May at 21:45

How to select specific columns in laravel eloquent

lets say I have 7 columns in table, and I want to select only two of them, something like this ``` SELECT `name`,`surname` FROM `table` WHERE `id` = '1'; ``` In laravel eloquent model it may looks ...

28 Apr at 16:39

JavaScript - cannot set property of undefined

``` var a = "1", b = "hello", c = { "100" : "some important data" }, d = {}; d[a]["greeting"] = b; d[a]["data"] = c; console.debug (d); ``` I get the following error: > Uncaught TypeError: Can...

14 Mar at 09:49

Get HTML source of WebElement in Selenium WebDriver using Python

I'm using the Python bindings to run Selenium WebDriver: ``` from selenium import webdriver wd = webdriver.Firefox() ``` I know I can grab a webelement like so: ``` elem = wd.find_element_by_css_sele...

Error "npm WARN package.json: No repository field"

I installed Express.js with the following command: ``` sudo npm install -g express ``` I get the following warnings: ``` npm WARN package.json range-parser@0.0.4 No repository field. npm WARN package...

29 Dec at 02:31

CSS: background image on background color

I have panel which I colored blue if this panel is being selected (clicked on it). Additionally, I add a small sign (`.png` image) to that panel, which indicates that the selected panel has been alrea...

How to grep a string in a directory and all its subdirectories?

How to grep a string or a text in a directory and all its subdirectories'files in LINUX ??

15 Sep at 02:4

HTML anchor tag with Javascript onclick event

On using Google I found that they are using onclick events in anchor tags. In option in google header part, it looks like normal a tag, but onclicking it doesn't get redirected but opened a menu. No...

Python/Json:Expecting property name enclosed in double quotes

I've been trying to figure out a good way to load JSON objects in Python. I send this json data: ``` {'http://example.org/about': {'http://purl.org/dc/terms/title': [{'type': 'literal', 'value': "Ann...

14 Sep at 13:17

How to export query result to csv in Oracle SQL Developer?

I'm using Oracle SQL Developer 3.0. Trying to figure out how to export a query result to a text file (preferably CSV). Right clicking on the query results window doesn't give me any export options.

25 Jul at 19:40

Adding a new array element to a JSON object

I have a JSON format object I read from a JSON file that I have in a variable called teamJSON, that looks like this: ``` {"theTeam":[{"teamId":"1","status":"pending"},{"teamId":"2","status":"member"}...

19 Sep at 01:17

Git push existing repo to a new and different remote repo server?

Say I have a repository on [git.fedorahosted.org](http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=summary) and I want to clone this into my account at github to have my own playground aside from the ...

3 Mar at 14:18

How to append a new row to an old CSV file in Python?

I am trying to add a new row to my old CSV file. Basically, it gets updated each time I run the Python script. Right now I am storing the old CSV rows values in a list and then deleting the CSV file a...

22 May at 11:19

How do I remove the first characters of a specific column in a table?

In SQL, how can I remove the first 4 characters of values of a specific column in a table? Column name is `Student Code` and an example value is `ABCD123Stu1231`. I want to remove first 4 chars from ...

6 Dec at 17:49

How to sort a list of strings?

What is the best way of creating an alphabetically sorted list in Python?

25 Apr at 19:27

Associating enums with strings in C#

I know the following is not possible because the Enumeration's type has to be an int ``` enum GroupTypes { TheGroup = "OEM", TheOtherGroup = "CMB" } ``` From my database I get a field with ...

19 Sep at 03:15

Get current folder path

I want to create a program that converts files. I would like the user to be able to place the executable file in any directory, and when executing that program (double-clicking on the .exe) I want the...

17 Jan at 10:11

Getting the IP address of the current machine using Java

I am trying to develop a system where there are different nodes that are run on different system or on different ports on the same system. Now all the nodes create a Socket with a target IP as the I...

11 Apr at 08:38

How do I execute a command and get the output of the command within C++ using POSIX?

I am looking for a way to get the output of a command when it is run from within a C++ program. I have looked at using the `system()` function, but that will just execute a command. Here's an example...

10 Nov at 16:43

How to convert Milliseconds to "X mins, x seconds" in Java?

I want to record the time using `System.currentTimeMillis()` when a user begins something in my program. When he finishes, I will subtract the current `System.currentTimeMillis()` from the `start` var...

9 Mar at 08:41

HTML-encoding lost when attribute read from input field

I’m using JavaScript to pull a value out from a hidden field and display it in a textbox. The value in the hidden field is encoded. For example, ``` <input id='hiddenId' type='hidden' value='chalk &...

ASP.NET MVC controller actions that return JSON or partial html

I am trying to create controller actions which will return either JSON or partial html depending upon a parameter. What is the best way to get the result returned to an MVC page asynchronously?

18 Jun at 17:20

How can I sanitize user input with PHP?

Is there a catchall function somewhere that works well for sanitizing user input for SQL injection and XSS attacks, while still allowing certain types of HTML tags?

Typescript Type 'string' is not assignable to type

Here's what I have in fruit.ts ``` export type Fruit = "Orange" | "Apple" | "Banana" ``` Now I'm importing fruit.ts in another typescript file. Here's what I have ``` myString:string = "Banana"; ...

18 Aug at 15:23

Convert one date format into another in PHP

Is there a simple way to convert one date format into another date format in PHP? I have this: ``` $old_date = date('y-m-d-h-i-s'); // works $middle = strtotime($old_date); /...