Some Of The Best Answers From Latest Asked Questions

3

answers

How do I convert an ANSI encoded file to UTF-8 with Notepad++?

I have a website, and I can send my Turkish characters with jQuery in Firefox, but Internet Explorer doesn't send my Turkish characters. I looked at my source file in notepad, and this file's code pag..

2

answers

return results from a function (javascript, nodejs)

Could anyone help me with this code? I need to return a value form a routeToRoom function: var sys = require('sys'); function routeToRoom(userId, passw) { var roomId = 0; var nStore = requir..

7

answers

Capturing window.onbeforeunload

I have a form where the input fields are saved onChange. In Firefox (5) this works even when the window is closed, but for Chrome and IE it doesn't and I need to be sure that I'm saving this data even..

14

answers

Exit while loop by user hitting ENTER key

I am a python newbie and have been asked to carry out some exercises using while and for loops. I have been asked to make a program loop until exit is requested by the user hitting <Return> only..

14

answers

CodeIgniter: Unable to connect to your database server using the provided settings Error Message

I have been using CI just fine using the MySQL driver. I want to use the MySQL driver instead, but as soon as I change it (just add the ā€˜iā€™ at the end of MySQL, and added the port number) I get th..

12

answers

How to get everything after last slash in a URL?

How can I extract whatever follows the last slash in a URL in Python? For example, these URLs should return the following: URL: http://www.test.com/TEST1 returns: TEST1 URL: http://www.test.com/page..

3

answers

Spring: How to inject a value to static field?

With this class @Component public class Sample { @Value("${my.name}") public static String name; } If I try Sample.name, it is always 'null'. So I tried this. public class Sample { ..

3

answers

Change the icon of the exe file generated from Visual Studio 2010

I am currently creating an application in Visual Studio 2010. After building the project to generate the output of my application, I find that the .exe is built with the default icon. Is there any w..

5

answers

Switch case on type c#

Possible Duplicate: C# - Is there a better alternative than this to 'switch on type'? Hello suppose i get a big if/else on class type. it's there a way to do it with a switch case ?..

4

answers

How to check how many letters are in a string in java?

How do you check how many letters are in a Java string? How do you check what letter is in a certain position in the string (i.e, the second letter of the string)?..

5

answers

Mysql select distinct

I am trying to select of the duplicate rows in mysql table it's working fine for me but the problem is that it is not letting me select all the fields in that query , just letting me select the field ..

7

answers

HTML entity for the middle dot

I'm looking for the html code for the dot. Not the dot that's at the end of sentences but the dot that's used to separate items horizontally. Item 1 . Item 2 . Item 3 The traditional dot is centere..

16

answers

How to install MySQLi on MacOS

I cannot find instructions about installing MySQLi on a Mac. Just to be clear, MySQL is up to date and I am running PHP 5. How do I install it? Where do I even get it from? Thanks for your help. I'll ..

6

answers

Reading a binary input stream into a single byte array in Java

The documentation says that one should not use available() method to determine the size of an InputStream. How can I read the whole content of an InputStream into a byte array? InputStream in; //assu..

1

answers

What ports need to be open for TortoiseSVN to authenticate (clear text) and commit?

What ports need to be open for TortoiseSVN to authenticate (basic) in order to commit? I know it is not a good thing, but I believe username and password are in the clear right now. Let me describe a..

8

answers

Meaning of $? (dollar question mark) in shell scripts

What does echo $? mean in shell programming?..

13

answers

How can I tell where mongoDB is storing data? (its not in the default /data/db!)

My host came with a mongodb instance and there is no /db directory so now I am wondering what I can do to find out where the data is actually being stored...

3

answers

Get the Year/Month/Day from a datetime in php?

I used date('w', timestamp) and date('w', timestamp) to know the day, date('n', timestamp) for months, etc. Now I'm using datetime and I'd like to know what are the equivalent functions to get a day,..

4

answers

How to parse a JSON string to an array using Jackson

I have a String with the following value: [ { "key1": "value11", "key2": "value12" }, { "key1": "value21", "key2": "value22" } ] And the following class: public class SomeC..

9

answers

How to add values in a variable in Unix shell scripting?

I have two variables called count1 and count7 count7=0 count7=$(($count7 + $count1)) This shows an error "expression is not complete; more token required". How should I add the two variables?..

9

answers

how to evenly distribute elements in a div next to each other?

This is meant for a menu. For example I have a div element with 3 spans in it, all of which have some margin, max-width and float (left or right). It is positioned starting from the left side and goes..

6

answers

How do I import from Excel to a DataSet using Microsoft.Office.Interop.Excel?

What I want to do I'm trying to use the Microsoft.Office.Interop.Excel namespace to open an Excel file (XSL or CSV, but sadly not XSLX) and import it into a DataSet. I don't have control over the work..

28

answers

How do I update a GitHub forked repository?

I recently forked a project and applied several fixes. I then created a pull request which was then accepted. A few days later another change was made by another contributor. So my fork doesn't conta..

9

answers

Download file from web in Python 3

I am creating a program that will download a .jar (java) file from a web server, by reading the URL that is specified in the .jad file of the same game/application. I'm using Python 3.2.1 I've manage..

4

answers

Asserting successive calls to a mock method

Mock has a helpful assert_called_with() method. However, as far as I understand this only checks the last call to a method. If I have code that calls the mocked method 3 times successively, each time ..

19

answers

For..In loops in JavaScript - key value pairs

I was wondering if there's a way to do something like a PHP foreach loop in JavaScript. The functionality I'm looking for is something like this PHP Snippet: foreach($data as $key => $value) { } ..

10

answers

Can you control how an SVG's stroke-width is drawn?

Currently building a browser-based SVG application. Within this app, various shapes can be styled and positioned by the user, including rectangles. When I apply a stroke-width to an SVG rect element ..

8

answers

Can I set an opacity only to the background image of a div?

Let's say I have <div class="myDiv">Hi there</div> I want to put a background-image and give it an opacity of 0.5 ā€“ but I want that the text I have written will have full opacity (1)...

9

answers

How to convert current date to epoch timestamp?

How to convert current date to epoch timestamp ? Format current date: 29.08.2011 11:05:02 ..

20

answers

Multiple contexts with the same path error running web service in Eclipse using Tomcat

This is the error that I got when I created my first Axis2 web service using Eclipse. After I wrote the class, I created the web service with Apache Axis2. When I click the start server button in ecli..

8

answers

How do I commit only some files?

I have two projects. One is the "official" project and the second is a light modification (some files added). I created new branch and I put new files to them. But in during development some files com..

9

answers

How to find numbers from a string?

I need to find numbers from a string. How does one find numbers from a string in VBA Excel?..

1

answers

Set EditText cursor color

I am having this issue where I am using the Android's Holo theme on a tablet project. However, I have a fragment on screen which has a white background. I am adding an EditText component on this fragm..

5

answers

How to list all properties of a PowerShell object

When I look at the Win32_ComputerSystem class, it shows loads of properties like Status, PowerManagementCapabilities, etc. However, when in PowerShell I do the below I only get back a couple: PS C:\W..

6

answers

Javascript Append Child AFTER Element

I would like to append an li element after another li inside a ul element using javascript, This is the code I have so far.. var parentGuest = document.getElementById("one"); var childGuest = documen..

11

answers

Why can't I use a list as a dict key in python?

I'm a bit confused about what can/can't be used as a key for a python dict. dicked = {} dicked[None] = 'foo' # None ok dicked[(1,3)] = 'baz' # tuple ok import sys dicked[sys] = 'bar' # ..

8

answers

Java SSLException: hostname in certificate didn't match

I have been using the following code to connect to one of google's service. This code worked fine on my local machine : HttpClient client=new DefaultHttpClient(); HttpPost post = new HttpPost("https:..

4

answers

Min/Max-value validators in asp.net mvc

Validation using attributes in asp.net mvc is really nice. I have been using the [Range(min, max)] validator this far for checking values, like e.g.: [Range(1, 10)] public int SomeNumber { get; set;..

4

answers

Specifying Style and Weight for Google Fonts

I am using Google fonts in a few of my pages and hit a wall when trying to use variations of a font. Example: http://www.google.com/webfonts#QuickUsePlace:quickUse/Family:Open+Sans I am importing thr..

14

answers

How to load external webpage in WebView

My problem is that the webpage is not loaded inside the WebView. mWebview.loadUrl("http://www.google.com"); launches the web browser... This is the code of my activity: import android.app.Ac..

3

answers

How do I set up the database.yml file in Rails?

I'm doing this tutorial (http://dmix.ca/2008/09/how-to-scrape-websites-in-ruby-on-rails-using-scrubyt/) and step 4 before I begin is to set up the database.yml file. Not sure what that means. Could so..

2

answers

How to auto-scroll to end of div when data is added?

I have a table inside of a div with the following style: #data { overflow-x:hidden; overflow-y:visible; height:500px; } This displays a vertical scroll bar once enough data is added to ..

7

answers

Apply function to each column in a data frame observing each columns existing data type

I'm trying to get the min/max for each column in a large data frame, as part of getting to know my data. My first try was: apply(t,2,max,na.rm=1) It treats everything as a character vector, because..

4

answers

Horizontal line using HTML/CSS

I am trying to get a horizontal line to work in my blog site, but I am having trouble in displaying the line in google chrome (IE and Firefox display it perfectly). Basically, in my CSS, I have the f..

6

answers

animating addClass/removeClass with jQuery

I am using jQuery and jQuery-ui and want to animate various attributes on various objects. For the sake of explaining the issue here I've simplified it to one div that changes from blue to red when ..

41

answers

Eclipse error: 'Failed to create the Java Virtual Machine'

I am getting this error message when I start Eclipse Helios on Windows 7: Failed to create the Java Virtual Machine My eclipse.ini looks as follows: -startup plugins/org.eclipse.equinox.launc..

7

answers

Need to remove href values when printing in Chrome

I'm attempting to customize the print CSS, and finding that it prints links out with the href value as well as the link. This is in Chrome. For this HTML: <a href="http://www.google.com">Goog..

5

answers

How to hide only the Close (x) button?

I have a modal dialog, and need to hide the Close (X) button, but I cannot use ControlBox = false, because I need to keep the Minimize and Maximize buttons. I need to hide just Close button, is ther..

5

answers

Align Div at bottom on main Div

I have two divs, one inside the other and I would like the small div to be aligned at the buttom of the main div. Here's my code so far. Currently, the button is at the top of main div, instead I wan..

7

answers

Why does "return list.sort()" return None, not the list?

I've been able to verify that the findUniqueWords does result in a sorted list. However, it does not return the list. Why? def findUniqueWords(theList): newList = [] words = [] # Read a ..

12

answers

Programmatically change UITextField Keyboard type

Is it possible to programmatically change the keyboard type of a uitextfield so that something like this would be possible: if(user is prompted for numeric input only) [textField setKeyboardType:..

4

answers

Prevent line-break of span element

I have a <span> element which I want to display without any line break. How can I do that?..

8

answers

How to use Python's pip to download and keep the zipped files for a package?

If I want to use the pip command to download a package (and its dependencies), but keep all of the zipped files that get downloaded (say, django-socialregistration.tar.gz) - is there a way to do that?..

10

answers

How to use npm with node.exe?

I have downloaded Windows Binary (.exe) of nodejs from the main page. How can I install and use npm (Node package manager)?..

5

answers

What is the difference between git clone and checkout?

What is the difference between git clone and git checkout?..

12

answers

How to allow users to check for the latest app version from inside the app?

I want to add a "Check for update" button in apps so that when someone clicks it, it will display a toast message / progress dialog for checking the app's version. If new version is found the apps w..

6

answers

CSS last-child selector: select last-element of specific class, not last child inside of parent?

<div class="commentList"> <article class="comment " id="com21"></article> <article class="comment " id="com20"></article> <article class="comment " id="com19"..

2

answers

How do you rebase the current branch's changes on top of changes being merged in?

Okay. If I'm on a branch (say working), and I want to merge in the changes from another branch (say master), then I run the command git-merge master while on the working branch, and the changes get me..

6

answers

how to list all sub directories in a directory

I'm working on a project and I need to list all sub directories in a directory for example how could I list all the sub directories in c:\..

4

answers

How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?

Can anyone explain how to implement one-to-one, one-to-many and many-to-many relationships while designing tables with some examples?..

3

answers

Allow only numbers to be typed in a textbox

How to allow only numbers to be written in this textbox ? <input type="text" class="textfield" value="" id="extra7" name="extra7"> ..

7

answers

How can I load Partial view inside the view?

I am very confuse with this partial view. I want to load a partial view inside my main view. Here is the simple example. I am loading Index.cshtml of the Homecontroller Index action as a main page. In..

7

answers

JavaScript Nested function

I got a piece of code for javascript which I just do not understand: function dmy(d) { function pad2(n) { return (n < 10) ? '0' + n : n; } return pad2(d.getUTCDate()) + '/' + ..

1

answers

What are the time complexities of various data structures?

I am trying to list time complexities of operations of common data structures like Arrays, Binary Search Tree, Heap, Linked List, etc. and especially I am referring to Java. They are very common, but ..

11

answers

Display last git commit comment

Often during a commit ($ git -commit -m ""), I wish to read my last comment to remember what progress I have made. Is there an easy way to directly access the last commit message through command-line?..

10

answers

Disable color change of anchor tag when visited

I have to disable the color change of an anchor tag when visited. I did this: a:visited{ color: gray } (The link is gray in color before visited.) But this is a way where I explicitly state the col..

8

answers

jQuery select option elements by value

I have a select element wrapped by a span element. I am not allowed to use the select id but I am allowed to use the span id. I am trying to write a javascript/jquery function in which the input is a ..

3

answers

bash script read all the files in directory

How do I loop through a directory? I know there is for f in /var/files;do echo $f;done; The problem with that is it will spit out all the files inside the directory all at once. I want to go one by on..

9

answers

Ellipsis for overflow text in dropdown boxes

I'm fixing the width of one of my dropdown boxes (yes I know there are cross-browser issues with doing this). Is there a non-js way to cut off overflowing text and append ellipses? text-overflow:elli..

5

answers

Why are iframes considered dangerous and a security risk?

Why are iframes considered dangerous and a security risk? Can someone describe an example of a case where it can be used maliciously?..

7

answers

Download a file from NodeJS Server using Express

How can I download a file that is in my server to my machine accessing a page in a nodeJS server? I'm using the ExpressJS and I've been trying this: app.get('/download', function(req, res){ var f..

3

answers

How do I fix 'Invalid character value for cast specification' on a date column in flat file?

I have a CSV file with a {LF} delimiting each row and a date column with the date format as "12/20/2010" (including quotation marks) My destination column is a SQL Server 2008 database table of type ..

6

answers

Python: Get relative path from comparing two absolute paths

Say, I have two absolute paths. I need to check if the location referring to by one of the paths is a descendant of the other. If true, I need to find out the relative path of the descendant from the ..

3

answers

Displaying a Table in Django from Database

How do you display the information from a database table in a table format on a webpage? Is there a simple way to do this in django or does it require a more complicated approach. More specifically, h..

6

answers

Jquery mouseenter() vs mouseover()

So after reading a recently answered question i am unclear if i really understand the difference between the mouseenter() and mouseover(). The post states MouseOver(): Will fire upon entering an elem..

19

answers

Print a list in reverse order with range()?

How can you produce the following list with range() in Python? [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] ..

7

answers

Oracle PL/SQL string compare issue

I have the following Oracle PL/SQL codes that may be rusty from you guys perspective: DECLARE str1 varchar2(4000); str2 varchar2(4000); BEGIN str1:=''; str2:='sdd'; IF(str1<>str..

3

answers

LINQ with groupby and count

This is pretty simple but I'm at a loss: Given this type of data set: UserInfo(name, metric, day, other_metric) and this sample data set: joe 1 01/01/2011 5 jane 0 01/02/2011 9 john 2 01/03/2011 0 j..

24

answers

Getting an element from a Set

Why doesn't Set provide an operation to get an element that equals another element? Set<Foo> set = ...; ... Foo foo = new Foo(1, 2, 3); Foo bar = set.get(foo); // get the Foo element from the..

3

answers

Check whether a string contains a substring

How can I check whether a given string contains a certain substring, using Perl? More specifically, I want to see whether s1.domain.com is present in the given string variable...

10

answers

How to remove backslash on json_encode() function?

How to remove the (\)backslash on a string? when using echo json_encode() ? For example: <?php $str = "$(\"#output\").append(\"<p>This is a test!</p>\")"; echo json_encode($str); ?&g..

3

answers

Placing an image to the top right corner - CSS

I need to display an image on the top-right corner of a div (the image is a "diagonal" ribbon) but keeping the current text contained in an internal div, like stuck to the top of it. I tried differen..

14

answers

How to embed an autoplaying YouTube video in an iframe?

I am trying to embed the new iframe version of a YouTube video and get it to auto play. As far as I can tell, there is no way of doing this by amending flags to the URL. Is there a way to do it by u..

9

answers

How can I read user input from the console?

I want to get a number from the user, and then multiply that number with Pi. my attempt at this is below. But a contains gibberish. For example, if I insert 22, then a contains 50. What am I doing wro..

4

answers

Using pointer to char array, values in that array can be accessed?

I created ptr as pointer to an array of 5 chars. char (*ptr)[5]; assigned it the address of a char array. char arr[5] = {'a','b','c','d','e'}; ptr = &arr; using pointer ptr can I access the ..

19

answers

What is the use of a private static variable in Java?

If a variable is declared as public static varName;, then I can access it from anywhere as ClassName.varName. I am also aware that static members are shared by all instances of a class and are not rea..

3

answers

How to increase the timeout period of web service in asp.net?

I've created one web service which is of asmx type. And I'm using my web service in the .net windows application. Web method from the web service receives byte array conversion of the object & ..

10

answers

iOS (iPhone, iPad, iPodTouch) view real-time console log terminal

Is there a way to view the real-time console log to view NSLog and other debug messages in a real-time manner, such as adb logcat?..

13

answers

How to set the context path of a web application in Tomcat 7.0

I know that I can rename my webapp (or it's WAR file) to ROOT but this is a terrible way to do it, IMHO. Now I checked out the tomcat doc & it says It is NOT recommended to place elements di..

9

answers

JQuery Redirect to URL after specified time

Is there a way to use JQuery to redirect to a specific URL after a give time period?..

14

answers

rails 3.1.0 ActionView::Template::Error (application.css isn't precompiled)

I made a basic rails app with a simple pages controller with an index function and when I load the page I get: ActionView::Template::Error (application.css isn't precompiled): 2: <html> ..

5

answers

Calling Scalar-valued Functions in SQL

I have migrated a database from oracle, and now have a few Scalar-valued Functions. However, when I call them, I get an error saying: Cannot find either column "dbo" or the user-defined function ..

5

answers

Print all day-dates between two dates

For example: from datetime import date d1 = date(2008,8,15) d2 = date(2008,9,15) I'm looking for simple code to print all dates in-between: 2008,8,15 2008,8,16 2008,8,17 ... 2008,9,14 2..

7

answers

Writing a large resultset to an Excel file using POI

This is sort of inline w/ Writing a large ResultSet to a File but the file in question is an Excel file. I'm using the Apache POI library to write an Excel file with a large data set retrieved from a..

5

answers

Image Greyscale with CSS & re-color on mouse-over?

I am looking to take an icon that is colored (and will be a link) and turn it greyscale until the user places their mouse over the icon (where it would then color the image). Is this possible to do, ..

21

answers

How to split a long array into smaller arrays, with JavaScript

I have an array of e-mails (it can be just 1 email, or 100 emails), and I need to send the array with an ajax request (that I know how to do), but I can only send an array that has 10 or less e-mails ..

36

answers

How to vertically align an image inside a div

How can you align an image inside of a containing div? Example In my example, I need to vertically center the <img> in the <div> with class ="frame": <div class="frame&qu..

5

answers

What is the javascript filename naming convention?

Should files be named something-with-hyphens.js, camelCased.js, or something else? I didn't find the answer to this question here...

5

answers

Adobe Acrobat Pro make all pages the same dimension

Does anyone know how to change the dimensions of each page on an Acrobat document. Also how can I see the dimensions of each page seperately?? For example I have a 3 pages document. The first 2 pages..

12

answers

How to identify all stored procedures referring a particular table

I created a table on development environment for testing purpose and there are few sp's which are refreing this table. Now I have have to drop this table as well as identify all sp's which are referri..