Search Results

Search found 5378 results on 216 pages for 'spell checking'.

Page 11/216 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Checking array of censored words against user submitted content

    - by steve-o
    Hello, I have set up an array of censored words and I want to check that a user submitted comment doesn't contain any of these words. What is the most efficient way of doing this? All I've come up with so far is splitting the string into an array of words and checking it against the array of censored words, but I've a feeling there's a neater way of doing this.

    Read the article

  • Java checking connection via socket continuously

    - by Onca
    I'm developing a multiclient-server program with Java based on GUI and database. The demand regarding the program from the client side is to make sure all the time that there is a connection to the server, and if the connection is lost (server goes down/problem with socket or stream) it should be notified. In other words I need a solution for continuously checking the connection to the server. What is the best way to do that ?

    Read the article

  • How can I improve my error checking and handling?

    - by Google
    Lately I have been struggling to understand what the right amount of checking is and what the proper methods are. I have a few questions regarding this: What is the proper way to check for errors (bad input, bad states, etc)? Is it better to explicitly check for errors, or use functions like asserts which can be optimized out of your final code? I feel like explicitly checking clutters a program with a lot of extra code which shouldn't be executed in most situations anyway-- and not to mention most errors end up with an abort/exit failure. Why clutter a function with explicit checks just to abort? I have looked for asserts versus explicit checking of errors and found little to truly explain when to do either. Most say 'use asserts to check for logic errors and use explicit checks to check for other failures.' This doesn't seem to get us very far though. Would we say this is feasible: Malloc returning null, check explictly API user inserting odd input for functions, use asserts Would this make me any better at error checking? What else can I do? I really want to improve and write better, 'professional' code.

    Read the article

  • Ruby syntax checking in vim

    - by roybotnik
    Hi everyone, I use vim with various plugins for editing ruby code. I have proper syntax highlighting set up but I was wondering if anyone knew of a way to get ruby syntax checking, similar to what you might see in an IDE such as visual studio, radrails, etc? Something that would simply turn stuff red or break highlighting when I'm missing an 'end' or have an improperly constructed line of code would be sweet. I googled and came across this plugin, http://github.com/scrooloose/syntastic/tree/master but I was wondering if anyone had any better suggestions.

    Read the article

  • Checking if date parsing is correct

    - by Javi
    Hello, I have this code for checking whether the Date is OK or not, but it's not ckecking all the cases. For example when text="03/13/2009" as this date doesn't exist in the format "dd/MM/yyyy" it parses the date as 03/01/2010. Is there any way to change this behaviour and getting an exception when I try to parse a Date which is not correct? What's the best way to do this validation? public static final String DATE_PATTERN = "dd/MM/yyyy"; public static boolean isDate(String text){ SimpleDateFormat formatter = new SimpleDateFormat(DATE_PATTERN); ParsePosition position = new ParsePosition(0); formatter.parse(text, position); if(position.getIndex() != text.length()){ return false; }else{ return true; } } Thanks.

    Read the article

  • Checking for a valid and in-use email address in PHP

    - by espais
    I'm not sure if this is exactly possible, but figured I'd throw it out there. I have a client that is getting some hate-mail from somebody he knows via a contact form on a website that I developed for him. Currently I do the normal checks for a validly-formatted email address, along with a Captcha, but the client has requested that a user enter his/her own email address in the form. Now I realize that something like this could be easily spoofed by setting up a fake Yahoo account, etc, but the client's thinking is that this person is not quite that computer-literate. Is there any possibility for checking if an email address is valid and in-use? The only other things I can think of is turning his contact form into a mailto: link.

    Read the article

  • checking crc32 of a file

    - by agent154
    This is not really a "how to" question. Is there a "standard" file structure that applications use to store the checksums of files in a folder? I'm developing a tool to check various things like crc32, md5, sha1, sha256, etc... I'd like to have my program store the various hashes in files in the folder of what I'm checking. I know that there is a file commonly used called 'md5sums' or 'sha1sums'. But what about CRC? I haven't noticed any around. And if there is, what's the structure of it? Thanks.

    Read the article

  • Condition checking vs. Exception handling

    - by Aidas Bendoraitis
    When is exception handling more preferable than condition checking? There are many situations where I can choose using one or the other. For example, this is a summing function which uses a custom exception: # module mylibrary class WrongSummand(Exception): pass def sum_(a, b): """ returns the sum of two summands of the same type """ if type(a) != type(b): raise WrongSummand("given arguments are not of the same type") return a + b # module application using mylibrary from mylibrary import sum_, WrongSummand try: print sum_("A", 5) except WrongSummand: print "wrong arguments" And this is the same function, which avoids using exceptions # module mylibrary def sum_(a, b): """ returns the sum of two summands if they are both of the same type """ if type(a) == type(b): return a + b # module application using mylibrary from mylibrary import sum_ c = sum_("A", 5) if c is not None: print c else: print "wrong arguments" I think that using conditions is always more readable and manageable. Or am I wrong? What are the proper cases for defining APIs which raise exceptions and why?

    Read the article

  • checking boolean property in XML(Spring)

    - by Abhishek Bhandari
    I am using Spring Framework . While writing coustum SQL queries , i am unable check a parameter of boolean value. For example this is not working .. do some SQl cods The above checking is not working , it is evaluating as equal in both the cases when booleanVariable is true and false . i tried to replace compareValue ="tree" and "false". As that is a monkey work i do sometimes . is it possible to check the boolean property in XML like above .

    Read the article

  • Nested for loop error with !null checking an element that doesn't exist

    - by Programatt
    I am currently using nested for loops in a 2D array of size 4,2. When I run my program, I get index out of bounds Exception on the following line else if (state[i][j+1] != null && state[i][j].getFlash() <= state[i][j].getCycleLength() && state[i][j+1].getCycleLength() == state[i][j].getCycleLength()){ } It says the index out of bounds is 2. I would understand the error if I wasn't checking to see if [i][j+1] wasn't null, but I don't understand the exception with the check? I tried moving around the !null check but the program still fails on this line. Any help would be greatly appreciated. Stack trace: Exception in thread "Timer-0" java.lang.ArrayIndexOutOfBoundsException: 2 at NatComp.data$1.run(data.java:67) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462)

    Read the article

  • No-argument method on window.external is invoked when checking with typeof

    - by janko
    Hi, I am trying to display an HTML page with embedded JavaScript code inside a System.Windows.Forms.WebBrowser control. The JavaScript code is expected to interact with the embedding environment through the window.external object. Before invoking a method on window.external, JavaScript is supposed to check for the existance of the method. If it is not there, the code should invoke a generic fallback method. // basic idea if (typeof(window.external.MyMethod) != 'undefined') { window.external.MyMethod(args); } else { window.external.Generic("MyMethod", args); } However, checking for a no-argument method with typeof seems to invoke the method already. That is, if MyMethod accepts any positive number of arguments, the code above will work perfectly; but, if MyMethod is a no-argument method, then the expression typeof(window.external.MyMethod) will not check for its type but invoke it, too. Is there any work-around to this behavior? Can I somehow escape the expression window.external.MyMethod to prevent the method call from occurring?

    Read the article

  • LINQ to Entites: How should I handle System.InvalidOperationException when checking for existance of

    - by chris
    I have a many-to-one relationship that users can edit via checkboxes. PK of Foo is ID, and fid contains the id from the checkbox. I'm checking to see if an element exists with: Foo ent; try { ent = ctx.Foo.First(f => f.ID == fid); } catch (System.InvalidOperationException ioe) { ent = new Foo(); } It seems to me that I should be able to do this without throwing an exception. What would be the best way to do this?

    Read the article

  • Entity Framework .Include() with compile time checking?

    - by Mikey Cee
    Consider the following code, which is calling against an EF generated data context: var context = new DataContext(); var employees = context.Employees.Include("Department"); If I change the name of the entity Department then this code is going to start throwing a runtime error. So I'll have to do some kind of find and replace throughout my code to replace each occurrence of "Department". Is there any way to call the .Include() method in a safe manner, so I get compile time checking for all the entity names being referenced?

    Read the article

  • How to use the boost lexical_cast library for just for checking input

    - by Inverse
    I use the boost lexical_cast library for parsing text data into numeric values quite often. In several situations however, I only need to check if values are numeric; I don't actually need or use the conversion. So, I was thinking about writing a simple function to test if a string is a double: template<typename T> bool is_double(const T& s) { try { boost::lexical_cast<double>(s); return true; } catch (...) { return false; } } My question is, are there any optimizing compilers that would drop out the lexical_cast here since I never actually use the value? Is there a better technique to use the lexical_cast library to perform input checking?

    Read the article

  • Import files directly to SVN repo without checking out first

    - by Werner
    Hi, I am using SVN and have a repository on a remote machine. Sometimes, when working on my local machine I realize that I need to add some new files to the repo. The usual procedure I know would then be: 1- at the current folder on my local machine checkout the whole SVN repo 2- enter there 3- copy the interesting file here 4- commit But this can be a bit tedious. I wonder if somehow, I can omit steps 1 to 3 and import the "interesting" file to SVN directly without necessity of checking out the repo first. Thanks

    Read the article

  • Why is checking in files called a 'commit'?

    - by Kjetil Klaussen
    The act of checking in files in a source control repository like git, mercurial or svn, is called a commit. Does anyone know the reason behind calling it a commit instead of just check in? English is not my mother tongue, so it might be some linguistic I don't quite get her, but what I'm I actually commiting to? (Hopefully I'm not commiting a crime, but you'll never know.) Is it in the meaning of "to consign for preservation"? Is it related to transactions (commit at the end of a transaction)?

    Read the article

  • Syntax problem when checking for a file

    - by Luke
    This piece of code has previously worked but I have C&P it to a new place and for some reason, it now won't work! <? $user_image = '/images/users/' . $_SESSION['id'] . 'a.jpg'; if (file_exists(realpath(dirname(__FILE__) . $user_image))) { echo '<img src="'.$user_image.'" alt="" />'; } else { echo '<img src="/images/users/small.jpg" alt="" />'; } ?> As you can see, I am checking for a file, if exists, showing it, if not, showing a placeholder. The $_SESSION['id'] variable does exist and is being used elsewhere within the script. Any ideas what the problem is? Thanks

    Read the article

  • Oracle checking existence before deletion in a trigger

    I have analyzed a hibernate generated oracle database and discovered that a delete of a row from a single table will spawn the firing of 1200+ triggers in order to delete the related rows in child tables. The triggers are all auto-generated the same - an automatic delete of a child row without checking for existence first. As it is impossible to predict which child tables will actually have related rows, I think a viable solution to preventing the firing of the cascaded delete down a deeply branched completely empty limb, would be to check for the existence of a related row before attempting to delete. In other dbms', I could simply state " if exists....." before deleting. Is there a comparable way to do this in oracle?

    Read the article

  • Issuew while checking in in TFS client explorer 2005

    - by Mini
    We have recently installed Team Explorer client for 2005 and TFS server 2008.. We have been using VS2005 and VSS earlier. To connect to TFS server 2008 we have installed a hotfix VS80sp1-KB932544-X86-ENU.exe. Everything has been setup well. However I noticed that when the files are checked out and u make some modifications , during checking in resolve confict dialog box asking to merge changes done by others isn't appearing. Instead the file is getting checked in overwriting the changes done by others. Is there some setting that needs to be done on TFS server 2008? Kindly help.

    Read the article

  • Fast string suffix checking in C# (.NET 4.0)?

    - by ilitirit
    What is the fastest method of checking string suffixes in C#? I need to check each string in a large list (anywhere from 5000 to 100000 items) for a particular term. The term is guaranteed never to be embedded within the string. In other words, if the string contains the term, it will be at the end of the string. The string is also guaranteed to be longer than the suffix. Cultural information is not important. These are how different methods performed against 100000 strings (half of them have the suffix): 1. Substring Comparison - 13.60ms 2. String.Contains - 22.33ms 3. CompareInfo.IsSuffix - 24.60ms 4. String.EndsWith - 29.08ms 5. String.LastIndexOf - 30.68ms These are average times. [Edit] Forgot to mention that the strings also get put into separate lists, but this is not important. It does add to the running time though. On my system substring comparison (extracting the end of the string using the String.Substring method and comparing it to the suffix term) is consistently the fastest when tested against 100000 strings. The problem with using substring comparison though is that Garbage Collection can slow it down considerably (more than the other methods) because String.Substring creates new strings. The effect is not as bad in .NET 4.0 as it was in 3.5 and below, but it is still noticeable. In my tests, String.Substring performed consistently slower on sets of 12000-13000 strings. This will obviously differ between systems and implementations. [EDIT] Benchmark code: http://pastebin.com/smEtYNYN

    Read the article

  • use of assertions for type checking in php?

    - by user151841
    I do some checking of arguments in my classes in php using exception-throwing functions. I have functions that do a basic check ( ===, in_array etc ) and throw an exception on false. So I can do assertNumeric($argument, "\$argument is not numeric."); instead of if ( ! is_numeric($argument) ) { throw new Exception("\$argument is not numeric."); } Saves some typing I was reading in the comments of the php manual page on assert() that As noted on Wikipedia - "assertions are primarily a development tool, they are often disabled when a program is released to the public." and "Assertions should be used to document logically impossible situations and discover programming errors— if the 'impossible' occurs, then something fundamental is clearly wrong. This is distinct from error handling: most error conditions are possible, although some may be extremely unlikely to occur in practice. Using assertions as a general-purpose error handling mechanism is usually unwise: assertions do not allow for graceful recovery from errors, and an assertion failure will often halt the program's execution abruptly. Assertions also do not display a user-friendly error message." This means that the advice given by "gk at proliberty dot com" to force assertions to be enabled, even when they have been disabled manually, goes against best practices of only using them as a development tool So, am I 'doing it wrong'? What other/better ways of doing this are there?

    Read the article

  • Launch ClickOnce via URL but not checking for updates

    - by Jeff Kotula
    I have a ClickOnce app that is frequently launched from another application via a URL. The URL includes some command-line arguments that load data, etc. Since the frequency of launching the app is so high, I want to cut out the check for version updates. So I implemented my own checking through the ApplicationDeployment class to avoid it. It works fine if you launch from the Start Menu once the app is installed. However, we also want to preserve the launch via URL behavior because it is advantageous in so many ways. But when launching via URL, the update check is always performed -- it seems IE isn't smart enough to look for the app in the local download area to see if it is already installed or not... Does anyone know of a way to get the "don't check for updates automatically" behavior while still using the URL launch mechanism? Actually, it looks like the issue is a Catch-22 in the ClickOnce model. If you launch with a URL, IE will always touch base with the host and check the version, updating if necessary, regardless of whether or not the app is flagged as "Don't check version". However, if you launch from the Start Menu, ClickOnce disables command-line arguments. Has anyone found any way around this, or know of a MS plan to fix it?

    Read the article

  • Checking for valid email addresses

    - by Roland
    I'm running a website with more than 60 000 registered users. Every week notifications are send to these users via email, now I've noticed some of the mail addresses do not exists anymore eg. the domain address is valid but the email name en asdas@ is not valid anymore since person does not work at a company anymore etc. Now I'm looping through the database and doing some regular expression checks and checking if the MX records exist with the following two functions function verify_email($email){ if(!preg_match('/^[_A-z0-9-]+((\.|\+)[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,4})$/',$email)){ return false; } else { return true; } } // Our function to verify the MX records function verify_email_dns($email){ list($name, $domain) = split('@',$email); if(!checkdnsrr($domain,'MX')){ return false; } else { return true; } } If the email address is in an invalid format or the domain does not exists I delete the users account. Are there any methods I could use to check if the email address still exists or not if the domain name is valid and the email address is in the correct format? For example [email protected] does not exist anymore but test.com is a valid domain name.

    Read the article

  • Checking multiple conditions in Ruby (within Rails, which may not matter)

    - by Ev
    Hello rubyists and railers, I have a method which checks over a params hash to make sure that it contains certain keys, and to make sure that certain values are set within a certain range. This is for an action that responds to a POST query by an iPhone app. Anyway, this method is checking for about 10 different conditions - any of which will result in an HTTP error being returned (I'm still considering this, but possibly a 400: bad request error). My current syntax is basically this (paraphrased): def invalid_submission_params?(params) [check one] or [check two] or [check three] or [check four] etc etc end Where each of the check statements returns true if that particular parameter check results in an invalid parameter set. I call it as a before filter with params[:submission] as the argument. This seems a little ugly (all the strung together or statements). Is there a better way? I have tried using case but can't see a way to make it more elegant. Or, perhaps, is there a rails method that lets me check the incoming params hash for certain conditions before handing control off to my action method?

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >