Some Of The Best Answers From Latest Asked Questions

7

answers

How can I remove non-ASCII characters but leave periods and spaces using Python?

I'm working with a .txt file. I want a string of the text from the file with no non-ASCII characters. However, I want to leave spaces and periods. At present, I'm stripping those too. Here's the code:..

13

answers

How to clear the cache in NetBeans

I created a project in NetBeans, and I would like to clear the NetBeans cache. I'm running NetBeans 7.0.1 on a Windows 7 machine. How do I do this?..

8

answers

Map.Entry: How to use it?

I'm working on creating a calculator. I put my buttons in a HashMap collection and when I want to add them to my class, which extends JPanel, I don't know how can I get the buttons from my collection...

5

answers

NameError: name 'reduce' is not defined in Python

I'm using Python 3.2. Tried this: xor = lambda x,y: (x+y)%2 l = reduce(xor, [1,2,3,4]) And got the following error: l = reduce(xor, [1,2,3,4]) NameError: name 'reduce' is not defined Tried print..

3

answers

JOptionPane YES/No Options Confirm Dialog Box Issue

I've created a JOptionPane and it only has two buttons YES_NO_OPTION . After JOptionPane.showConfirmDialog pops out , I want to click YES BUTTON to continue opening the JFileChooser and if I clicked ..

17

answers

How to close TCP and UDP ports via windows command line

Does somebody knows how to close a TCP or UDP socket for a single connection via windows command line? Googling about this, I saw some people asking the same thing. But the answers looked like a manu..

9

answers

Resize command prompt through commands

I want to resize the command prompt window in a batch file, is it possible to set a height and width through something I can just add in the batch file?..

3

answers

Difference between static STATIC_URL and STATIC_ROOT on Django

I am confused by static root and want to clarify things. To serve static files in Django, the following should be in settings.py and urls.py: import os PROJECT_DIR=os.path.dirname(__file__) 1. Abs..

4

answers

using favicon with css

I want to set the favicon for a fairly large number of pages. But, instead of using the HTML <head> tag <link rel="shortcut icon" href="favicon.ico">, I'd like to set it in the CSS file. I..

5

answers

How to add a hook to the application context initialization event?

For a regular Servlet, I guess you could declare a context listener, but for Spring MVC would Spring make this any easier? Furthermore, if I define a context listener and then would need to access th..

9

answers

Writing a dictionary to a csv file with one line for every 'key: value'

I've got a dictionary: mydict = {key1: value_a, key2: value_b, key3: value_c} I want to write the data to a file dict.csv, in this style: key1: value_a key2: value_b key3: value_c I wrote: impo..

2

answers

Adding headers to requests module

Earlier I used httplib module to add a header in the request. Now I am trying the same thing with the requests module. This is the python request module I am using: http://pypi.python.org/pypi/request..

5

answers

Difference between DOM parentNode and parentElement

Can somebody in explain me in as simple as possible terms, what is the difference between classical DOM parentNode and newly introduced in Firefox 9 parentElement..

14

answers

Windows 7 environment variable not working in path

I am trying to set up some path using environment variable. I added an environment variable "MAVEN_HOME" with the value "C:\maven". Then in the path I added "%MAVEN_HOME%\bin;...rest". When I type "ec..

2

answers

CORS - How do 'preflight' an httprequest?

I am trying to make a cross domain HTTP request to WCF service (that I own). I have read several techniques for working with the cross domain scripting limitations. Because my service must accommodate..

10

answers

Hiding a button in Javascript

In my latest program, there is a button that displays some input popup boxes when clicked. After these boxes go away, how do I hide the button?..

2

answers

changing color of h2

How I can change the color of h2 ? I have tried <h2 color="#006699">Process Report</h2> but it's not changed and I am still getting this default black colour Thanks ...

14

answers

Where can I find php.ini?

A few years ago I installed Apache 2.2x and PHP 5.3.1 on a Linux server I maintain. I used .tar.gz's and built them as instructed (instead of rpms and what-have-you). And all was fine. Today I need ..

17

answers

Eclipse projects not showing up after placing project files in workspace/projects

I've searched for 2 days and can't find anything. I find things that are close, but not what I need. I got a new computer recently and copied all of my projects over to my new computer. I opened Ecl..

10

answers

How do I determine the current operating system with Node.js

I'm writing a couple of node shell scripts for use when developing on a platform. We have both Mac and Windows developers. Is there a variable I can check for in Node to run a .sh file in one instance..

9

answers

Embed image in a <button> element

I'm trying to display a png image on a <button> element in HTML. The button is the same size as the image, and the image is shown but for some reason not in the center - so it's impossible to se..

3

answers

htaccess <Directory> deny from all

I've been cleaning up my project lately. I have a main .htaccess in the root directory and 6 others. 5 of them ran Options -Indexes which i didn't see anypoint of allowing any Directory viewing so mov..

6

answers

html cellpadding the left side of a cell

I want to pad my text in a cells on the right side with additional space . I don't use css style sheets . this is my code <table border="1" CELLPADDING="5"> on right size for example I want 1..

12

answers

iOS application: how to clear notifications?

I've an iOS application where some Push Notification are sent to. My problem is, that the messages/notifications stays in the Notification Center in iOS after then are tapped. How can I remove a notif..

15

answers

jQueryUI modal dialog does not show close button (x)

I'm using a jQuery modal dialog in my ASP .NET MVC 3 application. It works fine except for that there is no close button showing in the top right corner. How can I add this? $("#dialog-modal").dialo..

5

answers

Programmatically extract contents of InstallShield setup.exe

I am trying to extract the file-contents of an InstallShield setup.exe-file. (My plan is to use it in a back-office tool, so this must be done programmatically without any user interactions.) Is this..

6

answers

VBA - how to conditionally skip a for loop iteration

I have a for loop over an array. What I want to do is test for a certain condition in the loop and skip to the next iteration if true: For i = LBound(Schedule, 1) To UBound(Schedule, 1) If (Sched..

4

answers

make image( not background img) in div repeat?

I'm trying to repeat-y an image that's in a div and no background image but haven't figured how. Could you please point me to a solution? My code looks like this: <div id="rightflower"> <im..

24

answers

NoClassDefFoundError for code in an Java library on Android

I am experiencing an error quite often among my users. The app crashes during startup. When the MainActivity is supposed to be loaded the VM apparently cannot find the class. I cannot figure out why. ..

8

answers

How to check that Request.QueryString has a specific value or not in ASP.NET?

I have an error.aspx page. If a user comes to that page then it will fetch the error path in page_load() method URL using Request.QueryString["aspxerrorpath"] and it works fine. But if a user direct..

6

answers

datetimepicker is not a function jquery

I working with datetimepicker jquery ui, when code below html , datetimepicker is not displaying and when i inspect with firebug console it displayed an error `` $("#example1").datetimepicker is not ..

11

answers

Formatting numbers (decimal places, thousands separators, etc) with CSS

Is it possible to format numbers with CSS? That is: decimal places, decimal separator, thousands separator, etc...

8

answers

Recursive file search using PowerShell

I am searching for a file in all the folders. Copyforbuild.bat is available in many places, and I would like to search recursively. $File = "V:\Myfolder\**\*.CopyForbuild.bat" How can I do it in P..

11

answers

PHP-FPM doesn't write to error log

I've just installed a nginx+php-fpm server. Everything seems fine except that PHP-FPM never writes error to its log. fpm.conf [default] listen = /var/run/php-fpm/default.sock listen.allowed_clients ..

4

answers

Best dynamic JavaScript/JQuery Grid

I'm working with JavaScript, JQuery and HTML. UI Of my project is completely dynamic. I am looking for a dynamic JavaScript/JQuery Grid which supports following features. Can anybody tell me is there..

4

answers

Which characters are valid/invalid in a JSON key name?

Are there any forbidden characters in key names, for JavaScript objects or JSON strings? Or characters that need to be escaped? To be more specific, I'd like to use "$", "-" and space in key names...

6

answers

send Content-Type: application/json post with node.js

How can we make a HTTP request like this in NodeJS? Example or module appreciated. curl https://www.googleapis.com/urlshortener/v1/url \ -H 'Content-Type: application/json' \ -d '{"longUrl": "htt..

12

answers

Best way to select random rows PostgreSQL

I want a random selection of rows in PostgreSQL, I tried this: select * from table where random() < 0.01; But some other recommend this: select * from table order by random() limit 1000; I ha..

9

answers

Adding options to select with javascript

I want this javascript to create options from 12 to 100 in a select with id="mainSelect", because I do not want to create all of the option tags manually. Can you give me some pointers? Thanks functi..

7

answers

Change the On/Off text of a toggle button Android

I just changed the background of a ToggleButton, and now I'm looking to change the ON/OFF text that comes up with it. What is the easiest way to do this?..

9

answers

Use ffmpeg to add text subtitles

I am trying to add text subtitles to an .mp4 container using ffmpeg: ffmpeg -i input.mp4 -i input.srt -map 0.0 -map 0.1 -map 1.0 output.mp4 When I am trying to run this line, it gives me an error :..

6

answers

Undefined reference to `pow' and `floor'

I'm trying to make a simple fibonacci calculator in C but when compiling gcc tells me that I'm missing the pow and floor functions. What's wrong? Code: #include <stdio.h> #include <math.h&g..

3

answers

How to launch PowerShell (not a script) from the command line

I am new to PowerShell and am struggling with what I assume should be a simple operation—I am trying to launch a PowesShell window from the command line. If I launch a command line instance a..

9

answers

Get Root Directory Path of a PHP project

I have this folder structure in my PHP project. (this is as shown in eclips) -MySystem +Code +Data_Access -Public_HTML +css +js +Templates -resources When I..

27

answers

indexOf method in an object array?

What's the best method to get the index of an array which contains objects? Imagine this scenario: var hello = { hello: 'world', foo: 'bar' }; var qaz = { hello: 'stevie', foo: 'baz'..

4

answers

Python 3 string.join() equivalent?

I've been using string.join() method in python 2 but it seems like it has been removed in python 3. What is the equivalent method in python 3? string.join() method let me combine multiple strings to..

14

answers

How to pause a YouTube player when hiding the iframe?

I have a hidden div containing a YouTube video in an <iframe>. When the user clicks on a link, this div becomes visible, the user should then be able to play the video. When the user closes the..

6

answers

OpenCV C++/Obj-C: Detecting a sheet of paper / Square Detection

I successfully implemented the OpenCV square-detection example in my test application, but now need to filter the output, because it's quite messy - or is my code wrong? I'm interested in the four co..

6

answers

What does the "$" sign mean in jQuery or JavaScript?

Possible Duplicate: What is the meaning of “$” sign in JavaScript Now this must seem to be an easy and stupid question to ask but I must know why we use the dollar ($) symbol in..

11

answers

How to create a TextArea in Android

How do I display a TextArea for my android project? From xml, the only choice is TextField, multi lined. But thats editable. I need a TextArea which is only for displaying messages/text can't be edit/..

7

answers

What is the difference between XAMPP or WAMP Server & IIS?

I want to know what's the main difference between XAMPP or WAMP Server & IIS Server?..

12

answers

JavaScript code to stop form submission

One way to stop form submission is to return false from your JavaScript function. When the submit button is clicked, a validation function is called. I have a case in form validation. If that conditi..

5

answers

How to mount the android img file under linux?

Recently, I'm interest in the android rom, I want to change and rebuild them. So, I did some test on my XOOM, it's very easy to flash something into the machine. I got some ROM from MOTOROLA (http://d..

12

answers

Python: Best way to add to sys.path relative to the current running script

I have a directory full of scripts (let's say project/bin). I also have a library located in project/lib and want the scripts to automatically load it. This is what I normally use at the top of each s..

9

answers

How do I capture the output of a script if it is being ran by the task scheduler?

Using Windows Server 2008, how do I go about capturing the output of a script that is being ran with the windows task scheduler? I'm testing a rather long custom printing batch-script, and for debugg..

3

answers

Programmatically select a row in JTable

When the application is started, none of the rows is selected. But I would like to show that the first row is already selected. How to do this? Do I need to set the color of a row in JTable? Updat..

11

answers

Resolving IP Address from hostname with PowerShell

I am trying to get the ipaddress from a hostname using Powershell, but I really can't figure out how. Any help?..

11

answers

What is the difference between Integer and int in Java?

For example why can you do: int n = 9; But not: Integer n = 9; And you can do: Integer.parseInt("1"); But not: int.parseInt("1"); ..

8

answers

How to check for Is not Null And Is not Empty string in SQL server?

How can we check in a SQL Server WHERE condition whether the column is not null and not the empty string ('')?..

7

answers

How do I use StringUtils in Java?

I'm a beginner in Java. I want to use StringUtils.replace but Eclipse outputs "StringUtils cannot be resolved". I tried import java.lang.*;, but it doesn't work...

2

answers

Need to make a clickable <div> button

Kindly go through this link and notice the solution given by "thepeer": https://stackoverflow.com/a/3494108 I am having trouble understanding his solution. Let me illustrate with the example of a web..

5

answers

How does HTTP file upload work?

When I submit a simple form like this with a file attached: <form enctype="multipart/form-data" action="http://localhost:3000/upload?upload_progress_id=12344" method="POST"> <input type="hid..

30

answers

Downloading an entire S3 bucket?

I noticed that there doesn't seem to be an option to download an entire S3 bucket from the AWS Management Console. Is there an easy way to grab everything in one of my buckets? I was thinking about m..

8

answers

When is "java.io.IOException:Connection reset by peer" thrown?

ERROR GServerHandler - java.io.IOException: Connection reset by peer java.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcher.read0(Native Method) at sun.nio.ch.Sock..

25

answers

Android Facebook style slide

The new Facebook application and its navigation is so cool. I was just trying to see how it can be emulated in my application. Anyone has a clue how it can be achieved? On clicking the the top le..

4

answers

Ruby get object keys as array

I am new to Ruby, if I have an object like this {"apple" => "fruit", "carrot" => "vegetable"} How can I return an array of just the keys? ["apple", "carrot"] ..

5

answers

What do \t and \b do?

I expect this simple line of code printf("foo\b\tbar\n"); to replace "o" with "\t" and to produce the following output fo bar (assuming that tab stop occurs every 8 characters). On the contr..

23

answers

Solution for "Fatal error: Maximum function nesting level of '100' reached, aborting!" in PHP

I have made a function that finds all the URLs within an html file and repeats the same process for each html content linked to the discovered URLs. The function is recursive and can go on endlessly. ..

3

answers

How to get data by SqlDataReader.GetValue by column name

I use SqlDataReader.GetValue method to read values from DB: Log.WriteLine("Value of CompanyName column:" + thisReader.GetValue(1)); As parameter GetValue get index of column. How could I specify C..

4

answers

What is the difference between README and README.md in GitHub projects?

I've noticed some GitHub projects have not only a README file, but also a README.md file. What is the difference between these files? I know README serves also as introductory text in the project rep..

6

answers

What's the best way to identify hidden characters in the result of a query in SQL Server (Query Analyzer)?

When trying to identify erroneous data (often needing manual review and removal), I'd like an easy way of seeing hidden characters, such as TAB, Space, Carriage return and Line feed. Is there a built-..

12

answers

get UTC time in PHP

How can I get UTC/GMT +/- time stamp using PHP's date() function? For example, if I try date("Y-m-d H:i:s", time()); I will get Unix time stamp; but I need to get UTC/GMT time stamp with string GM..

13

answers

Node.js: how to consume SOAP XML web service

I wonder what is the best way to consume SOAP XML web service with node.js Thanks!..

27

answers

How can I get current date in Android?

I wrote the following code Date d = new Date(); CharSequence s = DateFormat.format("MMMM d, yyyy ", d.getTime()); But is asking me parameter, I want current date in string format, like 28-Dec-..

7

answers

Http Get using Android HttpURLConnection

I'm new to Java and Android development and try to create a simple app which should contact a web server and add some data to a database using a http get. When I do the call using the web browser in ..

9

answers

Convert byte to string in Java

I use below code to convert byte to string: System.out.println("string " + Byte.toString((byte)0x63)); Why it print "string 99". How to modify to let it print "string c"?..

17

answers

How to compare two floating point numbers in Bash?

I am trying hard to compare two floating point numbers within a bash script. I have to variables, e.g. let num1=3.17648e-22 let num2=1.5 Now, I just want do a simple comparison of these two numbers: ..

22

answers

Python list of dictionaries search

Assume I have this: [ {"name": "Tom", "age": 10}, {"name": "Mark", "age": 5}, {"name": "Pam", "age": 7} ] and by searching "Pam" as name, I want to retrieve the related dictionary: {name: "Pam", ag..

5

answers

php REQUEST_URI

I have the following php script to read the request in URL : $id = '/' != ($_SERVER['REQUEST_URI']) ? str_replace('/?id=' ,"", $_SERVER['REQUEST_URI']) : 0; It was used when the URL is http://..

6

answers

Check if a specific tab page is selected (active)

I am making an event to check if specific tab page in a tab control is active. The point is, it will trigger an event if that tab page in a tab control is the currently selected tab. Any code that wi..

12

answers

Stop fixed position at footer

I'm looking for a solution to the popular issue of stopping a fixed object at the footer of the page. I basically have a fixed "share" box in the bottom left corner of the screen and I don't want it ..

11

answers

Using port number in Windows host file

After installing TeamViewer, I have changed the wampserver port to 8080, so the address is http://localhost:8080. For the host file located at C:\WINDOWS\system32\drivers\etc\, I have also made the c..

6

answers

How can I disable notices and warnings in PHP within the .htaccess file?

I just want to only turn on PHP errors and disable all notices and warnings in PHP files...

10

answers

How to convert hex strings to byte values in Java

I have a String array. I want to convert it to byte array. I use the Java program. For example: String str[] = {"aa", "55"}; convert to: byte new[] = {(byte)0xaa, (byte)0x55}; What can I do?..

8

answers

How to get setuptools and easy_install?

I downloaded the ez_setup code from here: http://peak.telecommunity.com/dist/ez_setup.py and ran it, but i don't think setuptools was properly installed. When i try to open an egg using easy_install i..

3

answers

How to copy selected files from Android with adb pull

I'm attempting to use the adb pull command to copy only certain files (jpg) to my macbook. I tried "adb pull sdcard/mydir/*.jpg" but it apparently doesn't interpret wildcards. How can I get only the j..

8

answers

Switch to another branch without changing the workspace files

I cloned a git repository from GitHub, made some changes and some commits; I made quite a lot and all are quite dirty, so they're not suitable for a pull request. Now I created the branch cleanchanges..

32

answers

How to convert URL parameters to a JavaScript object?

I have a string like this: abc=foo&def=%5Basf%5D&xyz=5 How can I convert it into a JavaScript object like this? { abc: 'foo', def: '[asf]', xyz: 5 } ..

5

answers

How can I get a list of repositories 'apt-get' is checking?

I want a list of repositories in sources.list, plus those in sources.list.d/. Can I get this list in a form suitable for setting up another host so it watches the same repositories? Additionally, how ..

6

answers

Get href attribute on jQuery

I have some table rows <tr class="b_row"> <td> <div class="cpt"> <h2> <a href="/ref/ref/1.html">example</a> <..

5

answers

Get content of a DIV using JavaScript

I have two DIV's called DIV1 and DIV2 and DIV1 consists of dynamic content and DIV2 is empty. I need content of DIV1 to be displayed in DIV2. How can I do it. I coded in below manner which is not wor..

11

answers

How to list files in an android directory?

Here's my code so far: String path = Environment.getExternalStorageDirectory().toString()+"/Pictures"; AssetManager mgr = getAssets(); try { String list[] = mgr.list(pa..

12

answers

How can I see the size of a GitHub repository before cloning it?

Is there a way to see how big a Git repository is on GitHub before you decide to clone it? This seems like a really obvious/basic statistic, but I can't find how to see it on GitHub at all...

4

answers

There can be only one auto column

How do I correct the error from MySQL 'you can only have one auto increment column'. CREATE TABLE book ( id INT AUTO_INCREMENT NOT NULL, accepted_terms BIT(1) NOT NULL, accepted_privacy BIT(..

4

answers

sql query with multiple where statements

I am having a rather, for me, complicated mysql query on which I am totally stuck and cannot find any answer for online. Here's my query: SELECT items.* FROM items INNER JOIN items_meta_data WHERE (..

18

answers

Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)

I have a java project that runs on a webserver. I always hit this exception. I read some documentation and found that pessimistic locking (or optimistic, but I read that pessimistic is better) is the ..

14

answers

Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'?

When I run: C:\Users\ashahria\Downloads>java -jar schemaSpy_5.0.0.jar I get the error below. What is wrong? How can I fix it? Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\Curre..

15

answers

How to highlight text using javascript

Can someone help me with a javascript function that can highlight text on a web page. And the requirement is to - highlight only once, not like highlight all occurrences of the text as we do in case o..

2

answers

Pass parameter to EventHandler

I have the following EventHandler to which I added a parameter MusicNote music: public void PlayMusicEvent(object sender, EventArgs e,MusicNote music) { music.player.Stop(); System.Timers.Tim..

4

answers

How to fix div on scroll

If you scroll down the page in the following URL, the 'share' div will lock onto the browser: http://knowyourmeme.com/memes/pizza-is-a-vegetable I'm assuming they are applying a position: fixed; att..