Some Of The Best Answers From Latest Asked Questions

6

answers

RegEx for valid international mobile phone number

I use Clickatell to send SMSes to clients' mobile phones. Is there a standardised regular expression for all valid mobile phone numbers, e.g. +27 123 4567? I'd roll my own, but I'm worried about miss..

10

answers

moving committed (but not pushed) changes to a new branch after pull

I've done a fair bit of work ("Your branch is ahead of 'origin/master' by 37 commits.") which really should have gone into its own branch rather than into master. These commits only exist on my local..

4

answers

How can I generate an INSERT script for an existing SQL Server table that includes all stored rows?

I'm looking for a way to generate a "Create and insert all rows" script with SQL Management Studio 2008 R2. I know that I can create a "create table" script. I can also create an "insert in" script,..

15

answers

Detect if value is number in MySQL

Is there a way to detect if a value is a number in a MySQL query? Such as SELECT * FROM myTable WHERE isANumber(col1) = true ..

21

answers

Difference between classification and clustering in data mining?

Can someone explain what the difference is between classification and clustering in data mining? If you can, please give examples of both to understand the main idea...

7

answers

How to add items into a numpy array

I need to accomplish the following task: from: a = array([[1,3,4],[1,2,3]...[1,2,1]]) (add one element to each row) to: a = array([[1,3,4,x],[1,2,3,x]...[1,2,1,x]]) I have tried doing stuff lik..

35

answers

Several ports (8005, 8080, 8009) required by Tomcat Server at localhost are already in use

I'm getting the following error when I try to run a simple JSP program on Tomcat in Eclipse. Several ports (8005, 8080, 8009) required by Tomcat v6.0 Server at localhost are already in use. The s..

17

answers

Add line break to 'git commit -m' from the command line

I am using Git from the command line and am trying to add a line break to the commit message (using git commit -m "") without going into Vim. Is this possible?..

7

answers

Sending HTML Code Through JSON

I've got a php script which generates HTML content. Is there a way to send back that HTML content through JSON to my webpage from the php script?..

7

answers

Regex empty string or email

I found a lot of Regex email validation in SO but I did not find any that will accept an empty string. Is this possible through Regex only? Accepting either empty string or email only? I want to hav..

1

answers

How to put attributes via XElement

I have this code: XElement EcnAdminConf = new XElement("Type", new XElement("Connections", new XElement("Conn"), // Conn.SetAttributeValue("Server", comboBox1.Text); // Conn.SetAttrib..

13

answers

javac error: Class names are only accepted if annotation processing is explicitly requested

I get this error when I compile my java program: error: Class names, 'EnumDevices', are only accepted if annotation processing is explicitly requested 1 error Here is the java code (I'm running t..

11

answers

How to find the UpgradeCode and ProductCode of an installed application in Windows 7

I have an application installed on my machine. I also have its source code but somehow the ProductCode and UpgradeCode of this application were changed. Now I want to get the UpgradeCode and ProductC..

3

answers

Replace Div with another Div

I have this thing I m trying to do. I have a main picture of a map and within that map there are regions. These regions have hot spots on them so you can click them and it will replace the whole map w..

11

answers

Count number of tables in Oracle

Like MySQL has "SHOW TABLES" , how do you count tables in Oracle DB. Little bit of research gave me this query: select owner, count(*) from dba_tables So like MySQL has a standard command, does Ora..

17

answers

How to decide when to use Node.js?

I am new to this kind of stuff, but lately I've been hearing a lot about how good Node.js is. Considering how much I love working with jQuery and JavaScript in general, I can't help but wonder how to ..

5

answers

batch/bat to copy folder and content at once

I'm writing a batch script that does a copy. I want to script it to copy an entire folder. When I want to copy a single file, I do this copy %~dp0file.txt file.txt If I have a folder with this st..

9

answers

Changing the child element's CSS when the parent is hovered

First of all, I'm assuming this is too complex for CSS3, but if there's a solution in there somewhere, I'd love to go with that instead. The HTML is pretty straightforward. <div class="parent">..

6

answers

ini_set("memory_limit") in PHP 5.3.3 is not working at all

I had this working before : echo ini_get("memory_limit")."\n"; ini_set("memory_limit","256M"); echo ini_get("memory_limit")."\n"; That would input this : 32M 256M on a php script executed by c..

9

answers

printing out a 2-D array in Matrix format

How can I print out a simple int [][] in the matrix box format like the format in which we handwrite matrices in. A simple run of loops doesn't apparently work. If it helps i'm trying to compile this ..

11

answers

How can I dynamically add items to a Java array?

In PHP, you can dynamically add elements to arrays by the following: $x = new Array(); $x[] = 1; $x[] = 2; After this, $x would be an array like this: {1,2}. Is there a way to do something similar..

11

answers

Emulate a 403 error page

I know you can send a header that tells the browser this page is forbidden like: header('HTTP/1.0 403 Forbidden'); But how can I also display the custom error page that has been created on the serv..

6

answers

make arrayList.toArray() return more specific types

So, normally ArrayList.toArray() would return a type of Object[]....but supposed it's an Arraylist of object Custom, how do I make toArray() to return a type of Custom[] rather than Object[]?..

16

answers

jQuery returning "parsererror" for ajax request

Been getting a "parsererror" from jquery for an Ajax request, I have tried changing the POST to a GET, returning the data in a few different ways (creating classes, etc.) but I cant seem to figure out..

12

answers

How to stretch a fixed number of horizontal navigation items evenly and fully across a specified container

I'd like to stretch 6 nav items evenly across a 900px container, with an even amount of white space between. For instance... ---| 900px Container |--- ---| HOME ABOUT BASIC SERVICES SPECIA..

4

answers

postgresql - replace all instances of a string within text field

In postgresql, how do I replace all instances of a string within a database column? Say I want to replace all instances of cat with dog, for example. What's the best way to do this?..

13

answers

MySQL: Fastest way to count number of rows

Which way to count a number of rows should be faster in MySQL? This: SELECT COUNT(*) FROM ... WHERE ... Or, the alternative: SELECT 1 FROM ... WHERE ... // and then count the results with a buil..

13

answers

jQuery & CSS - Remove/Add display:none

I have a div with this class : .news{ width:710px; float:left; border-bottom:1px #000000 solid; font-weight:bold; display:none; } And I'd like with some jQuery methods remove that displa..

5

answers

How to find which git branch I am on when my disk is mounted on other server

Our git repo is on a Linux server; I can be on the master branch or create a new branch that I can go inside and use. Our git repo disk is mounted on AIX box to build (I can see git directory in the ..

7

answers

Which is the best library for XML parsing in java

I'm searching the java library for parsing XML (complex configuration and data files), I googled a bit but couldn't found other than dom4j (Seems like they are working on V2).. I have taken look at co..

12

answers

What is the maximum number of edges in a directed graph with n nodes?

What is the maximum number of edges in a directed graph with n nodes? Is there any upper bound?..

12

answers

Where does Hive store files in HDFS?

I'd like to know how to find the mapping between Hive tables and the actual HDFS files (or rather, directories) that they represent. I need to access the table files directly. Where does Hive store i..

4

answers

Java Project: Failed to load ApplicationContext

I have a Java Project in which I am writing a simple JUNIT test case. I have copied the applicatinoContext.xml file into the root java source directory. I've tried it with some of the recommended se..

10

answers

How can I check if a background image is loaded?

I want to set a background image on the body tag, then run some code - like this: $('body').css('background-image','http://picture.de/image.png').load(function() { alert('Background image done lo..

7

answers

How do I do logging in C# without using 3rd party libraries?

I would like to implement logging in my application, but would rather not use any outside frameworks like log4net. So I would like to do something like DOS's echo to a file. What is the most effectiv..

8

answers

Why are C++ inline functions in the header?

NB This is not a question about how to use inline functions or how they work, more why they are done the way they are. The declaration of a class member function does not need to define a function as..

19

answers

Android: Force EditText to remove focus?

I would like to be able to remove the focus from the EditText. For example if the Keyboard appears, and the user hides it with the back button, I would like the focus and the cursor to disappear. How ..

7

answers

How to set UTF-8 encoding for a PHP file

I have a PHP script called : http://cyber-flick.com/apiMorpho.php?method=getMorphoData&word=kot That displays some data in plain text: CzÄ?L?Ä? mowy: rzeczownik Przypadek: dopeL?niacz Rod..

12

answers

Sorting std::map using value

I need to sort an std::map by value rather than by key. Is there an easy way to do it? I got one solution from the follwing thread: std::map sort by data? Is there a better solution? map<long, ..

15

answers

How to install latest version of Node using Brew

The latest version of NodeJs right now is 0.4.1 The command brew install node right now, installs 0.2.6 - which is not ideal. I would like 0.4.1 I've looked at this list of commands for brew and tri..

21

answers

Cloning an Object in Node.js

What is the best way to clone an object in node.js e.g. I want to avoid the situation where: var obj1 = {x: 5, y:5}; var obj2 = obj1; obj2.x = 6; console.log(obj1.x); // logs 6 The object may well..

7

answers

What is Model in ModelAndView from Spring MVC?

Having this basic function protected ModelAndView handleRequestInternal(...) { ... return new ModelAndView("welcomePage", "WelcomeMessage", message); } I know that this will return modeland..

4

answers

What's the best practice using a settings file in Python?

I have a command line script that I run with a lot of arguments. I have now come to a point where I have too many arguments, and I want to have some arguments in dictionary form too. So in order to s..

9

answers

How to replace case-insensitive literal substrings in Java

Using the method replace(CharSequence target, CharSequence replacement) in String, how can I make the target case-insensitive? For example, the way it works right now: String target = "FooBar"; targ..

6

answers

Can I avoid the native fullscreen video player with HTML5 on iPhone or android?

I've built a web app that uses the HTML5 tag and JavaScript code that renders other content synchronized with the running video. It works great in desktop browsers: Firefox, Chrome, and Safari. On an..

6

answers

Ruby value of a hash key?

I've got a list of values that are in a Ruby hash. Is there a way to check the value of the key and if it equals "X", then do "Y"? I can test to see if the hash has a key using hash.has_key?, but no..

2

answers

AttributeError: 'list' object has no attribute 'encode'

I have a list of unicode objects and want to encode them to utf-8, but encoding doesn't seem to work. the code is here : >>> tmp = [u' test context'] >>> tmp.encode('utf-8') Trac..

8

answers

How to change the decimal separator of DecimalFormat from comma to dot/point?

I have this little crazy method that converts BigDecimal values into nice and readable Strings. private String formatBigDecimal(BigDecimal bd){ DecimalFormat df = new DecimalFormat(); df.setM..

20

answers

Eclipse IDE for Java - Full Dark Theme

Is there any way to completely turn Eclipse to a dark IDE? Here's a Picture of what I'm asking: I don't mind doing 1 hour of work to do something like this :D EDIT: As Konstantin Komissarchik said, I ..

6

answers

What is a good game engine that uses Lua?

I know Love2D and Corona SDK (for mobile devices). Is there any other game engines that use Lua you recommend?..

4

answers

How to fire AJAX request Periodically?

<meta http-equiv="Refresh" Content="5"> This script reloads or refresh the page after every 5 seconds. But I want to do it using jQuery and AJAX call. Is it possible? ..

5

answers

Rails 3 check if attribute changed

Need to check if a block of attributes has changed before update in Rails 3. street1, street2, city, state, zipcode I know I could use something like if @user.street1 != params[:user][:street1] t..

8

answers

Best lightweight web server (only static content) for Windows

I got application server running in Windows – IIS6.0 with Zend Server to execute PHP. I am looking for lightweight static content only web server on this same machine which will relive IIS form hand..

12

answers

PHP errors NOT being displayed in the browser [Ubuntu 10.10]

I'm new to PHP and the whole LAMP stack but I've managed to get it up and running on my Ubuntu 10.10 system. Everything seems to be working with the exception of error reposting in the browser which I..

5

answers

Completely removing phpMyAdmin

I installed virtualmin and phpmyadmin separately using the apt-get command. phpMyAdmin didn't work because of Virtualmin's security settings (suexec). When I visit mydomain.com/phpmyadmin, it would do..

11

answers

JavaScript, Node.js: is Array.forEach asynchronous?

I have a question regarding the native Array.forEach implementation of JavaScript: Does it behave asynchronously? For example, if I call: [many many elements].forEach(function () {lots of work to do}..

22

answers

How do I get a Date without time in Java?

Continuing from Stack Overflow question Java program to get the current date without timestamp: What is the most efficient way to get a Date object without the time? Is there any other way than these..

13

answers

convert datetime to date format dd/mm/yyyy

I have a DateTime object 2/19/2011 12:00:00 AM. I want to convert this object to a string 19/2/2011. Please help me to convert DateTime to string format...

5

answers

Simple int to char[] conversion

I have a simple question How to simply convert integer (getting values 0-8) to char, e.g. char[2] in C? Thanks..

7

answers

Autocomplete syntax for HTML or PHP in Notepad++. Not auto-close, autocompelete

How can I get autocompletion of syntax for HTML or PHP in Notepad++? Not auto-close, I am looking for autocompelete...

30

answers

Android Drawing Separator/Divider Line in Layout?

I would like to draw a line right in the middle of a layout and use it as a separator of other items like TextView. Is there a good widget for this. I don't really want to use an image as it would be..

1

answers

Capture the screen shot using .NET

Possible Duplicate: How May I Capture the Screen in a Bitmap? I need to make an application that captures a snapshot of the current screen whenever a particular button is hit. I have searc..

7

answers

Preserve Line Breaks From TextArea When Writing To MySQL

I'm using a textarea to enable users to input comments. However, if the users enters new lines, the new lines don't appear when they are outputted. Is there any way to make the line breaks stay. An..

7

answers

Change GridView row color based on condition

I want to change a particular row color of gridview based on some condition, I am using ASP.NET with c#. Thank you...

10

answers

Can I start the iPhone simulator without "Build and Run"?

I want to delete an app in the simulator before I "build and run". How can I start the simulator so I can do the deletion? If I start it by "build and run" I get a long log output that takes a while b..

11

answers

How to center a checkbox in a table cell?

The cell contains nothing but a checkbox. It is rather wide because of text in the table header row. How do I center the checkbox (with inline CSS in my HTML? (I know)) I tried <td> &..

15

answers

force client disconnect from server with socket.io and nodejs

Is there any way to disconnect a client with SocketIO, and literally close the connection? So if someone is connected to my server, and I want to close the connection between them and my server, how w..

15

answers

How to round the corners of a button

I have a rectangle image (jpg) and want to use it to fill the background of a button with rounded corner in xcode. I wrote the following: UIButton *button = [[UIButton buttonWithType:UIButtonTypeRou..

21

answers

How to check if IEnumerable is null or empty?

I love string.IsNullOrEmpty method. I'd love to have something that would allow the same functionality for IEnumerable. Is there such? Maybe some collection helper class? The reason I am asking is tha..

5

answers

Populating a ListView using an ArrayList?

My Android app needs to populate the ListView using the data from an ArrayList. I have trouble doing this. Can someone please help me with the code?..

6

answers

Difference between clustered and nonclustered index

I need to add proper index to my tables and need some help. I'm confused and need to clarify a few points: Should I use index for non-int columns? Why/why not I've read a lot about clustered and no..

13

answers

Replace multiple strings at once

Is there an easy equivalent to this in JavaScript? $find = array("<", ">", "\n"); $replace = array("&lt;", "&gt;", "<br/>"); $textarea = str_replace($find, $replace, $textarea); ..

6

answers

Remove ':hover' CSS behavior from element

I have CSS that changes formatting when you hover over an element. _x000D_ _x000D_ .test:hover { border: 1px solid red; }_x000D_ <div class="test">blah</div>_x000D_ _x000D_ _x000D_ In som..

14

answers

Fastest method of screen capturing on Windows

I want to write a screencasting program for the Windows platform, but am unsure of how to capture the screen. The only method I'm aware of is to use GDI, but I'm curious whether there are other ways t..

10

answers

What do &lt; and &gt; stand for?

I know that the entities &lt; and &gt; are used for < and >, but I am curious what these names stand for. Does &lt; stand for something like "Left tag" or is it just a code?..

10

answers

How do I send an HTML email?

I have successfully sent email in my web application using JMS, but the result only displays in plain text. I want the content to be able to display html. How do I do it? Here is roughly what I have: ..

13

answers

What is the best way to extract the first word from a string in Java?

Trying to write a short method so that I can parse a string and extract the first word. I have been looking for the best way to do this. I assume I would use str.split(","), however I would like to g..

8

answers

Function is not defined - uncaught referenceerror

I have this uncaught referenceerror function is not defined error which do not understand. If I have $(document).ready(function(){ function codeAddress() { var address = document.getElementById("..

28

answers

How do I add 1 day to an NSDate?

Basically, as the title says. I'm wondering how I could add 1 day to an NSDate. So if it were: 21st February 2011 It would become: 22nd February 2011 Or if it were: 31st December 2011 It wou..

20

answers

Determine function name from within that function (without using traceback)

In Python, without using the traceback module, is there a way to determine a function's name from within that function? Say I have a module foo with a function bar. When executing foo.bar(), is ther..

14

answers

Editing in the Chrome debugger

How do I "dynamically" edit JavaScript code in the Chrome debugger? It's not for me, so I don't have access to the source file. I want to edit code and see what effects they have on the page, in this ..

5

answers

How to align this span to the right of the div?

I have the following HTML: <div class="title"> <span>Cumulative performance</span> <span>20/02/2011</span> </div> with this CSS: .title { display: b..

10

answers

get UTC timestamp in python with datetime

Is there a way to get the UTC timestamp by specifying the date? What I would expect: datetime(2008, 1, 1, 0, 0, 0, 0) should result in 1199145600 Creating a naive datetime object means that the..

4

answers

HQL "is null" And "!= null" on an Oracle column

Does hibernate convert column != null in HQL to a column is null in SQL?..

5

answers

How to check if a user likes my Facebook Page or URL using Facebook's API

I think I'm going crazy. I can't get it to work. I simply want to check if a user has liked my page with javascript in an iFrame app. FB.api({ method: "pages.isFan", page_id: my_pa..

40

answers

adb server version doesn't match this client

Whenever I try to run adb devices: $ adb devices * daemon not running. starting it now * * daemon started successfully * List of devices attached ..

11

answers

How to create large PDF files (10MB, 50MB, 100MB, 200MB, 500MB, 1GB, etc.) for testing purposes?

I tried this for ((i=1; i<=10; i++)); do convert 100MB.pdf 10MB.pdf 100MB.pdf; done to create 100MB file but very quickly run out of RAM. Any ideas?..

10

answers

Is mongodb running?

I have installed mongodb and the php drivers on my unix server. My question is how can I tell if mongodb is running? Is there a simple command line query to check status? If I start it once from the s..

7

answers

Override and reset CSS style: auto or none don't work

I would like to override following CSS styling defined for all tables: table { font-size: 12px; width: 100%; min-width: 400px; display:inline-table; } I have..

13

answers

How to find a whole word in a String in java

I have a String that I have to parse for different keywords. For example, I have the String: "I will come and meet you at the 123woods" And my keywords are '123woods' 'woods' I should report when..

5

answers

How do you change the character encoding of a postgres database?

I have a database that was set up with the default character set SQL_ASCII. I want to switch it to UNICODE. Is there an easy way to do that?..

5

answers

filtering a list using LINQ

i have a list of project objects: IEnumerable<Project> projects a Project class as a property called Tags. this is a int[] i have a variable called filteredTags which is also a int[]. So..

4

answers

Javascript Regexp dynamic generation from variables?

How to construct two regex patterns into one? For example I have one long pattern and one smaller, I need to put smaller one in front of long one. var pattern1 = ':\(|:=\(|:-\('; var pattern2 = ':\(..

9

answers

Text overwrite in visual studio 2010

Really silly problem here. In Visual Studio 2010, the text cursor has changed from the blinking line, to a blinking grey box around the characters. When I type overwrites the text in front of it. ..

12

answers

How to run a C# application at Windows startup?

I made an application that launches during startup, with the next code below. The process runs on the process manager tool after the restart, but I can't see the application on the screen. When I open..

10

answers

How can I check what version/edition of Visual Studio is installed programmatically?

I could read registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0. However, it doesn't give me any information about the edition of it - Professional/Ultimate or whatever. How can I get ..

4

answers

How can I change the image of an ImageView?

I have just started learning android. And i don't know How can I change the image of an ImageView? ie it has some Image which was set in the layout but i want to change that image through coding how s..

19

answers

"Sources directory is already netbeans project" error when opening a project from existing sources

I've installed NetBeans 6.9.1 and installed few updates for it. Then I've created a new project from existing sources. After a few changes I've closed it. And now I am having an error, when trying to..

2

answers

Jquery split function

I have a ajax function as below <script type="text/javascript"> $(document).ready(function () { var timer, delay =600000; //5 minutes counted in milliseconds. timer = setInterval(function(){ ..

7

answers

Using Alert in Response.Write Function in ASP.NET

I have database code like this try { string strConnectionString = ConfigurationManager.ConnectionStrings["SqlServerCstr"].ConnectionString; SqlConnection myConnection = new SqlConnection(st..