w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to read from input file (text file) and validate input as valid integer?
I would probably read the line with std::getline, then use a Boost lexical_cast to convert to int. It will throw an exception unless the entirety of the input string can be converted to the target type -- exactly what you want. Of course, you'll also need to check that the converted result is in the correct range, and also throw the exception if it's out of range.

Categories : C++

replacing linspace with meshgrid
x=linspace(0,100,100); First comment: this will not produce [0 1 2 ... 100] - for that you would use linspace(0,100,101) since there are 101 elements in 0:100 You were actually very close to getting this right. Just don't turn xx into xx(:) (then the shape will be wrong at the end): [xx yy] = meshgrid(0:100, 0:100); % I like to use xx and yy to remind myself they are 2d... x0=[0 1 2 3]; y0=[4 5 6 7]; for ii=1:4 % I use ii since i is also used as a built in variable with value sqrt(-1) r(ii,:,:) = sqrt((xx - x0(ii)).^2 + (yy - y0(ii)).^2); end It is probably OK to leave the innermost for loop. I can't think of a way to get rid of it that wouldn't make your code less readable.

Categories : Matlab

How to check if input is valid or not?
In this case there's not really much you can do. If you try to read a floating-point number into an integer variable, that will not give any error since the stream (with the number in your example) reads the 1 as an integer, which it of course is. What you could do is to peek at the next character to see if it is something you expect or not.

Categories : C++

Matlab: Submatrix selection using meshgrid() matrices
I found the answer P = impixel(G, floor(Qx), floor(Qy)); G_samples = reshape(P(;,1), size(Qx)); (just making sure this question is marked as answered incase some one has the same problem)

Categories : Matlab

valid user input which begins with nine digits and ends with x or v
Here is the regex: /^[+-]?[0-9]{9}[xv]$/ [+-]?: Means optional sign [0-9]{9}: Means 9 digits [xv]: Means one of the 'x' or 'v'

Categories : Javascript

Determine if string input could be a valid directory in Python
Unless I'm misunderstanding, os.path does have the tools you need. def check_names(infile): if os.path.isdir(infile): <do stuff> elif os.path.exists(infile): <do stuff> ... These functions take in the path as a string, which I believe is what you want. See os.path.isdir and os.path.exists. Yes, I did misunderstand. Have a look at this post .

Categories : Python

K&R valid input for arrays & pointers in the swap function
how can I re-write the for loop without having to use a magic number (in this case 4)? One way of doing this, is to add a special terminator value ( usually NULL) in the array that you are iterating, e.g. char *v[] = { a, b, c, d, NULL }; for(count = 0; v[count] != NULL; ++count) printf("%s",v[count]);

Categories : C

Which exception to throw for invalid input which is valid from client perspective
Exceptions should be used to catch errors in program flow ("what happens inside") , not for input validation. I wouldn't throw an exception at all. Think about it, this is not what "exception" means as it is completely normal for the user to input two lines with equal slopes.

Categories : Java

Check if input number is valid in Codeigniter Form Validation
Try the is_numeric() function in PHP: http://php.net/manual/en/function.is-numeric.php It'd return true if the number is an valid number, and return false if it isn't.

Categories : PHP

I'm trying to limt user input to a valid price using jquery & javascript. How do i prevent second decimal point
var str = this.value; var firstDot = str.indexOf('.'); var secondDot = str.indexOf('.', firstDot + 1); if ( firstDot >= 0 && secondDot >= 0 ) { this.value = str.substr(0, secondDot) + str.substr(secondDot + 1); } Here's the fiddle: http://jsfiddle.net/YN4ta/

Categories : Javascript

How can I rearrange this so input Ctrl-z(end of file signal) breaks loop while still testing for valid inputs in c++
Well, you can read the input word by word and parse these words separately. If the number can not be retrieved from the word, user will be asked to enter the input again. If there are no more words, the loop will stop: std::string word; std::cout << "Enter score: "; while (std::cin >> word) { unsigned int value; std::istringstream is(word); if (is >> value) { assignmentScore.push_back(value); } else { std::cout << std::endl << word << " is not a valid positive numerical value. try again."; std::cin.clear(); std::cin.ignore(numeric_limits<int>::max(), ' '); } std::cout << std::endl << "Enter score: "; } just avoid using cin.fail() for checking whether the retr

Categories : C++

How can I use input in grid view?
You could place the grid along with its checkboxes inside an HTML form and make the Delete button as submit button for this form. Then when the button is clicked, the form will be submitted and the values of the selected checkboxes will be sent to the controller action so that you could delete the corresponding records.

Categories : Asp Net Mvc

Hidden input is messing up grid
Seems to work as desired if you move the hidden field (http://jsfiddle.net/EZMvB/1/). Not sure why placement matters since the default style of display: none should prevent it from affecting layout? <div class="container-fluid"> <form action="/admin/category/create" class="row-fluid" method="post"> <div class="span6"> <label for="NameEnglish">Name (English)</label> <input class="input-block-level" name="NameEnglish" type="text"> </div> <div class="span6"> <label for="NameEnglish">Name (English)</label> <input class="input-block-level" name="NameEnglish" type="text"> </div> <input type="submit" value="Create" class="btn btn-l

Categories : HTML

findContours, contourArea give errors with nested contours. "Assertion failed", "input array is not a valid matrix"
I cannot judge for the CV_EXTERNAL case. BUt in the first case the problem seems simple. for (int i = 1; i != ContourVector.size(); ++i){ if ( (contourArea(ContourVector[i])) > BiggestContourArea) { biggest = i; BiggestContourArea = contourArea(ContourVector[biggest]); } } In C++ arrays and vectors are indexed from zero. So first item in vector has index 0, and the last one has ContourVector.size() - 1. To fix you code simply change the for cycle to: for (int i = 1; i < ContourVector.size(); ++i) ....

Categories : C++

input-prepend in Bootstrap responsive grid
<label class="add-on span1"><input type="checkbox" /></label> <input class="input-small span11" type="text" placeholder="Cost Range"/> add classes like this on label and input .. similarly you can add class on control-group also.. and can vary the width by using span1- span12 or span* in case if it still creates problem wrap control group in a row..

Categories : HTML

How to Prevent Identical input of Value in Kendo Grid
In your javascript you could have a list of 'days used' and push and pop a day is used and remove when no longer used. Then use that array to validate selection (Add a select event to your dropdown).

Categories : Javascript

Extjs create a grid feature or grid plugin that sets a tooltip for each column in the grid
In your plugins init method, you will be able to loop through the columns of the grid (the constructor and initComponent methods of the grid will have already been called at this point). That means that you can inspect each column to see if the user has setup a custom renderer. If there is none, you can put your one, and if there is one, you can chain the existing renderer with yours. EDIT Ext.define('My.Plugin', { init: function(grid) { // You may not need the scope, but if you do, this binding will // allow to preserve the scope configured in the column... var pluginRenderer = Ext.Function.bind(this.renderer, this); Ext.each(grid.query('gridcolumn'), function(col) { var renderer = col.renderer; col.renderer = renderer

Categories : Extjs

How do I apply a MINIMUM value to a Kendo grid column input box?
I figured it out: schema: { model: { id: "namefirstlast", fields: { "namefirstlast": { editable: true, type: "string" }, "directorsequence": { editable: true, type: "number" }, "isonballot": { editable: true, type: "boolean" }, "concatenation": { editable: true, type: "string" }, "MoreNames": { editable: true, type: "number", validation: { min: 0 } }, } }, } },

Categories : Jquery

show and hide an input button in web grid table
Is this the sort of thing you were looking for? Working jsFiddle here HTML: <table id="mytable"> <tr> <th>First Name</th> <th>Last Name</th> </tr> <tr> <td> <input type="text" class="txt_input" id="fname" /> </td> <td> <input type="text" class="txt_input" id="lname" /> </td> </tr> </table> <input type="button" id="edbutt" value="Allow Editing" /> <input type="button" id="svbutt" class="hidden" value="Save" /> jQuery/Javascript $('.txt_input').prop("disabled", true); $('#edbutt').click(function() { $('.txt_input').prop("disabled", false); $('#svbutt').removeClass('hidden'); $(thi

Categories : Jquery

Input elements overflow bootstrap grid system cells?
I think you're asking if it's possible to limit the amount of characters that can be entered into the input field. If not, then I apologize. This is how you would do that: <input data-bind="" maxlength="10"> This sets the maximum number of characters that can be input into that field to 10, or whatever integer you want to put in there. EDIT: Or if the problem is that the input field is visually too long, you can do the following: <div class="container"> <div class="row-fluid"> <div class="span7"></div> <div class="span2">per Invoice</div> <div class="span2 offset1">per LB</div> </div> <div class="row-fluid"> <div class="span7"> <select> <option&g

Categories : CSS

jQuery - create bootstrap grid based on user input
You can use split function. Example: var input = "3 3 2 4"; var parts = input.split(" "); console.log(parts); Output: ["3", "3", "2", "4"] And then just loop through the array to add them one by one to your div container (better assign id to the div container though) This is an example of looping through the array. (reference: Jquery split function) for (i = 0, l = parts.length; i < l; i++) { $('div.container').append('<div class=span' + parts[i] + '></div>') }

Categories : Jquery

Error Specified cast is not valid
Whether table EP_PATTERNS contains any rows? Otherwise you a trying to cast NULL to int and fails. You code should looks like: SqlConnection cn = new SqlConnection(constring); cn.Open(); SqlCommand cmd = new SqlCommand("select max(ID) from EP_PATTERNS ", cn); var value = (int?)cmd.ExecuteScalar(); int maxId = value.HasValue ? value.Value + 1 : 0; //Increase value or default it to zero txtID.Text = maxId.ToString(); cn.Close();

Categories : C#

Netbeans Error a Valid XML
It's been a while since I implemented a Netbeans Swing application, but I do remember that when you create a form, it creates an auxiliary file with xml (perhaps the suffix is ".form" or something similar, but I don't remember for sure). In any case, close Netbeans and search the project directory for the auxiliary file (the file prefix should be your class name). Open it up in a text editor, and hopefully it will be obvious how the xml got corrupted and how to fix it.

Categories : Java

Error 401 - But htpasswd valid
Remove this line: AuthGroupFile /dev/null And check that /home/NDD.fr/.htpasswd is readable by the apache2 or www-data user. (If you don't know how to do that, run ls -la /home/NDD.fr/ | grep htpasswd on your server.)

Categories : Htaccess

Raise error when date is not valid
You can write your own to_date() function, but you have to call it with its schema-qualified name. (I used the schema "public", but there's nothing special about that.) create or replace function public.to_date(any_date text, format_string text) returns date as $$ select to_date((any_date::date)::text, format_string); $$ language sql Using the bare function name executes the native to_date() function. select to_date('20130229', 'yyyymmdd'); 2013-03-01 Using the schema-qualified name executes the user-defined function. select public.to_date('20130229', 'yyyymmdd'); ERROR: date/time field value out of range: "20130229" SQL state: 22008 I know that's not quite what you're looking for. But . . . It's simpler than rebuilding PostgreSQL from source. Fixing up your existing SQL and PL

Categories : Postgresql

Specified Cast not Valid error using Nhibernate
Use whatever rounding, truncating etc. that you need in the SELECT-part of the SQL query. But you should also check what the actual return type of the SQL query is. Is it really decimal?

Categories : C#

CHCSVParser returns nil Array for valid filePath & valid csv file
So what counts as a "very big file" anyway? At which point is it prudent to use delegation over the simple 'arrayWithContentsofCSVFile'? The way that CHCSVParser reads and parses your CSV file is identical regardless of whether you're using the NSArray category method or directly interfacing with the delegate itself (you can see this for yourself here). So "a very big file" is really a CSV file which would be too large to hold in memory as an NSArray in its entirety. The memory consumption will depend both on the number of columns and the number of rows, so it's hard to give a definite limit. What this means is that the problems you get from using the -arrayWithContentsOfCSV with large files shouldn't manifest themselves as returning nil, but as low memory warnings and the like. The

Categories : Iphone

How to extract valid string from beginning to the first no base64 valid character?
You could use a regular expression to remove the invalid portion: import re invalid_tail = re.compile(r'[^a-zA-Z0-9+/= ].*$') def remove_tail(base64_value): return invalid_tail.sub('', base64_value) The [^a-zA-Z0-9+/= ] matches any character that is not a valid Base64 character, plus the trailing = padding and newlines and carriage returns (which are allowed in encoded values to wrap lines). Demo: >>> example = 'The quick brown fox jumps over the lazy dog!'.encode('base64') >>> remove_tail(example + '*This is a tail').decode('base64') 'The quick brown fox jumps over the lazy dog!' or, using the decodable portion of your sample: >>> data = "3AQEFGh8NFgoqDwYsAQALDVFPVltYVkNGXldCRFUbNRk=----------:jhawrewre:-- " >>> remove_tail(data).decode

Categories : Python

leapmotion creating a valid device -> adding to valid controller
You don't create Device objects yourself. The Device class describes connected devices. Get a Device object from the Controller object after the controller has "connected". (Currently only one Leap Motion device can be recognized.)

Categories : C++

Syntax error in a valid JSON document
The client is trying to execute the Script resource (it is interpreted as Script, not JSON). {"test":fail"} is invalid JavaScript -- try running it in the console. jsonp requires a callback that is ordinarily requested by the client so that it can be run properly. You should actually be doing something like: response.write(request.query.callback + "(" + JSON.stringify(json) + ")"); This will be emitted as callback12345({"test":"fail"}) which is valid JavaScript and will run properly.

Categories : Json

System.InvalidCastException: Specified cast is not valid. Error
The most likely cause of the InvalidCastException is the x.Field<Int32>("userid") line. The Field<T> extension method will throw an InvalidCastException in the case where the actual type of the data doesn't match the type which was passed to Field<T>. Hence if userid wasn't an Int32 this would throw. EDIT Based on your comments the type of userid is actually UInt32 and not Int32. This is what is causing the problem. Try using the following and it should work x.Field<UInt32>("userid")

Categories : C#

ASP.NET Web API: model is valid if error message is set from resources
I tried your solution, yet I do not understand class Resources.Localization. Where did it come from? My solution is described below and it was working with good resources. Model: using TestApp.Properties; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; namespace TestApp.Models { public class LoginModel { public string Email { get; set; } [Required] [MinLength(5, ErrorMessageResourceName="Test", ErrorMessageResourceType=typeof(Resources))] public string Password { get; set; } } } ModelValidationFilterAttribute: using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Web; using System.Web.Http.Controllers; using System.

Categories : C#

parseJSON will throw error on valid JSON
I believe you are missing one backslash in , and - it should be \r, \n and \t. Adding those makes jQuery.parseJSON() work just fine - http://jsfiddle.net/Nv282/. Could you show how are you escaping characters in escaparCaracteresJSON() function?

Categories : Java

Error on filling my model in MVC "Specified cast is not valid"
This can happen if row["category"] (same applied for row["topicID"]) is NULL in the data row because you can't cast null to non-nullable int. I notice that you are left joining your tblCategory and therefore NULL is a real possibility. Either fix on the server using a coalescing function (i.e to force any NULL category to default to 0) or else check if row["category"]==DBNull.Value before you attempt to cast it, or indeed use Int32.TryParse and have whatever handling for a category of 0, etc.

Categories : C#

Async causing error of Parameter is not valid
I found my issue. I was accessing my fonts in a static manner, as in a constant, and inside using(){} blocks. So I wrote a function that returns a new copy of the constant font, this way it doesn't matter if the font gets disposed.

Categories : C#

Tomcat 7 startup error: tcnative.dll is not valid
Basically It seems that you may have an incorrect version. Are you using multiple java on your machines if yes then try to look into environment variables for JAVA_HOME & PATH. Secondly, also paste the complete version of java and tomcat Also run following commands at command prompt java -version javac -version echo %JAVA_HOME% And are you using MSI installer of tomcat or just a zip version of tomcat. Because in many cases MSI installer never work for some ghost reasons.

Categories : Java

How to use Grid inside Grid (Nested Grid) on Devexpress tools in WPF
To show a nested grid for your GridControl rows define DataRowTemplate. like this: <my:GridControl Name="dgPhotoJobs" MouseDoubleClick="dgPhotoJobs_MouseDoubleClick"> <my:GridControl.Columns> <my:GridColumn FieldName="JobName" Name="grdColumnJobName" /> <my:GridColumn FieldName="JobDate" Name="grdColumnJobDate" /> </my:GridControl.Columns> <my:GridControl.View> <my:TableView NavigationStyle="Row" ShowAutoFilterRow="True" ShowGroupPanel="False" MultiSelectMode="Row" Name="JobTableView" AllowEditing="False" Focusable="False"> <dxg:TableView.DataRowTemplate>

Categories : C#

linq count error: DbExpressionBinding requires an input expression with a collection ResultType. Parameter name: input
you should use 'by new' after 'group'. I hope this will help you. var entries = from entry in _db.Entries group entry by new { entry.Name } into groupedByName select new { groupedByName.Key.Name, NumberOfComments = groupedByName.Count(x => x.Name != null) };

Categories : Linq

Query gives error: String was not recognized as a valid Boolean
The type mismatch might actually be between other fields (ie: other than the ProjectID) in the database and your Project class? Make sure that all your properties and datatypes in your Project class correctly coincide with the Project database table fields. There might be an accidental mismatch eg: a boolean field in your Project class may be marked as a varchar field in the database or vice versa.

Categories : C#

InvalidArgument=Value of '1' is not valid for 'index'. Error with server compact sql 4.0
You can not use * with where condition in delete command ..so TRY like this.... SqlCeCommand cm = new SqlCeCommand("DELETE FROM Emails WHERE query ='" + listView1.SelectedItems[0].Text + "'", conn);

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.