Some Of The Best Answers From Latest Asked Questions

6

answers

jQuery find and replace string

I have somewhere on website a specific text, let's say "lollypops", and I want to replace all the occurrences of this string with "marshmellows". The problem is that I don't know where exactly the tex..

10

answers

Check if a file exists locally using JavaScript only

I want to check if a file exists locally, where the HTML file is located. It has to be JavaScript. JavaScript will never be disabled. jQuery is not good but can do. By the way, I am making a titanium..

16

answers

How do format a phone number as a String in Java?

I have been storing phone numbers as longs and I would like to simply add hyphens when printing the phone number as a string. I tried using DecimalFormat but that doesn't like the hyphen. Probably be..

5

answers

How to check whether an object has certain method/property?

Using dynamic pattern perhaps? You can call any method/property using the dynamic keyword, right? How to check whether the method exist before calling myDynamicObject.DoStuff(), for example?..

6

answers

How to import spring-config.xml of one project into spring-config.xml of another project?

I have two projects with the name simple-core-impl and simple-core-web. Both projects are spring based and both have a parent project name simple-core. I have simple-impl-config.xml in simple-core-..

31

answers

JavaScript check if variable exists (is defined/initialized)

Which method of checking if a variable has been initialized is better/correct? (Assuming the variable could hold anything (string, int, object, function, etc.)) if (elem) { // or !elem or if (type..

6

answers

How to test for $null array in PowerShell

I'm using an array variable in PowerShell 2.0. If it does not have a value, it will be $null, which I can test for successfully: PS C:\> [array]$foo = $null PS C:\> $foo -eq $null True But w..

4

answers

wildcard * in CSS for classes

I have these divs that I'm styling with .tocolor, but I also need the unique identifier 1,2,3,4 etc. so I'm adding that it as another class tocolor-1. <div class="tocolor tocolor-1"> tocolor..

10

answers

Add CSS or JavaScript files to layout head from views or partial views

Layout pages head: <head> <link href="@Url.Content("~/Content/themes/base/Site.css")" rel="stylesheet" type="text/css" /> </head> A View (AnotherView) from the appli..

9

answers

mysqldump data only

I am looking for the syntax for dumping all data in my mysql database. I don't want any table information...

5

answers

Add some word to all or some rows in Excel?

If I want to add some word before each number of a column, how can I do that. 10 s 123 24 c 235 33 s 345 46 s 346 59 s 546 62 c 277 I mean : for example I put the word "k" before each number ..

12

answers

How to deploy a war file in Tomcat 7

I have copied the sample.war file into the webapps directory of Tomcat, and I can access localhost:8080. Now how will Tomcat deploy it, I mean do I need to open it in browser? How can I access the ap..

21

answers

Kill a postgresql session/connection

How can I kill all my postgresql connections? I'm trying a rake db:drop but I get: ERROR: database "database_name" is being accessed by other users DETAIL: There are 1 other session(s) using the d..

7

answers

Access localhost from the internet

I need to forward my localhost for a short period of time for testing purposes. It has to be accessed from the public internet. How can I achieve this? Thanks...

6

answers

Yahoo Finance All Currencies quote API Documentation

I've being using this feed for a long time, I believe Apple does it as well in one of the mac widgets. but what is really curious is that I simply can't find any documentation for it, I've tried googl..

3

answers

jQuery - determine if input element is textbox or select list

How would I determine whether the element returned by an :input filter in jQuery is a textbox or select list? I want to have a different behavior for each ( textbox returns text value, select returns..

1

answers

How to make war file in Eclipse

What is the easy way to make war file? My project is working when i right click run on server, but i want to deploy on tomcat server. I have installed m2clipse but it gave me an error. Is maven com..

27

answers

Better way to Format Currency Input editText?

I have an editText, starting value is $0.00. When you press 1, it changes to $0.01. Press 4, it goes to $0.14. Press 8, $1.48. Press backspace, $0.14, etc. That works, the problem is, if somebody man..

11

answers

Extract source code from .jar file

Is there a way to extract the source code from an executable .jar file (Java ME)? ..

8

answers

Error: Address already in use while binding socket with address but the port number is shown free by `netstat`

I tried to bind my socket(server socket) at port number 8000. It worked and did the job for me. At the end of the code I close the socket as well. The very next instant I run my code again and it show..

2

answers

How can I link a photo in a Facebook album to a URL

On a Facebook page I have photos with examples of our work. I would like to link each photo to a URL with details of this work. Is there a way to link a photo that is already in a Facebook album to a ..

5

answers

Redirecting from HTTP to HTTPS with PHP

I'm working on a shopping cart website and I would like to redirect the user to a HTTPS page when he's entering his billing details and maintain the HTTPS connection for the next pages until he logs o..

5

answers

Deep copy of a dict in python

I would like to make a deep copy of a dict in python. Unfortunately the .deepcopy() method doesn't exist for the dict. How do I do that? >>> my_dict = {'a': [1, 2, 3], 'b': [4, 5, 6]} >&g..

44

answers

How to show soft-keyboard when edittext is focused

I want to automatically show the soft-keyboard when an EditText is focused (if the device does not have a physical keyboard) and I have two problems: When my Activity is displayed, my EditText is fo..

7

answers

How do I create a file at a specific path?

In python I´m creating a file doing: f = open("test.py", "a") where is the file created? How can I create a file on a specific path? f = open("C:\Test.py", "a") returns error...

12

answers

How to install Java SDK on CentOS?

I have CentOS 5, but I don't know the steps to install Java SDK on Linux. Where to download the RPM file and what can I do next to fully install that? Then I need to install Tomcat. Or is there any..

1

answers

How to abort an interactive rebase if --abort doesn't work?

I've got myself into a muddle via an interactive rebase, and I now wish to abort it. (i.e. go back to the point before I was dropped into interactive rebase mode, in my case via git pull --rebase.) ..

7

answers

How do you change the text in the Titlebar in Windows Forms?

I am trying to set a condition that would change the writing inside the title bar... But how do I change the title bar text?..

13

answers

PHP session handling errors

I have this at the very top of my send.php file: ob_start(); @session_start(); //some display stuff $_SESSION['id'] = $id; //$id has a value header('location: test.php'); And the following at the..

7

answers

ant warning: "'includeantruntime' was not set"

I receive the following warning: [javac] build.xml:9: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds What does this mean?..

5

answers

How to find out if an installed Eclipse is 32 or 64 bit version?

How can I find out if a specific Eclipse instance on my (Windows 7) PC is the 32-bit or 64-bit version? I've checked the About screen and the maze of dialogs one can call from there, but I didn't fin..

5

answers

WPF button click in C# code

I have an array of button which is dynamically generated at run time. I have the function for button click in my code, but I can't find a way to set the button's click name in code. So, what is the..

3

answers

TABLOCK vs TABLOCKX

what is the difference between TABLOCK and TABLOCKX http://msdn.microsoft.com/en-us/library/ms187373.aspx states that TABLOCK is a shared lock while TABLOCKX is an exclusive lock. Is the first maybe o..

8

answers

JavaScript checking for null vs. undefined and difference between == and ===

How do I check a variable if it's null or undefined and what is the difference between the null and undefined? What is the difference between == and === (it's hard to search Google for "===" )? ..

5

answers

How to connect android wifi to adhoc wifi?

I'm new on the android system. Is this correct, the android 2.2.1 WIFI only detects non-ad hoc wireless network? I was wondering if there's a way to connect my android to an ad hoc network set-up from..

17

answers

Integer to hex string in C++

How do I convert an integer to a hex string in C++? I can find some ways to do it, but they mostly seem targeted towards C. It doesn't seem there's a native way to do it in C++. It is a pretty simple..

22

answers

Django CSRF check failing with an Ajax POST request

I could use some help complying with Django's CSRF protection mechanism via my AJAX post. I've followed the directions here: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ I've copied the AJ..

10

answers

How to watch for array changes?

In Javascript, is there a way to be notified when an array is modified using push, pop, shift or index-based assignment? I want something that would fire an event that I could handle. I know about th..

5

answers

How to get the Google Map based on Latitude on Longitude?

I want to display Google map in my web page based on longitude and latitude. First user want to enter longitude and latitude in two text box's. Then click submit button I have to display appropriate l..

15

answers

Is Constructor Overriding Possible?

What i know is, the compiler writes a default no argument constructor in the byte code. But if we write it ourselves, that constructor is called automatically. Is this phenomena a constructor overridi..

2

answers

SQL join format - nested inner joins

I have the following SQL statement in a legacy system I'm refactoring. It is an abbreviated view for the purposes of this question, just returning count(*) for the time being. SELECT COUNT(*) FROM Ta..

10

answers

How to remove all leading zeroes in a string

If I have a string 00020300504 00000234892839 000239074 how can I get rid of the leading zeroes so that I will only have this 20300504 234892839 239074 note that the number above was generated r..

6

answers

'float' vs. 'double' precision

The code float x = 3.141592653589793238; double z = 3.141592653589793238; printf("x=%f\n", x); printf("z=%f\n", z); printf("x=%20.18f\n", x); printf("z=%20.18f\n", z); will give you the output x=..

5

answers

The application has stopped unexpectedly: How to Debug?

Please note, unlike many other questions having the subject title "application has stopped unexpectedly", I am not asking for troubleshooting a particular problem. Rather, I am asking for an outline ..

14

answers

Git blame -- prior commits?

Is it possible to see who edited a specific line before the commit reported by git blame, like a history of commits for a given line? For example, I run the following (on the superb uncrustify projec..

20

answers

Throw away local commits in Git

Due to some bad cherry-picking, my local Git repository is currently five commits ahead of the origin, and not in a good state. I want to get rid of all these commits and start over again. Obviously,..

3

answers

PowerShell: Comparing dates

I am querying a data source for dates. Depending on the item I am searching for, it may have more than date associated with it. get-date ($Output | Select-Object -ExpandProperty "Date") An example ..

18

answers

What is the { get; set; } syntax in C#?

I am learning ASP.NET MVC and I can read English documents, but I don't really understand what is happening in this code: public class Genre { public string Name { get; set; } } What does this ..

9

answers

Get next element in foreach loop

I have a foreach loop and I want to see if there is a next element in the loop so I can compare the current element with the next. How can I do this? I've read about the current and next functions but..

4

answers

How to split string using delimiter char using T-SQL?

I have this long string in one of the columns of the table. I want to get only specific information:- My Table structure:- Col1 = '123' Col2 = 'AAAAA' Col3 = 'Clent ID = 4356hy|Client Name = B B BOB|..

9

answers

How to get a list of all files that changed between two Git commits?

Due to bureaucracy, I need to get a list of all changed files in my repository for a report (I started with existing source code). What should I run to get this list?..

2

answers

Create an Android GPS tracking application

Recently, I've taken up android development as a hobby and was looking to develop an application that can find and track a users position using Google Maps. Once the application has a GPS lock, it ca..

6

answers

How do I pass a URL with multiple parameters into a URL?

Basically I'm trying to pass a URL like this: www.foobar.com/?first=1&second=12&third=5 into a URL like this: http://www.facebook.com/sharer.php?&t=FOOBAR&u=http://www.foobar.com/f..

5

answers

Find character position and update file name

What function might I use to find a character position in a string using PowerShell 2.0. i.e I would use CHARINDEX or PATINDEX if using SQL Server. I looked at using the Select-String cmdlet but i..

12

answers

Disabling vertical scrolling in UIScrollView

There is an option in IB to uncheck vertical scrolling on a scrollview, but it doesnt seem to work. How can the scrollview be set to only scroll horizontally, and not vertically in the code rather th..

12

answers

How to get root access on Android emulator?

I have All Android SDK versions(from 1.5 to 2.3.3), and I tried many methods for getting root in Android emulator. I don't use any Android device and test everything on emulator(AVD). I need to get r..

25

answers

How would I run an async Task<T> method synchronously?

I'm learning about async/await, and ran into a situation where I need to call an async method synchronously. How can I do that? Async method: public async Task<Customers> GetCustomers() { ..

5

answers

jQuery Remove string from string

I am trying to remove a string from a string in jQuery. Here is the string: username1, username2 and username3 like this post. I would like to remove username1, from this list. I tried adding the ..

5

answers

Git remote branch deleted, but still it appears in 'branch -a'

Let's say I had a branch named coolbranch in my repository. Now, I decided to delete it (both remotely and locally) with: git push origin :coolbranch git branch -D coolbranch Great! Now the branch..

11

answers

Open fancybox from function

I am trying to open a fancybox from a function I have - in short my HTML code looks like this; <a href="#modalMine" onclick="myfunction(this); return false;"> click </a> and a part of..

33

answers

How to convert an enum type variable to a string?

How to make printf to show the values of variables which are of an enum type? For instance: typedef enum {Linux, Apple, Windows} OS_type; OS_type myOS = Linux; and what I need is something like ..

13

answers

Unix: How to delete files listed in a file

I have a long text file with list of file masks I want to delete Example: /tmp/aaa.jpg /var/www1/* /var/www/qwerty.php I need delete them. Tried rm `cat 1.txt` and it says the list is to..

22

answers

What is the use of "assert"?

I have been reading some source code and in several places I have seen the usage of assert. What does it mean exactly? What is its usage?..

17

answers

Offset a background image from the right using CSS

Is there a way to position a background image a certain number of pixels from the right of its element? For example, to position something a certain number of pixels (say, 10) from the left, this is ..

15

answers

Declare a const array

Is it possible to write something similar to the following? public const string[] Titles = { "German", "Spanish", "Corrects", "Wrongs" }; ..

11

answers

Read a javascript cookie by name

I have set a cookie using document.cookie = 'MYBIGCOOKIE=' + value + '; expires=' + now.toGMTString() + '; path=/'; Now there are between 5 and 10 cookies set on this site, is there ..

6

answers

javascript jquery radio button click

I have 2 radio buttons and jquery running. <input type="radio" name="lom" value="1" checked> first <input type="radio" name="lom" value="2"> second Now, with a button I can set onClick ..

11

answers

Regex to validate password strength

My password strength criteria is as below : 8 characters length 2 letters in Upper Case 1 Special Character ([email protected]#$&*) 2 numerals (0-9) 3 letters in Lower Case Can somebody please give me regex..

6

answers

Get Client Machine Name in PHP

This program only returns the client machine name in localhost only echo gethostbyaddr($_SERVER['REMOTE_ADDR']); If it is run from an online server, then computer name is not shown and some other in..

10

answers

Get the current time in C

I want to get the current time of my system. For that I'm using the following code in C: time_t now; struct tm *mytime = localtime(&now); if ( strftime(buffer, sizeof buffer, "%X", mytime) ) { ..

6

answers

JavaScript: location.href to open in new window/tab?

I have a JavaScript file from a third party developer. It has a has link which replaces the current page with the target. I want to have this page opened in a new tab. This is what I have so far: if..

7

answers

UnicodeEncodeError: 'ascii' codec can't encode character u'\xef' in position 0: ordinal not in range(128)

I want to parse my XML document. So I have stored my XML document as below class XMLdocs(db.Expando): id = db.IntegerProperty() name=db.StringProperty() content=db.BlobProperty() ..

4

answers

How to make a HTTP PUT request?

What is the best way to compose a rest PUT request in C#? The request has to also send an object not present in the URI...

2

answers

For loop in Objective-C

Where should I use the for loop and where should I use the for in loop? I would like to know the difference between them...

9

answers

Escape Character in SQL Server

I want to use quotation with escape character. How can I do? I have received error in SQL Server Unclosed quotation mark after the character string. I'm writing SQL query in a varchar variable but I..

3

answers

Append text with .bat

I want to create a log of every operation processed in a batch file and used the following but to no avail. How do I fix it (the file was not created)? REM>> C:\"VTS\ADVANCED TOOLS\SYSTEM\LOG\A..

18

answers

Change default text in input type="file"?

I want to change default text on button that is "Choose File" when we use input="file". How can I do this? Also as you can see in image button is on left side of text. How can I put it on right sid..

31

answers

org.xml.sax.SAXParseException: Content is not allowed in prolog

I have a Java based web service client connected to Java web service (implemented on the Axis1 framework). I am getting following exception in my log file: Caused by: org.xml.sax.SAXParseException:..

4

answers

How to change current working directory using a batch file

I need some help in writing a batch file. I have a path stored in a variable root as follows: set root=D:\Work\Root Then I am changing my working directory to this root as follows: cd %root% Whe..

13

answers

Find current directory and file's directory

In Python, what commands can I use to find: the current directory (where I was in the terminal when I ran the Python script), and where the file I am executing is? ..

9

answers

Function for Factorial in Python

How do I go about computing a factorial of an integer in Python?..

3

answers

SaveFileDialog setting default path and file type?

I'm using SaveFileDialog.SaveFile. How can I get it to the default (operating system) drive letter and also limit the options to show only .BIN as the file extension? I tried reading the docs on MSDN..

11

answers

How to change column datatype in SQL database without losing data

I have SQL Server database and I just realized that I can change the type of one of the columns from int to bool. How can I do that without losing the data that is already entered into that table? ..

11

answers

CSS opacity only to background color, not the text on it?

Can I assign the opacity property to the background property of a div only and not to the text on it? I've tried: background: #CCC; opacity: 0.6; but this doesn't change the opacity...

15

answers

NoClassDefFoundError in Java: com/google/common/base/Function

When I executing the following code: public static void main(String[] args) { try { FirefoxDriver driver = new FirefoxDriver(); driver.get("http:www.yahoo.com"); } catch (NoC..

4

answers

How do I use valgrind to find memory leaks?

How do I use valgrind to find the memory leaks in a program? Please someone help me and describe the steps to carryout the procedure? I am using Ubuntu 10.04 and I have a program a.c, please help me..

10

answers

How to cast ArrayList<> from List<>

Can somebody please explain me why I can't cast List<> to ArrayList<> with first approach and I do with second one? Thank you. First approach: ArrayList<Task> tmp = ((ArrayList<..

1

answers

-bash: syntax error near unexpected token `newline'

To reset the admin password of SolusVM I am executing the following command: php /usr/local/solusvm/scripts/pass.php --type=admin --comm=change --username=<ADMINUSERNAME> When doing so, the f..

5

answers

Android Closing Activity Programmatically

What is the equivalent operation within an activity to navigating away from the screen. Like when you press the back button, the activity goes out of view. How can this be called from inside an activ..

33

answers

Build error: "The process cannot access the file because it is being used by another process"

I've got a C# webforms app, that until today had been working just swimmingly. Now today, all of a sudden, every time I try run the app, I get a file locking error: Unable to copy file "obj\Debu..

3

answers

Which MySQL datatype to use for an IP address?

Possible Duplicate: How to store an IP in mySQL I want to get the IP address from $_SERVER['REMOTE_ADDR'] and some other $_SERVER variables, which datatype is the right one for this? Is it..

8

answers

How to change letter spacing in a Textview?

How can i change letter spacing in a textview? Will it help if I have HTML text in it (I cannot use webview in my code). P.S. I'm using my own typeface in the textview with HTML text...

27

answers

Why am I getting 'Assembly '*.dll' must be strong signed in order to be marked as a prerequisite.'?

I'm trying to compile my excel addin using C# 4.0, and started to get this problem when building my project in Visual Studio. It's important to tell you that I haven't had this problem before. What co..

13

answers

Running Facebook application on localhost

I am planning to connect to Facebook chat from my localhost. I will need to get the session key from Facebook. When I give the site URL as localhost:8080 or ip-address:8080 it does not work. I read ..

10

answers

How to add a primary key to a MySQL table?

This is what I tried but it fails: alter table goods add column `id` int(10) unsigned primary AUTO_INCREMENT; Does anyone have a tip?..

7

answers

If using maven, usually you put log4j.properties under java or resources?

Where should I put the log4j.properties file when using the conventional Maven directories? ..

6

answers

connecting to MySQL from the command line

How can you connect to MySQL from the command line in a Mac? (i.e. show me the code) I'm doing a PHP/SQL tutorial, but it starts by assuming you're already in MySQL...

4

answers

How to create unit tests easily in eclipse

I want to create unit tests easily by just selecting method. Is there a tool in eclipse that does that. It should support templates. I should be able to create positive test as well as negative tests...

2

answers

Removing the first 3 characters from a string

What is the most efficient way to remove the first 3 characters of a string? For example: 'apple' change to 'le' 'a cat' change to 'at' ' a b c'change to 'b c' ..

4

answers

Why would we call cin.clear() and cin.ignore() after reading input?

Google Code University's C++ tutorial used to have this code: // Description: Illustrate the use of cin to get input // and how to recover from errors. #include <iostream> using namespace std;..