Some Of The Best Answers From Latest Asked Questions

26

answers

Count specific character occurrences in a string

What is the simplest way to count the number of occurrences of a specific character in a string? That is, I need to write a function, countTheCharacters(), so that str = "the little red hen" count =..

4

answers

Crystal Reports 13 And Asp.Net 3.5

I'm developing a website using Asp.Net 3.5 in Visual Studio 2008 and we use Crystal Reports 10 (that's come together vs2008). Last Year, We migrate it to Visual Studio 2010 but we still use .Net 3.5..

6

answers

How do you specify a byte literal in Java?

If I have a method void f(byte b); how can I call it with a numeric argument without casting? f(0); gives an error...

21

answers

File Upload ASP.NET MVC 3.0

(Preface: this question is about ASP.NET MVC 3.0 which was released in 2011, it is not about ASP.NET Core 3.0 which was released in 2019) I want to upload file in asp.net mvc. How can I upload the fi..

5

answers

How to use ClassLoader.getResources() correctly?

How can I use ClassLoader.getResources() to find recursivly resources from my classpath? E.g. finding all resources in the META-INF "directory": Imagine something like getClass().getClassLoader(..

11

answers

/bin/sh: pushd: not found

I am doing the following inside a make file pushd %dir_name% and i get the following error /bin/sh : pushd : not found Can someone please tell me why this error is showing up ? I checked my $PA..

7

answers

How to ignore HTML element from tabindex?

Is there any way in HTML to tell the browser not to allow tab indexing on particular elements? On my page though there is a sideshow which is rendered with jQuery, when you tab through that, you get ..

9

answers

How can I clear or empty a StringBuilder?

I'm using a StringBuilder in a loop and every x iterations I want to empty it and start with an empty StringBuilder, but I can't see any method similar to the .NET StringBuilder.Clear in the documenta..

13

answers

How do I log a Python error with debug information?

I am printing Python exception messages to a log file with logging.error: import logging try: 1/0 except ZeroDivisionError as e: logging.error(e) # ERROR:root:division by zero Is it possib..

16

answers

How to select the last record of a table in SQL?

This is a sample code to select all records from a table. Can someone show me how to select the last record of that table? select * from table When I use: SELECT * FROM TABLE ORDER BY ID DESC LIMIT..

11

answers

Changing element style attribute dynamically using JavaScript

I hav a certain style sheet for a div. Now i want to modify one attribute of div dynamically using js. How can i do it? document.getElementById("xyz").style.padding-top = "10px"; Is this correct?..

5

answers

Change a column type from Date to DateTime during ROR migration

I need to change my column type from date to datetime for an app I am making. I don't care about the data as its still being developed. How can I do this? ..

5

answers

How to set RelativeLayout layout params in code not in xml?

For example I want to add 3 buttons on screen: one align left, one align center, last one align right. How can I set their layout in code, not in xml?..

9

answers

How to round up a number in Javascript?

I want to use Javascript to round up a number. Since the number is currency, I want it to round up like in these examples (2 decimal points): 192.168 => 192.20 192.11 => 192.20 192.21 => 192.30 19..

15

answers

Equivalent to 'app.config' for a library (DLL)

Is there an equivalent to app.config for libraries (DLLs)? If not, what is the easiest way to store configuration settings that are specific to a library? Please consider that the library might be use..

5

answers

How to set True as default value for BooleanField on Django?

I am using BooleanField in Django. By default, the checkbox generated by it is unchecked state. I want the state to be checked by default. How do I do that?..

3

answers

How to pass credentials to httpwebrequest for accessing SharePoint Library

I'm trying to read files from a SharePoint document library using HttpWebRequest. In order to do that I have to pass some credentials. I'm using the below request: HttpWebRequest request = (HttpWeb..

5

answers

setting system property

I am trying to follow this instruction for running gate embedded It says: "System property gate.home should be set to the gate installation directory." (http://gate.ac.uk/wiki/code-repository/) How ..

9

answers

How to make a class property?

In python I can add a method to a class with the @classmethod decorator. Is there a similar decorator to add a property to a class? I can better show what I'm talking about. class Example(object): ..

2

answers

How to represent e^(-t^2) in MATLAB?

I am a beginner in MATLAB, and I need to represent e(-t2). I know that, for example, to represent ex I use exp(x), and I have tried the following 1) tp=t^2; / tp=t*t; x=exp(-tp); 2) x=exp(-t^2);..

22

answers

How to get first and last day of the current week in JavaScript

I have today = new Date(); object. I need to get first and last day of the current week. I need both variants for Sunday and Monday as a start and end day of the week. I am little bit confuse now with..

13

answers

Using only CSS, show div on hover over <a>

I would like to show a div when someone hovers over an <a> element, but I would like to do this in CSS and not JavaScript. Do you know how this can be achieved?..

10

answers

Can I position an element fixed relative to parent?

I find that when I position an element fixed, it doesn't matter if the parent is positioned relative or not, it will position fixed, relative to the window? CSS #wrapper { width: 300px; background: ..

14

answers

Order Bars in ggplot2 bar graph

I am trying to make a bar graph where the largest bar would be nearest to the y axis and the shortest bar would be furthest. So this is kind of like the Table I have Name Position 1 James Go..

13

answers

Define a fixed-size list in Java

Is it possible to define a list with a fixed size that's 100? If not why isn't this available in Java?..

5

answers

What is a CSRF token? What is its importance and how does it work?

I am writing an application (Django, it so happens) and I just want an idea of what actually a "CSRF token" is and how it protects the data. Is the post data not safe if you do not use CSRF ..

6

answers

How to sort a List of objects by their date (java collections, List<Object>)

private List<Movie> movieItems = null; public List<Movie> getMovieItems() { final int first = 0; if (movieItems == null) { getPagingInfo(); movieItems = jpaControll..

3

answers

PHP, How to get current date in certain format

2011-03-04 21:00:40 I want to get current date and time in the above format. How do I do this in PHP?..

4

answers

Using Apache httpclient for https

I have enabled https in tomcat and have a self-signed certificate for server auth. I have created an http client using Apache httpClient. I have set a trust manager loading the server certificate. The..

8

answers

How do I get an empty array of any size in python?

I basically want a python equivalent of this in C: int a[x]; but in python I declare an array like: a = [] and the problem is I want to assign random slots with values like: a[4] = 1 but I ca..

15

answers

jQuery "blinking highlight" effect on div?

I'm looking for a way to do the following. I add a <div> to a page, and an ajax callback returns some value. The <div> is filled with values from the ajax call, and the <div> is the..

6

answers

CodeIgniter - Correct way to link to another page in a view

I was wondering if someone could tell me the correct way to link to another page from within a view. Is there a function for this or is it just the usual about Cheers,..

4

answers

How can I change the class of an element with jQuery>

I have a JavaScript function that looks like this: function UpdateFilterView() { if (_extraFilterExists) { if ($('#F_ShowF').val() == 1) { $('#extraFilterDropDownButton').attr('class', &qu..

3

answers

R: Select values from data table in range

I have a data table in R: name date ---- ---- John 1156649280 Adam 1255701960 ...etc... I want to get all of the rows that have a date within a range. In SQL, I might say SELECT * FROM ..

4

answers

Redirecting a request using servlets and the "setHeader" method not working

I am new to servlet development, and I was reading an ebook, and found that I can redirect to a different web page using setHeader("Location", "http://www.google.com") But this is not working, as ..

6

answers

How to calculate the running time of my program?

I wrote a program and now I want to calculate the total running time of my program from start to end. How can I do this?..

11

answers

how to convert a string to an array in php

how to convert a string in array in php i.e $str="this is string"; should be like this arr[0]=this arr[1]=is arr[2]=string The str_split($str, 3); split the string in 3 character wo..

7

answers

Cut off text in string after/before separator in powershell

Ok so here is what I'm trying to do: I want to make a little powershell script that takes each file of my music library and then does a hash sum of it and writes that into a file like so: test.txt ; ..

14

answers

Cannot create PoolableConnectionFactory

What is the problem? Can't connect to database? org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory ( Communications link failure The last pack..

11

answers

Practical uses of git reset --soft?

I have been working with git for just over a month. Indeed I have used reset for the first time only yesterday, but the soft reset still doesn't make much sense to me. I understand I can use the soft..

14

answers

How to detect if multiple keys are pressed at once using JavaScript?

I'm trying to develop a JavaScript game engine and I've came across this problem: When I press SPACE the character jumps. When I press → the character moves right. The problem is that w..

14

answers

javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Group")

unexpected element (uri:"", local:"Group"). Expected elements are <{}group> Meet an exception when unmarshalling from xml JAXBContext jc = JAXBContext.newInstance(Group.class); Unmarshaller ..

7

answers

How to get substring from string in c#?

I have a large string and its stored in a string variable str. And i want to get a substring from that in c#? Suppose the string is : " Retrieves a substring from this instance. The substring starts a..

10

answers

SQLite Query in Android to count rows

I'm trying to create a simple Login form, where I compare the login id and password entered at the login screen with that stored in the database. I'm using the following query: final String DATABASE..

11

answers

What is a "thread" (really)?

I have been trying to find a good definition, and get an understanding, of what a thread really is. It seems that I must be missing something obvious, but every time I read about what a thread is, it..

25

answers

rmagick gem install "Can't find Magick-config"

I get the error shown below when attempting to install the rmagick gem. I am on Snowleopard 10.6 using RVM, Ruby 1.9.2-head and Rails 3.05. Responses to similar questions recommended installing ImageM..

5

answers

WordPress path url in js script file

I added custom script: wp_enqueue_script('functions', get_bloginfo('template_url') . '/js/functions.js', 'search', null, false); It works great, except in the functions.js I have: Reset.style.bac..

4

answers

Fast and simple String encrypt/decrypt in JAVA

I need fast and simple way to encrypt/decrypt a "lot" of String data. I tried jasypt but it crashes on my Android phone. I have about 2000 records (strings). BasicTextEncryptor textEncryptor = new Ba..

14

answers

How to make an element width: 100% minus padding?

I have an html input. The input has padding: 5px 10px; I want it to be 100% of the parent div's width(which is fluid). However using width: 100%; causes the input to be 100% + 20px how can I get aro..

14

answers

JavaScript: Parsing a string Boolean value?

JavaScript has parseInt() and parseFloat(), but there's no parseBool or parseBoolean method in the global scope, as far as I'm aware. I need a method that takes strings with values like "true" or "fa..

8

answers

z-index not working with fixed positioning

I have a div with default positioning (i.e. position:static) and a div with a fixed position. If I set the z-indexes of the elements, it seems impossible to make the fixed element go behind the static..

5

answers

Getting a HeadlessException: No X11 DISPLAY variable was set

Exception in thread "main" java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it. at java.awt.GraphicsEnvironment.checkHead..

8

answers

How do I get the currently-logged username from a Windows service in .NET?

I have a Windows service which need the currently logged username. I tried System.Environment.UserName, Windows identity and Windows form authentication, but all are returning "System" as the user as ..

7

answers

How can I nullify css property?

Basically I have two external css in my page. The first Main.css contains all style rules but I don't have access to it, and hence I cannot modify it. I have access to a second file Template.css , so..

12

answers

back button callback in navigationController in iOS

I have pushed a view onto the navigation controller and when I press the back button it goes to the previous view automatically. I want to do a few things when back button is pressed before popping th..

10

answers

How to Remove Array Element and Then Re-Index Array?

I have some troubles with an array. I have one array that I want to modify like below. I want to remove element (elements) of it by index and then re-index array. Is it possible? $foo = array( '..

11

answers

How to generate .NET 4.0 classes from xsd?

What are the options to generate .NET 4.0 c# classes (entities) from an xsd file, using Visual Studio 2010?..

7

answers

when do you need .ascx files and how would you use them?

When building a website, when would it be a good idea to use .ascx files? What exactly is the .ascx and what is it used for? Examples would help a lot thanks!..

9

answers

What does OpenCV's cvWaitKey( ) function do?

What happens during the execution of cvWaitKey()? What are some typical use cases? I saw it in OpenCV reference but the documentation isn't clear on its exact purpose...

7

answers

How can I get nth element from a list?

How can I access a list by index in Haskell, analog to this C code? int a[] = { 34, 45, 56 }; return a[1]; ..

19

answers

/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found

How can I get GLIBCXX_3.4.15 in Ubuntu? I can't run some programs that I'm compiling. When I do: strings /usr/lib/libstdc++.so.6 | grep GLIBC I get: GLIBCXX_3.4 GLIBCXX_3.4.1 GLIBCXX_3.4.2 GLIBCX..

6

answers

replace String with another in java

What function can replace a string with another string? Example #1: What will replace "HelloBrother" with "Brother"? Example #2: What will replace "JAVAISBEST" with "BEST"?..

11

answers

Remove quotes from a character vector in R

Suppose you have a character vector: char <- c("one", "two", "three") When you make reference to an index value, you get the following: > char[1] [1] "one" How can you strip off the quote ..

6

answers

right align an image using CSS HTML

How can I right-align an image using CSS. I do not want the text to wrap-around the image. I want the right aligned image to be on a line by itself...

5

answers

Print string to text file

I'm using Python to open a text document: text_file = open("Output.txt", "w") text_file.write("Purchase Amount: " 'TotalAmount') text_file.close() I want to substitute the value of a string varia..

26

answers

CSS technique for a horizontal line with words in the middle

I'm trying to make a horizontal rule with some text in the middle. For example: ----------------------------------- my title here ----------------------------- Is there a way to do that in CSS? With..

7

answers

Build Step Progress Bar (css and jquery)

You've seen iterations of this type of progress bar on sites like paypal. How does one go about setting this up using CSS and jquery? I have 4 pages and each page is a step... so 4 steps...

13

answers

Convert timestamp to readable date/time PHP

I have a timestamp stored in a session (1299446702). How can I convert that to a readable date/time in PHP? I have tried srttotime, etc. to no avail...

12

answers

How to see indexes for a database or table in MySQL?

How do I see if my database has any indexes on it? How about for a specific table?..

4

answers

Sort a list of lists with a custom compare function

I know there are several questions named like this, but they don't seem to work for me. I have a list of lists, 50 times 5 elements. I want to sort this list by applying a custom compare function to ..

2

answers

JList add/remove Item

Hi I have to pick an element from a JList to another, removing it from the first The method I've created inserts only one element, overwriting the last one and doesn't remove the selected item from th..

7

answers

How do I set an un-selectable default description in a select (drop-down) menu in HTML?

I have a drop down where the user selects a language: <select> <option>English</option> <option>Spanish</option> </select> I want the default option tha..

8

answers

Sorting a Python list by two fields

I have the following list created from a sorted csv list1 = sorted(csv1, key=operator.itemgetter(1)) I would actually like to sort the list by two criteria: first by the value in field 1 and then b..

11

answers

How can I retrieve Id of inserted entity using Entity framework?

I have a problem with Entity Framework in ASP.NET. I want to get the Id value whenever I add an object to database. How can I do this? According to Entity Framework the solution is: using (var context..

3

answers

blur() vs. onblur()

I have a input tag with an onblur event listener: <input id="myField" type="input" onblur="doSomething(this)" /> Via JavaScript, I want to trigger the blur event on this input so that it, in ..

7

answers

Authenticate Jenkins CI for Github private repository

I'd like for Jenkins to automagically fetch data from my private repository hosted on Github. But I have no idea how to accomplish that task.. Tried the documentation, generating ssh-key for jenkins u..

11

answers

Get error message if ModelState.IsValid fails?

I have this function in my controller. [HttpPost] public ActionResult Edit(EmployeesViewModel viewModel) { Employee employee = GetEmployee(viewModel.EmployeeId); TryUpdateModel(employee); ..

4

answers

How to use CURL via a proxy?

I am looking to set curl to use a proxy server. The url is provided by an html form, which has not been a problem. Without the proxy it works fine. I have found code on this and other sites, but they ..

3

answers

Clicking submit button of an HTML form by a Javascript code

I don't know much about WEB probramming, so feel free to ask if I'm missing any details. There is a certain website which I'm visiting very frequently, and it requires users to log in every time they..

6

answers

SQL Query to fetch data from the last 30 days?

Hi I am new to Oracle. How do I do a simple statement, for example get product id from the last 30, or 20 days purchase date? SELECT productid FROM product WHERE purchase_date ? ..

44

answers

Passing data between view controllers

I'm new to iOS and Objective-C and the whole MVC paradigm and I'm stuck with the following: I have a view that acts as a data entry form and I want to give the user the option to select multiple produ..

8

answers

How can I get the height and width of an uiimage?

From the URL Image in Mail I'm adding image to mail view. It will show full image. But I want to calculate, proportionally change the height and width of the image. How can I get the height and widt..

5

answers

Adding whitespace in Java

There is a class trim() to remove white spaces, how about adding/padding? Note: " " is not the solution...

4

answers

How to use foreach with a hash reference?

I have this code foreach my $key (keys %ad_grp) { # Do something } which works. How would the same look like, if I don't have %ad_grp, but a reference, $ad_grp_ref, to the hash?..

5

answers

Undefined reference to sqrt (or other mathematical functions)

I have this simple code: max = (int) sqrt (number); and in the header I have: #include <math.h> But application still says undefined reference to sqrt. Do you see any problem here? It look..

16

answers

Execution time of C program

I have a C program that aims to be run in parallel on several processors. I need to be able to record the execution time (which could be anywhere from 1 second to several minutes). I have searched for..

13

answers

How to get a Color from hexadecimal Color String

I'd like to use a color from an hexa string such as "#FFFF0000" to (say) change the background color of a Layout. Color.HSVToColor looks like a winner but it takes a float[] as a parameter. Am I any ..

7

answers

In LINQ, select all values of property X where X != null

Is there a shorter way to write the following? (Something that would check for null without explicitly writing != null) from item in list where item.MyProperty != null select item.MyProperty ..

13

answers

Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction

In ASP.NET MVC, what is the difference between: Html.Partial and Html.RenderPartial Html.Action and Html.RenderAction ..

3

answers

Get table name by constraint name

Oracle constraint name is known. How do I find the name of the table for which this constraint is applied?..

5

answers

SQL Combine Two Columns in Select Statement

If I have a column that is Address1 and Address2 in my database, how do I combine those columns so that I could perform operations on it only in my select statement, I will still leave them separate ..

9

answers

How to get a complete list of ticker symbols from Yahoo Finance?

I've googled endlessly for a method of getting a complete (and daily updated) list of all Yahoo ticker symbols available through http://finance.yahoo.com Yahoo has information for stocks, futures etc..

7

answers

Open local folder from link

How can I open a local folder view by clicking on any link? I tried many options like <a href="file:///D:/Tools/">Open folder</a> or <a onclick="file:///D:/Tools/">Open folder<..

13

answers

PHP mkdir: Permission denied problem

I am trying to create a directory with PHP mkdir function but I get an error as follows: Warning: mkdir() [function.mkdir]: Permission denied in .... How to settle down the problem?..

19

answers

How to convert jsonString to JSONObject in Java

I have String variable called jsonString: {"phonetype":"N95","cat":"WP"} Now I want to convert it into JSON Object. I searched more on Google but didn't get an..

3

answers

What does the keyword "transient" mean in Java?

I saw somewhere transient private TrackDAO trackDAO; ..

9

answers

How do I use Comparator to define a custom sort order?

I want to develop a sorting demo for car list. I am using data table to display car list. Now actually I want to sort the list by car color. Here it is not sort by alphabetic order. I want to use my c..

7

answers

EOFError: end of file reached issue with Net::HTTP

I am using ruby-1.8.7-p302/Rails 2.3.11. I am trying to use FQL (Facebook API) to get stats for a link. Here's my code: def stats(fb_post_url) url = BASE_URI + "?query=#{URI.encode("select like_cou..

3

answers

python: Appending a dictionary to a list - I see a pointer like behavior

I tried the following in the python interpreter: >>> >>> a = [] >>> b = {1:'one'} >>> a.append(b) >>> a [{1: 'one'}] >>> b[1] = 'ONE' >>>..

7

answers

no debugging symbols found when using gdb

GNU gdb Fedora (6.8-37.el5) Kernal 2.6.18-164.el5 I am trying to debug my application. However, everytime I pass the binary to the gdb it says: (no debugging symbols found) Here is the file ou..