Some Of The Best Answers From Latest Asked Questions

7

answers

Add a column to a table, if it does not already exist

I want to write a query for MS SQL Server that adds a column into a table. But I don't want any error display, when I run/execute the following query. I am using this sort of query to add a table .....

3

answers

How to quickly test some javascript code?

What would be a good way to test Javascript on a browser? Should there be a localhost in my computer? and how to create one?..

7

answers

how much memory can be accessed by a 32 bit machine?

What is meant by 32bit or 64 bit machine? It’s the processor architecture…a 32 bit machine can read and write 32bit data at a time same way with 64 bit machine…. whats the maximum memory that ..

7

answers

How do I automatically play a Youtube video (IFrame API) muted?

<iframe class="youtube-player" type="text/html" src="http://www.youtube.com/embed/JW5meKfy3fY?wmode=opaque&autohide=1&autoplay=1&volume=0&vol=0&mute=1" frameborder="0">&l..

7

answers

How can I find out if an .EXE has Command-Line Options?

Suppose you have an .EXE and you want to check if it has Command-Line Options. How can one know if the .EXE has this ability. In my case I know that Nir Sofers WebBrowserPassView.exe has the ability t..

21

answers

Why is the console window closing immediately once displayed my output?

I'm studying C# by following the guides in MSDN. Now, I just tried the Example 1 (here is the link to MSDN), and I've encountered an issue: why is the console window closing immediately once displa..

8

answers

Should I return EXIT_SUCCESS or 0 from main()?

It's a simple question, but I keep seeing conflicting answers: should the main routine of a C++ program return 0 or EXIT_SUCCESS? #include <cstdlib> int main(){return EXIT_SUCCESS;} or int m..

3

answers

XMLHttpRequest (Ajax) Error

I'm using XMLHttpRequest in JavaScript. However, it gives me an error, and I don't know what my problem is. I have to parse an XML file and assign its contents to the webpage - here's my code: <sc..

4

answers

Determine if 2 lists have the same elements, regardless of order?

Sorry for the simple question, but I'm having a hard time finding the answer. When I compare 2 lists, I want to know if they are "equal" in that they have the same contents, but in different order. ..

4

answers

How to change the current URL in javascript?

On my website: http://mywebsite.com/1.html I want to use the window.location.pathname to get the last part of the url: 1.html and since I have all my webpages in numbers I want to add 1 to t..

22

answers

How can I list all collections in the MongoDB shell?

In the MongoDB shell, how do I list all collections for the current database that I'm using?..

14

answers

Skipping every other element after the first

I have the general idea of how to do this in Java, but I am learning Python and not sure how to do it. I need to implement a function that returns a list containing every other element of the list, ..

2

answers

Comments in .gitignore?

Can you write comments in a .gitignore file? If so, should the line be preceded with a # or some other indicator?..

38

answers

How do I vertically center text with CSS?

I have a <div> element which contains text and I want to align the contents of this <div> vertically center. Here is my <div> style: _x000D_ _x000D_ #box { height: 170px; width: ..

5

answers

Using routes in Express-js

So I'm starting to use Node.js. I saw the video with Ryan Dahl on Nodejs.org and heard he recommended Express-js for websites. I downloaded the latest version of Express, and began to code. I have a ..

24

answers

ImportError: No module named PIL

I use this command in the shell to install PIL: easy_install PIL then I run python and type this: import PIL. But I get this error: Traceback (most recent call last): File "<console>", lin..

1

answers

How to programmatically turn off WiFi on Android device?

I need to turn off the WiFi a while after pressing the "Turn off the Screen" button. There is a need for this app for my tablet because sometimes I just forget to turn off the WiFi and this discharges..

6

answers

Simple file write function in C++

I have this code: // basic file operations #include <iostream> #include <fstream> using namespace std; int main() { writeFile(); } int writeFile () { ofstream myfile; myfile.op..

7

answers

Unexpected end of file error

I hope you can help me, cause I have no idea about what's going on. I'm having the following error while trying to add Beecrypt library to my project: fatal error C1010: unexpected end of file whi..

6

answers

Clear all fields in a form upon going back with browser back button

I need a way to clear all the fields within a form when a user uses the browser back button. Right now, the browser remembers all the last values and displays them when you go back. More clarificatio..

13

answers

JavaScript single line 'if' statement - best syntax, this alternative?

It's been clearly put, although opinion none the less, that forgoing curly brackets on a single line if statement is not ideal for maintainability and readability. But what about this? if (lemons) {..

6

answers

ALTER TABLE to add a composite primary key

I have a table called provider. I have three columns called person, place, thing. There can be duplicate persons, duplicate places, and duplicate things, but there can never be a dupicate person-place..

8

answers

PHP read and write JSON from file

I have the following JSON in a file list.txt: { "bgates":{"first":"Bill","last":"Gates"}, "sjobs":{"first":"Steve","last":"Jobs"} } How do I add "bross":{"first":"Bob","last":"Ross"} to my file usi..

18

answers

Tomcat is not running even though JAVA_HOME path is correct

When I am trying to run tomcat using startup.bat I get the following error, The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAV..

3

answers

Calling stored procedure from another stored procedure SQL Server

I have 3 insert stored procedures each SP inserts data in 2 different tables Table 1 Table 2 idPerson idProduct name productName ..

9

answers

How to move a file?

I looked into the Python os interface, but was unable to locate a method to move a file. How would I do the equivalent of $ mv ... in Python? >>> source_files = '/PATH/TO/FOLDER/*' >>&..

23

answers

Compiler error "archive for required library could not be read" - Spring Tool Suite

I am starting to configure my development environment and I am using Spring Tool Suite 2.8.1 along with m2E 1.01. As far as I can tell, since this is a Maven Project (my first), my Maven POM is dicta..

20

answers

How do I drop a MongoDB database from the command line?

What's the easiest way to do this from my bash prompt?..

8

answers

Get all messages from Whatsapp

I'm trying to implement an app that will show in a textview all the messages received from Whatsapp. Is there any way to do it? Is it possible to extract all the messages from Whatsapp?..

6

answers

ValueError: unsupported format character while forming strings

This works: print "Hello World%s" %"!" But this doesn't print "Hello%20World%s" %"!" the error is ValueError: unsupported format character 'W' (0x57) at index 8 I am using Python 2.7. Why woul..

13

answers

How to send email to multiple recipients using python smtplib?

After much searching I couldn't find out how to use smtplib.sendmail to send to multiple recipients. The problem was every time the mail would be sent the mail headers would appear to contain multipl..

19

answers

How to create standard Borderless buttons (like in the design guideline mentioned)?

I was just checking the design guidelines and wondering about the borderless buttons. I goggled and tried to find in the source but can't bring it together by myself. Is this the normal Button widget ..

12

answers

Secure random token in Node.js

In this question Erik needs to generate a secure random token in Node.js. There's the method crypto.randomBytes that generates a random Buffer. However, the base64 encoding in node is not url-safe, it..

3

answers

Convert ndarray from float64 to integer

I've got an ndarray in python with a dtype of float64. I'd like to convert the array to be an array of integers. How should I do this? int() won't work, as it says it can't convert it to a scalar. Ch..

2

answers

Oracle SQL : timestamps in where clause

I need to look up rows within a particular time frame. select * from TableA where startdate >= '12-01-2012 21:24:00' and startdate <= '12-01-2012 21:25:33' I.e.: I need to look up rows w..

24

answers

FB OpenGraph og:image not pulling images (possibly https?)

First -- I do not believe this is a duplicate issue. I've searched for same or similar problems on SO extensively, and due to the nature of troubleshooting before asking, I believe this problem is uni..

2

answers

Append text using StreamWriter

This is probably a pretty simple question. In C# I'm trying to write a simple method, called my "DebugWrite" method, to write out any exceptions caught within my program to a text file stored locally..

33

answers

Exception 'open failed: EACCES (Permission denied)' on Android

I am getting open failed: EACCES (Permission denied) on the line OutputStream myOutput = new FileOutputStream(outFileName); I checked the root, and I tried android.permission.WRITE_EXTERNAL_STO..

2

answers

val() vs. text() for textarea

I am using jQuery, and wondering if I should use val() or text() (or another method) to read and update the content of a textarea. I have tried both and I've had issues with both. When I use text() t..

2

answers

Java String encoding (UTF-8)

I have come across this line of legacy code, which I am trying to figure out: String newString = new String(oldString.getBytes("UTF-8"), "UTF-8")); As far as I can understand, it is encoding & ..

8

answers

duplicate 'row.names' are not allowed error

I am trying to load a csv file that has 14 columns like this: StartDate, var1, var2, var3, ..., var14 when I issue this command: systems <- read.table("http://getfile.pl?test.csv", header = TRU..

4

answers

repaint() in Java

Possible Duplicate: Java GUI repaint() problem? I write a Java code, but I have a trouble with GUI problem. When I add a component into JFrame object, then I call repaint() method in order ..

26

answers

Logical operator in a handlebars.js {{#if}} conditional

Is there a way in handlebars JS to incorporate logical operators into the standard handlebars.js conditional operator? Something like this: {{#if section1 || section2}} .. content {{/if}} I know I ..

9

answers

JSHint and jQuery: '$' is not defined

The following JS: (function() { "use strict"; $("#target").click(function(){ console.log("clicked"); }); }()); Yields: test.js: line 5, col 3, '$' is not defined. When linted using J..

3

answers

Excel VBA - Range.Copy transpose paste

I'm trying to something very simple, but I seem to be stuck. I am following the help menu for PasteSpecial but I cannot seem to get my code to work without an error. I want to take Worksheets("Sheet1..

7

answers

How can I get name of element with jQuery?

How can I get name property of HTML element with jQuery?..

6

answers

How to make PopUp window in java

I am currently developing a java application. I want to show a new Window which contains a text area and a button. Do you have any ideas?..

5

answers

Populating VBA dynamic arrays

The following code gives me error 9 "subscript out of range". I meant to declare a dynamic array so that the dimension changes as I add elements to it. Do I have to create a "spot" on the array before..

7

answers

How to add a custom Ribbon tab using VBA?

I am looking for a way to add a custom tab in the Excel ribbon which would carry a few buttons. I chanced on some resources addressing it via Google but all look dodgy and outrageously complicated. ..

4

answers

Add quotation at the start and end of each line in Notepad++

I have a list (in a .txt file) which I'd like to quickly convert to JavaScript Syntax, so I want to take the following: AliceBlue AntiqueWhite Aqua Aquamarine Azure Beige Bisque Black BlanchedAlmond ..

10

answers

Why when I transfer a file through SFTP, it takes longer than FTP?

I manually copy a file to a server, and the same one to an SFTP server. The file is 140MB. FTP: I have a rate arround 11MB/s SFTP: I have a rate arround 4.5MB/s I understand the file has to be encr..

4

answers

Adding a Scrollable JTextArea (Java)

I am trying to add a scroll bar to a JTextArea. Would someone please tell me what I did wrong with the code below? JFrame frame = new JFrame ("Test"); JTextArea textArea = new JTextArea ("Test"); JS..

6

answers

Fastest way to reset every value of std::vector<int> to 0

What's the fastest way to reset every value of a std::vector<int> to 0 and keeping the vectors initial size ? A for loop with the [] operator ? ..

7

answers

How to get char from string by index?

Lets say I have a string that consists of x unknown chars. How could I get char nr. 13 or char nr. x-14?..

6

answers

How to draw text using only OpenGL methods?

I don't have the option to use but OpenGL methods (that is glxxx() methods). I need to draw text using gl methods only. After reading the red book, I understand that it is possible only through the gl..

4

answers

what is difference between success and .done() method of $.ajax

Can anyone help me? I am not able to understand the difference between success and .done() of $.ajax. If possible please give examples...

17

answers

How to convert JSON to CSV format and store in a variable

I have a link that opens up JSON data in the browser, but unfortunately I have no clue how to read it. Is there a way to convert this data using JavaScript in CSV format and save it in JavaScript file..

9

answers

How to change xampp localhost to another folder ( outside xampp folder)?

How can I change my default xampp localhost c:xampp/htdoc to another folder i.e. c:/alan? When I use the IP address I should be able to view my website file in C:/alan. Thanks for helping me...

10

answers

how to implement a long click listener on a listview

I want to add OnLongClickListener on my list view. Whenever the user long press the item in list some action should be performed, But my code does not catch this listener. Please let me know where I a..

12

answers

How to remove first and last character of a string?

I have worked in SOAP message to get LoginToken from Webservice, and store the LoginToken in String and used System.out.println(LoginToken); to print. This prints [wdsd34svdf], but I want only wdsd34s..

4

answers

CSS3 :unchecked pseudo-class

I know there is an official CSS3 :checked pseudo-class, but is there an :unchecked pseudo-class, and do they have the same browser support? Sitepoint's reference doesn't mention one, however this what..

3

answers

What is the command for cut copy paste a file from one directory to other directory

Can any one please help what is the command for cut copy and paste one file from one directory to other directory. I want do above task by using Command from command prompt. I know I can do this by u..

12

answers

Gerrit error when Change-Id in commit messages are missing

I set up a branch in the remote repository and made some commits on that branch. Now I want to merge the remote branch to the remote master. Basically follows are my operations: checkout branch che..

16

answers

What exactly is Apache Camel?

I don't understand what exactly Camel does. If you could give in 101 words an introduction to Camel: What exactly is it? How does it interact with an application written in Java? Is it something ..

4

answers

Remove ALL styling/formatting from hyperlinks

I'm creating a navigation menu with words with different colors (href links). I would like the color NOT to change on any state (hover, visited etc). I know how to set the the colors for the differen..

13

answers

How to select only 1 row from oracle sql?

I want to use oracle syntax to select only 1 row from table DUAL. For example, I want to execute this query: SELECT user FROM DUAL ...and it'd have, like, 40 records. But I need only one recor..

5

answers

How to make a <svg> element expand or contract to its parent container?

The goal is to have the <svg> element expand to the size of its parent container, in this case a <div>, no matter how big or small that container may be. The code: <style> svg,..

8

answers

Ajax Success and Error function failure

I am having trouble getting my jQuery ajax to work properly. It directs to the PHP page to update the database, but never returns back to the script for the success or error options. My code is below..

20

answers

Cross browser JavaScript (not jQuery...) scroll to top animation

I'm looking for a simple, cross-browser "scroll to top" animation I can apply to a link. I don't want to require a JS library such as jQuery/Moo, etc. // jQuery Equivilant to convert to pure JS... $(..

23

answers

Which version of Python do I have installed?

I have to run a Python script on a Windows server. How can I know which version of Python I have, and does it even really matter? I was thinking of updating to the latest version of Python...

3

answers

Disable arrow key scrolling in users browser

I'm making a game using canvas, and javascript. When the page is longer than the screen (comments, etc.) pressing the down arrow scrolls the page down, and makes the game impossible to play. What ca..

13

answers

iOS - UIImageView - how to handle UIImage image orientation

Is it possible to setup UIImageView to handle image orientation? When I set the UIImageView to image with orientation RIGHT (it is photo from camera roll), the image is rotated to right, but I want to..

15

answers

Python Image Library fails with message "decoder JPEG not available" - PIL

PIL does support JPEG in my system. Whenever I do an upload, my code is failing with: File "PIL/Image.py", line 375, in _getdecoder raise IOError("decoder %s not available" % decoder_name) IOErr..

5

answers

Invalid application of sizeof to incomplete type with a struct

I have a struct where I put all the information about the players. That's my struct: struct player{ int startingCapital; int currentCapital; int startingPosition; int currentPosition; ..

2

answers

C# Validating input for textbox on winforms

I want to check what the user is writing in a textbox before I save it in a database. What is the best way to do this? I guess I can always write some ifs or some try-catch blocks, but I was wondering..

5

answers

How to return a class object by reference in C++?

I have a class called Object which stores some data. I would like to return it by reference using a function like this: Object& return_Object(); Then, in my code, I would call it like this..

10

answers

How to make a gui in python

I was wondering if any of you know where I could find a simple tutorial on the web maybe to make a very simplistic gui. I have no idea how to start out in code to make one so I need your help. What I ..

1

answers

Select * from subquery

I'd like to get sum of column1, sum of column2 and total sum. In Postgres I can do it this way: (notice the star) SELECT *, a+b AS total_sum FROM ( SELECT SUM(column1) AS a, SUM(column2) AS b F..

7

answers

What's the best practice to round a float to 2 decimals?

I'm using eclipse + Android SDK. I need to round a float value to 2 decimals. I usually use the next "trick" using Math library. float accelerometerX = accelerometerX * 100; accelerometerX = rou..

3

answers

How can I reference a commit in an issue comment on GitHub?

I find a lot of answers on how to reference a GitHub issue in a git commit (using the #xxx notation). I'd like to reference a commit in my comment, generating a link to the commit details page?..

14

answers

How to print all key and values from HashMap in Android?

I am very new for Android development, and I am trying to use HashMap in Android sample project. Now, am doing sample project for learn android. I just store keys and values in HashMap, i want to show..

3

answers

Should I use "camel case" or underscores in python?

So which is better and why? def my_function(): or def myFunction(): ..

5

answers

Why do I need 'b' to encode a string with Base64?

Following this python example, I encode a string as Base64 with: >>> import base64 >>> encoded = base64.b64encode(b'data to be encoded') >>> encoded b'ZGF0YSB0byBiZSBlbmNvZ..

6

answers

Use jquery click to handle anchor onClick()

I have a set of dynamically generated anchor tags in a for loop as follows: <div id = "solTitle"> <a href = "#" id = "' + tagId + '" onClick = "openSolution();"> ' + solTitle + '</a&g..

10

answers

How to set 24-hours format for date on java?

I have been developing Android application where I use this code: Date d=new Date(new Date().getTime()+28800000); String s=new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format(d); I need to get date ..

3

answers

A Simple AJAX with JSP example

I am trying to learn AJAX with JSP and I have written the following code. This does not seem to be working. Kindly help: This is my configuration_page.jsp <html> <head> <..

5

answers

Convert array to string in NodeJS

I want to convert an array to string in NodeJS. var aa = new Array(); aa['a'] = 'aaa'; aa['b'] = 'bbb'; console.log(aa.toString()); But it doesn't work. Anyone knows how to convert?..

5

answers

How to change the default charset of a MySQL table?

There is a MySQL table which has this definition taken from SQLYog Enterprise : Table Create Table ----------------- -----------------------..

2

answers

How to initialize a vector in C++

I want to initialize a vector like we do in case of an array. Example int vv[2] = {12, 43}; But when I do it like this, vector<int> v(2) = {34, 23}; OR vector<int> v(2); v = {0, 9}..

3

answers

How to return a complex JSON response with Node.js?

Using nodejs and express, I'd like to return one or multiple objects (array) using JSON. In the code below I output one JSON object at a time. It works but this isn't exactly what I want. The response..

11

answers

How to normalize a 2-dimensional numpy array in python less verbose?

Given a 3 times 3 numpy array a = numpy.arange(0,27,3).reshape(3,3) # array([[ 0, 3, 6], # [ 9, 12, 15], # [18, 21, 24]]) To normalize the rows of the 2-dimensional array I thought..

9

answers

Check image width and height before upload with Javascript

I have a JPS with a form in which a user can put an image: <div class="photo"> <div>Photo (max 240x240 and 100 kb):</div> <input type="file" name="photo" id="photoInput" ..

8

answers

Using regular expression in css?

I have an html page with divs that have id(s) of the form s1, s2 and so on. <div id="sections"> <div id="s1">...</div> <div id="s2">...</div> ... </div> ..

20

answers

How to calculate time elapsed in bash script?

I print the start and end time using date +"%T", which results in something like: 10:33:56 10:36:10 How could I calculate and print the difference between these two? I would like to get something ..

2

answers

Linux configure/make, --prefix?

Bear with me, this one's not very easy to explain... I'm trying to configure, make and make install Xfce into my buildroot build directory. When configuring I'm using --prefix=/home/me/somefolder/m..

17

answers

Manually map column names with class properties

I am new to the Dapper micro ORM. So far I am able to use it for simple ORM related stuff but I am not able to map the database column names with the class properties. For example, I have the followi..

10

answers

Convert a SQL Server datetime to a shorter date format

I have a datetime column in SQL Server that gives me data like this 10/27/2010 12:57:49 pm and I want to query this column but just have SQL Server return the day month and year - eg. 2010 10 27 or so..

13

answers

Sort objects in an array alphabetically on one property of the array

Let's say you have a JavaScript class like this var DepartmentFactory = function(data) { this.id = data.Id; this.name = data.DepartmentName; this.active = data.Active; } Let's say you t..

17

answers

Creating default object from empty value in PHP?

I see this error only after upgrading my PHP environment to PHP 5.4 and beyond. The error points to this line of code: Error: Creating default object from empty value Code: $res->success = ..

6

answers

What's the difference between lists enclosed by square brackets and parentheses in Python?

>>> x=[1,2] >>> x[1] 2 >>> x=(1,2) >>> x[1] 2 Are they both valid? Is one preferred for some reason?..