Some Of The Best Answers From Latest Asked Questions

12

answers

Difference between .on('click') vs .click()

Is there any difference between the following code? $('#whatever').on('click', function() { /* your code here */ }); and $('#whatever').click(function() { /* your code here */ }); ..

9

answers

Call An Asynchronous Javascript Function Synchronously

First, this is a very specific case of doing it the wrong way on-purpose to retrofit an asynchronous call into a very synchronous codebase that is many thousands of lines long and time doesn't current..

9

answers

Javascript: The prettiest way to compare one value against multiple values

Whats the prettiest way to compare one value against multiples options? I know there are loads of ways of doing this, but I'm looking for the neatest. i ask because i'd hoped this was workable (it i..

13

answers

Facebook share link without JavaScript

The following link is for sharing a page on Twitter: http://twitter.com/share Is there a similar option for Facebook that doesn't require JavaScript? I know about http://facebook.com/sharer.php, bu..

5

answers

How to present a simple alert message in java?

Coming from .NET i am so used calling Alert() in desktop apps. However in this java desktop app, I just want to alert a message saying "thank you for using java" I have to go through this much sufferi..

5

answers

"Unable to locate tools.jar" when running ant

When running ant, I get the following message: Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar I have JAVA_HOME set to C:\Program Files\Java\jdk1.7.0_02, ..

8

answers

C++ class forward declaration

When I try to compile this code, I get: 52 C:\Dev-Cpp\Projektyyy\strategy\Tiles.h invalid use of undefined type `struct tile_tree_apple' 46 C:\Dev-Cpp\Projektyyy\strategy\Tiles.h forward declaration ..

5

answers

Test if a string contains a word in PHP?

In SQL we have NOT LIKE %string% I need to do this in PHP. if ($string NOT LIKE %word%) { do something } I think that can be done with strpos() But can’t figure out how… I need exactly that ..

2

answers

Excluding Maven dependencies

I have a query about exclusion of maven dependencies . Consider the following <dependency> <groupId>org.springframework.security</groupId> <artifactId>sprin..

14

answers

Linux/Unix command to determine if process is running?

I need a platform independent (Linux/Unix|OSX) shell/bash command that will determine if a specific process is running. e.g. mysqld, httpd... What is the simplest way/command to do this?..

22

answers

UIView Hide/Show with animation

My simple goal is to fade animate hiding and showing functions. Button.hidden = YES; Simple enough. However, is it possible to have it fade out rather than just disappearing? It looks rather unprof..

5

answers

Is it possible to indent JavaScript code in Notepad++?

I have some JavaScript code that is written in one line (no carriage returns), it's completely unreadable... With Notepad++, I tried to replace these characters ({, }, ;) by themselves plus a carriag..

4

answers

batch to copy files with xcopy

I have checked some examples on internet but I can't get my (first) batch file to work. I would like to copy automatically my file from a folder to another one but nothing happen. @echo off xcopy "C:..

6

answers

LINQ Using Max() to select a single row

I'm using LINQ on an IQueryable returned from NHibernate and I need to select the row with the maximum value(s) in a couple of fields. I've simplified the bit that I'm sticking on. I need to select ..

5

answers

Spacing between elements

I'm a complete begginer in CSS and HTML and I'm building my first basic page for training. What I want do do now is have spacing between two elements without using <br>. Currently I'm using thi..

6

answers

jQuery - Appending a div to body, the body is the object?

When I'm adding a div to body, it's returning the body as the object and then whenever I use that - it's obviously using body. Bad. Code:- var holdyDiv = $('body').append('div'); $(holdyDiv).attr('i..

2

answers

JSON for List of int

I have a class public class ItemList { public long Id { get; set; } public string Name { get; set; } public string Description { get; set; } public List<int> ItemModList { get; ..

6

answers

diff current working copy of a file with another branch's committed copy

I have a repo with file foo in the master branch. I switched to bar branch and made some changes to foo. How can I now run a git diff between this copy (which isn't committed yet) and the copy of the ..

4

answers

Extract text from a string

How do I extract the "program name" from a string. The string will look like this : % O0033(SUB RAD MSD 50R III) G91G1X-6.4Z-2.F500 G3I6.4Z-8. G3I6.4 G3R3.2X6.4F500 G91G0Z5. G91G1X-10.4 G..

6

answers

T-SQL: How to Select Values in Value List that are NOT IN the Table?

I have a list of e-mail addresses, some of them are in my table, some of them are not. I want to select all e-mails from that list and whether they are in the table or not. I can get users whose ma..

9

answers

Jackson: how to prevent field serialization

I have an entity class with a password field: class User { private String password; //setter, getter.. } I want this field to be skipped during serialization. But it should still be able to ..

8

answers

How to convert Calendar to java.sql.Date in Java?

Calendar cal; String sql = "INSERT INTO ttable (dt) values (?);" //dt is a dateTime field in ttable PreparedStatement stmt = connection.prepareStatement(sql); stmt = setDate(1,cal); //not working s..

2

answers

mysql SELECT IF statement with OR

The following works - returns Y when chargeback equal to 1 else it defaults to N IF(fd.charge_back = 1, 'Y', 'N') AS charge_back however I cannot seem to get this one working? Is the syntax valid ..

17

answers

How to move the layout up when the soft keyboard is shown android

I have a login screen with two EditTexts and a login button in my layout. The problem is that, when I start typing, the soft keyboard is shown and covers the login button. How can I push the layout up..

7

answers

Serializing a list to JSON

I have an object model that looks like this: public MyObjectInJson { public long ObjectID {get;set;} public string ObjectInJson {get;set;} } The property ObjectInJson is an already serialized v..

13

answers

Asynchronous Requests with Python requests

I tried the sample provided within the documentation of the requests library for python. With async.map(rs), I get the response codes, but I want to get the content of each page requested. This, for ..

10

answers

Can I write a CSS selector selecting elements NOT having a certain class or attribute?

I would like to write a CSS selector rule that selects all elements that don't have a certain class. For example, given the following HTML: <html class="printable"> <body class="printabl..

9

answers

Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7)

I've got a XAMPP installation running on Windows 7. As soon as I add a VirtualHost to httpd-vhosts.conf, BOTH the 'regular' http://localhost AND the new dropbox.local aren't working. This is what I..

6

answers

Include another JSP file

I am currently trying to learn JSP. My question is, at present I used to include the header and footer of the page using: <%@include file="includes/header.jsp" %> and <%@include file="in..

3

answers

base64 encoded images in email signatures

I have to include some images (company logo's etc) in email signatures. I've had all sorts of issues using the embedded images produced by the email system in question (they get sent as attachments ge..

12

answers

Android-java- How to sort a list of objects by a certain value within the object

Im trying to sort through an arraylist of objects by a particular value within the object. What would be the best approach to do such a thing. Should I use Collections.sort() with some kind of compara..

5

answers

How to use an existing database with an Android application

I have already created an SQLite database. I want to use this database file with my Android project. I want to bundle this database with my application. Instead of creating a new database, how can t..

3

answers

ggplot combining two plots from different data.frames

I want to combine two ggplots, from two different data.frames, into one plot. Below you will find the code. I want to combine plot 1&2 or plots 3&4. df1 <- data.frame(p=c(10,8,7,3,2,6,7,8)..

6

answers

Can someone explain mappedBy in JPA and Hibernate?

I am new to hibernate and need to use one-to-many and many-to-one relations. It is a bi-directional relationship in my objects, so that I can traverse from either direction. mappedBy is the recommende..

14

answers

Sorting rows in a data table

We have two columns in a DataTable, like so: COL1 COL2 Abc 5 Def 8 Ghi 3 We're trying to sort this datatable based on COL2 in decreasing order. COL1 COL2 ghi 8 a..

5

answers

R: Comment out block of code

Possible Duplicate: R: Multiline Comment Workarounds? I want to comment out several lines of code in R. Is there any way of doing it without having to put a # before each line - sort of lik..

4

answers

Sorting Characters Of A C++ String

If i have a string is there a built in function to sort the characters or would I have to write my own? for example: string word = "dabc"; I would want to change it so that: string sortedWord = "..

2

answers

How to execute 16-bit installer on 64-bit Win7?

I am trying to install Sheridan controls (ActiveThreed 2.01) on Win7 64-bit, but evidently it is a 16-bit installer so it won't execute. What would be the best way to get round this problem? Can a..

6

answers

Implicit function declarations in C

What is meant by the term "implicit declaration of a function"? A call to a standard library function without including the appropriate header file produces a warning as in the case of: int main(){ ..

7

answers

SQL Query for Selecting Multiple Records

I have 9 fields and I need to see all the data from these fields which have a particular set of IDs. Could any one tell me the SQL query for it? Ex: Database contains 100 records. I need to select a ..

7

answers

How to fill in proxy information in cntlm config file?

Cntlm is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy intended to help you break free from the chains of Microsoft proprietary world. I have my proxy URL in the following f..

7

answers

How to support UTF-8 encoding in Eclipse

How can I add UTF-8 support in eclipse? I want to add for example Russian language but eclipse won't support it. What should I do? Please guide me...

7

answers

How to handle change of checkbox using jQuery?

I have some code <input type="checkbox" id="chk" value="value" /> <label for="chk">Value </label> <br/> <input type="button" id="But1" value="set value" /> <br /> ..

5

answers

Using Oracle to_date function for date string with milliseconds

I have to perform some inserts into an Oracle DB. I have some dates in the following format '23.12.2011 13:01:001' Following the documentation I wrote inserts to_date as follows: to_date('23.12.2..

4

answers

Detecting a redirect in ajax request?

I want to use jQuery to GET a URL and explicitly check if it responded with a 302 redirect, but not follow the redirect. jQuery's $.ajax appears to always follow redirects. How can I prevent this, a..

5

answers

Getting the current date in visual Basic 2008

I dont know how to get the current date in visual basic 2008. Here is a sample code regDate = Format(Date.Now(), "ddMMMyyyy") The output is like 7/02/1900 Need help..

38

answers

Express.js req.body undefined

I have this as configuration of my Express server app.use(app.router); app.use(express.cookieParser()); app.use(express.session({ secret: "keyboard cat" })); app.set('view engine', 'ejs'); app.set("..

8

answers

How to set radio button checked as default in radiogroup?

I have created RadioGroup and RadioButton dynamically as following: RadioGroup radioGroup = new RadioGroup(context); RadioButton radioBtn1 = new RadioButton(context); ..

3

answers

best practice font size for mobile

I have seen this question on SO: What are the most common font-sizes for H1-H6 tags with this being the recommended font sizes fo H tags: h1 { font-size: 2em; } h2 { font-size: 1.5em; } h3 { font-si..

13

answers

Byte array to image conversion

I want to convert a byte array to an image. This is my database code from where I get the byte array: public void Get_Finger_print() { try { using (SqlConnection thisConnection = new..

3

answers

LINQ: combining join and group by

I have a query that combines a join and a group, but I have a problem. The query is like: var result = from p in Products join bp in BaseProducts on p.BaseProductId equals b..

12

answers

Add / remove input field dynamically with jQuery

I would like to use jquery to build a dynamic add/ remove form. IT should look like: Name Type Required? The example input : Name Type Required? Tony Admin checked (checkbox) Delete <==pres..

8

answers

Setting up Vim for Python

I really like the Emacs editor for Python because of it's smart tabbing for instance if I have something like this def foo(): if bar: blah [b]eep and I press tab on the cursor..

7

answers

How to remove unique key from mysql table

I need to remove a unique key from my mysql table. How can remove that using mysql query. I tried this but it is not working alter table tbl_quiz_attempt_master drop unique key; Please help me Th..

10

answers

Add a pipe separator after items in an unordered list unless that item is the last on a line

Is it possible to style this html ... <ul> <li>Dogs</li> <li>Cats</li> <li>Lions</li> <li>Tigers</li> <li>Zebras</li..

7

answers

How do I exit from the text window in Git?

I am using Windows and before committing, Git wants me to enter a text message and a new text window appears. How can I exit from this? I am trying to learn Git. So, a little help will be highly..

6

answers

How do you get the magnitude of a vector in Numpy?

In keeping with the "There's only one obvious way to do it", how do you get the magnitude of a vector (1D array) in Numpy? def mag(x): return math.sqrt(sum(i**2 for i in x)) The above works, b..

9

answers

surface plots in matplotlib

I have a list of 3-tuples representing a set of points in 3D space. I want to plot a surface that covers all these points. The plot_surface function in the mplot3d package requires as arguments X,Y a..

4

answers

List of Java class file format major version numbers?

I saw this list of major version numbers for Java in another post: Java 1.2 uses major version 46 Java 1.3 uses major version 47 Java 1.4 uses major version 48 Java 5 uses major version 49 Java 6 us..

9

answers

Toad for Oracle..How to execute multiple statements?

I have some 800-1200 INSERT statements generated from an excel sheet. I want to run these in TOAD - Oracle db. If I press F9, it runs only one line and F5 gives me syntax issue and do not seem to wor..

8

answers

Pretty-Print JSON Data to a File using Python

A project for class involves parsing Twitter JSON data. I'm getting the data and setting it to the file without much trouble, but it's all in one line. This is fine for the data manipulation I'm tryin..

10

answers

Netbeans how to set command line arguments in Java

I am trying to set command line arguments in a Netbeans 7.1 Java project on Windows 7 64 bit. Netbeans is not passing the arguments I give it. I go to Project --> Properties --> Run --> and type th..

6

answers

Read a text file using Node.js?

I need to pass in a text file in the terminal and then read the data from it, how can I do this? node server.js file.txt How do I pass in the path from the terminal, how do I read that on the other..

2

answers

How can I determine if a String is non-null and not only whitespace in Groovy?

Groovy adds the isAllWhitespace() method to Strings, which is great, but there doesn't seem to be a good way of determining if a String has something other than just white space in it. The best I've ..

11

answers

Using a dictionary to select function to execute

I am trying to use functional programming to create a dictionary containing a key and a function to execute: myDict={} myItems=("P1","P2","P3",...."Pn") def myMain(key): def ExecP1(): p..

15

answers

How to dump a table to console?

I'm having trouble displaying the contents of a table which contains nested tables (n-deep). I'd like to just dump it to std out or the console via a print statement or something quick and dirty but I..

13

answers

Using Default Arguments in a Function

I am confused about default values for PHP functions. Say I have a function like this: function foo($blah, $x = "some value", $y = "some other value") { // code here! } What if I want to use th..

7

answers

Convert RGBA PNG to RGB with PIL

I'm using PIL to convert a transparent PNG image uploaded with Django to a JPG file. The output looks broken. Source file Code Image.open(object.logo.path).save('/tmp/output.jpg', 'JPEG') or I..

10

answers

How to copy selected lines to clipboard in vim

How to copy selected lines to clipboard in vim. I know how to do it for all text files, but I want to do in for selected lines. Thanks!..

9

answers

NULL or BLANK fields (ORACLE)

I'm new to Oracle, so my question might sound silly. I did go through the previous posts, but no luck. In the table, there is a column which is blank, and i am trying to find out the blank count in th..

7

answers

Convert string to JSON Object

How do I convert string to object? I am facing this problem because I am trying to read the elements in the JSON string using "each". My string is given below. jsonObj = "{"TeamList" : [{"teamid" : ..

22

answers

Node.js EACCES error when listening on most ports

I'm testing out an app (hopefully to run on heroku, but am having issues locally as well). It's giving me an EACCES error when it runs http.Server.listen() - but it only occurs on some ports. So, lo..

6

answers

How do I add a Maven dependency in Eclipse?

I don't know how to use Maven at all. I've been developing for a couple years with Eclipse and haven't yet needed to know about it. However, now I'm looking at some docs that suggest I do the follow..

22

answers

make iframe height dynamic based on content inside- JQUERY/Javascript

I am loading an aspx web page in an iframe. The content in the Iframe can be of more height than the iframe's height. The iframe should not have scroll bars. I have a wrapper div tag inside the ifram..

5

answers

fatal: Not a valid object name: 'master'

I have a private server running git 1.7 When I git init a folder it doesn't create a master branch. Cause when i do: git branch it doesn't list anything. When I do: git --bare init it cr..

15

answers

Getting android.content.res.Resources$NotFoundException: exception even when the resource is present in android

Please let me know where I am going wrong to get the error. I am creating an app which have one of its activity to be only in landscape mode. So I added the following in AndroidManifest.xml file <..

8

answers

OS specific instructions in CMAKE: How to?

I am a beginner to CMAKE. Below is a simple cmake file which works well in mingw environment windows. The problem is clearly with target_link_libraries() function of CMAKE where I am linking libwsock3..

9

answers

Differences between C++ string == and compare()?

I just read some recommendations on using std::string s = get_string(); std::string t = another_string(); if( !s.compare(t) ) { instead of if( s == t ) { I'm almost always using the last one..

4

answers

Nullable DateTime conversion

Possible Duplicate: c# why cant a nullable int be assigned null as a value Im trying to convert my reader[3] object which is datetime to be null if there is no lastPostDate for a Forum but ..

5

answers

Android: No Activity found to handle Intent error? How it will resolve

No Activity found to handle Intent error? How it will resolve. Preference customPref = (Preference) findPreference("DataEntryScreen"); customPref .setOnPreferenceClickListener(new OnPrefe..

13

answers

How do I raise the same Exception with a custom message in Python?

I have this try block in my code: try: do_something_that_might_raise_an_exception() except ValueError as err: errmsg = 'My custom error message.' raise ValueError(errmsg) Strictly speak..

21

answers

Recursively counting files in a Linux directory

How can I recursively count files in a Linux directory? I found this: find DIR_NAME -type f ¦ wc -l But when I run this it returns the following error. find: paths must precede expression: ¦..

20

answers

ORA-01882: timezone region not found

I'm accessing an Oracle Database from a java application, when I run my application I get the following error: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 ORA-01882..

14

answers

How to copy a row and insert in same table with a autoincrement field in MySQL?

In MySQL I am trying to copy a row with an autoincrement column ID=1 and insert the data into same table as a new row with column ID=2. How can I do this in a single query?..

9

answers

What is the difference between `throw new Error` and `throw someObject`?

I want to write a common error handler which will catch custom errors thrown on purpose at any instance of the code. When I did throw new Error('sample') like in the following code try { throw n..

15

answers

ORA-01461: can bind a LONG value only for insert into a LONG column-Occurs when querying

When I try to query objects, I end up with following error: ORA-01461: can bind a LONG value only for insert into a LONG column Could someone please help me on the cause and solution of the problem..

11

answers

How to read an excel file in C# without using Microsoft.Office.Interop.Excel libraries

I have a .Net-Windows application in C#. I need to open an excel and process it. How can I do this without using Microsoft.Office.Interop.Excel libraries?..

8

answers

Set transparent background using ImageMagick and commandline prompt

Suppose you have any image (PNG or JPG). This image has a white background and I need to make this background transparent. I have tried with these examples: convert original.png -background none tr..

8

answers

Check whether $_POST-value is empty

if(isset($_POST['submit'])) { if(!isset($_POST['userName'])) { $username = 'Anonymous'; } else $username = $_POST['userName']; } I cannot get the $username to be "Anonymous..

5

answers

ruby LoadError: cannot load such file

When I require a file, for example (called st.rb): require 'rubygems' require 'mongrel' class TestHandler < Mongrel::HttpHandler def process(request, response) response.start(200) do |head..

7

answers

What is the recommended way to delete a large number of items from DynamoDB?

I'm writing a simple logging service in DynamoDB. I have a logs table that is keyed by a user_id hash and a timestamp (Unix epoch int) range. When a user of the service terminates their account, I n..

24

answers

Is there a way to get version from package.json in nodejs code?

Is there a way to get the version set in package.json in a nodejs app? I would want something like this var port = process.env.PORT || 3000 app.listen port console.log "Express server listening on po..

6

answers

How to communicate between iframe and the parent site?

The website in the iframe isn't located in the same domain, but both are mine, and I would like to communicate between the iframe and the parent site. Is it possible?..

16

answers

Tips for debugging .htaccess rewrite rules

Many posters have problems debugging their RewriteRule and RewriteCond statements within their .htaccess files. Most of these are using a shared hosting service and therefore don't have access to the..

5

answers

How to limit file upload type file size in PHP?

I have an upload form and am checking the file size and file type to limit the uploaded file to 2 megabytes and either .pdf, .jpg, .gif or .png file types. My goal is to have an alert message display..

16

answers

How to iterate over a JSONObject?

I use a JSON library called JSONObject (I don't mind switching if I need to). I know how to iterate over JSONArrays, but when I parse JSON data from Facebook I don't get an array, only a JSONObject,..

8

answers

compareTo with primitives -> Integer / int

Is it better to write int primitive1 = 3, primitive2 = 4; Integer a = new Integer(primitive1); Integer b = new Integer(primitive2); int compare = a.compareTo(b); or int primitive1 = 3, primitive2..

5

answers

select the TOP N rows from a table

I am making some paging, and I need to make some query and get the result form defined slicing . for example: I need to get all "top" rows in range 20n < x < 40n etc. SELECT * FROM Reflow WH..

5

answers

org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing

In my project I have User, Role, UserRole and BloodGroup entities. Firstly I take List<BloodGroup> from DB and set to User. Then I give User and Role entites to UserRole. After that I insert Use..

6

answers

Get folder up one level

I am using this: echo dirname(__FILE__); which gives: C:\UwAmp\www\myfolder\admin However I am looking for path until: C:\UwAmp\www\myfolder\ from current script. How can that be done ?..