Search Results

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

Page 15/216 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Checking data of all same class elements

    - by Tiffani
    I need the code to check the data-name value of all instances of .account-select. Right now it just checks the first .account-select element and not any subsequent ones. The function right now is on click of an element such as John Smith, it checks the data-name of the .account-select lis. If the data-names are the same, it does not create a new li with the John Smith data. If no data-names are equal to John Smith, then it adds an li with John Smith. This is the JS-Fiddle I made for it so you can see what I am referring to: http://jsfiddle.net/rsxavior/vDCNy/22/ Any help would be greatly appreciated. This is the Jquery Code I am using right now. $('.account').click(function () { var acc = $(this).data("name"); var sel = $('.account-select').data("name"); if (acc === sel) { } else { $('.account-hidden-li').append('<li class="account-select" data-name="'+ $(this).data("name") +'">' + $(this).data("name") + '<a class="close bcn-close" data-dismiss="alert" href="#">&times;</a></li>'); } }); And the HTML: <ul> <li><a class="account" data-name="All" href="#">All</a></li> <li><a class="account" data-name="John Smith" href="#">John Smith</a></li> </ul> <ul class="account-hidden-li"> <ul>

    Read the article

  • C++ type-checking at compile-time

    - by Masterofpsi
    Hi, all. I'm pretty new to C++, and I'm writing a small library (mostly for my own projects) in C++. In the process of designing a type hierarchy, I've run into the problem of defining the assignment operator. I've taken the basic approach that was eventually reached in this article, which is that for every class MyClass in a hierarchy derived from a class Base you define two assignment operators like so: class MyClass: public Base { public: MyClass& operator =(MyClass const& rhs); virtual MyClass& operator =(Base const& rhs); }; // automatically gets defined, so we make it call the virtual function below MyClass& MyClass::operator =(MyClass const& rhs); { return (*this = static_cast<Base const&>(rhs)); } MyClass& MyClass::operator =(Base const& rhs); { assert(typeid(rhs) == typeid(*this)); // assigning to different types is a logical error MyClass const& casted_rhs = dynamic_cast<MyClass const&>(rhs); try { // allocate new variables Base::operator =(rhs); } catch(...) { // delete the allocated variables throw; } // assign to member variables } The part I'm concerned with is the assertion for type equality. Since I'm writing a library, where assertions will presumably be compiled out of the final result, this has led me to go with a scheme that looks more like this: class MyClass: public Base { public: operator =(MyClass const& rhs); // etc virtual inline MyClass& operator =(Base const& rhs) { assert(typeid(rhs) == typeid(*this)); return this->set(static_cast<Base const&>(rhs)); } private: MyClass& set(Base const& rhs); // same basic thing }; But I've been wondering if I could check the types at compile-time. I looked into Boost.TypeTraits, and I came close by doing BOOST_MPL_ASSERT((boost::is_same<BOOST_TYPEOF(*this), BOOST_TYPEOF(rhs)>));, but since rhs is declared as a reference to the parent class and not the derived class, it choked. Now that I think about it, my reasoning seems silly -- I was hoping that since the function was inline, it would be able to check the actual parameters themselves, but of course the preprocessor always gets run before the compiler. But I was wondering if anyone knew of any other way I could enforce this kind of check at compile-time.

    Read the article

  • Zend_Form MultiCheckbox not checking boxes

    - by azz0r
    $groups = Model_UserGroup::load_links($object->id); foreach ($groups as $item) { $object->group[$item->group_id] = $item->enabled; } $array_object = (array) $object;//turn the object to an array so zend_form can use it $form->populate($array_object); enabled = 1 or 0 In the form class: $group = new Zend_Form_Element_MultiCheckbox('group'); $groups = Model_Group::load_all(); $new_item = array(); foreach ($groups as $item) { $group->addMultiOption($item->id, $item->name); } However the top group is the only one ever checked. Anyone spot anything glaringly wrong? I know its difficult to get a grasp of my layout/setup for this. Here is the array_object: Array ( [table_name] => User [id] => 112 [updated] => 1269428783 [created] => 1153237813 [group] => Array ( [1] => 1 [3] => 1 ) ) Here is the html zend_form is creating: <dd id="group-element"> <label for="group-1"><input name="group[]" id="group-1" value="1" checked="checked" type="checkbox">Administrator Access</label><br> <label for="group-2"><input name="group[]" id="group-2" value="2" type="checkbox">Content Admin</label><br> <label for="group-3"><input name="group[]" id="group-3" value="3" type="checkbox">Administrator</label><br> <label for="group-4"><input name="group[]" id="group-4" value="4" type="checkbox">Studio</label> </dd> edit: just done a small test and made the $groups (in the first set of code tags) empty and it still ticks the first box. hm Fixed this by doing: // $selected_groups = Model_UserGroup::load_links($object->id); $group_ticks = array(); foreach ($selected_groups as $item) { if ($item->enabled == 1) { $group_ticks[] = $item->group_id;//$form->group->setValue($item->group_id); } } $form->group->setValue($group_ticks); //

    Read the article

  • Checking inherited attributes in an 'ancestry' based SQL table

    - by Brendon Muir
    I'm using the ancestry gem to help organise my app's tree structure in the database. It basically writes a childs ancestor information to a special column called 'ancestry'. The ancestry column for a particular child might look like '1/34/87' where the parent of this child is 87, and then 87's parent is 34 and 34's is 1. It seems possible that we could select rows from this table each with a subquery that checks all the ancestors to see if a certain attribute it set. E.g. in my app you can hide an item and its children just by setting the parent element's visibility column to 0. I want to be able to find all the items where none of their ancestors are hidden. I tried converting the slashes to comma's with the REPLACE command but IN required a set of comma separated integers rather than one string with comma separated string numbers. It's funny, because I can do this query in two steps, e.g. retrieve the row, then take its ancestry column, split out the id's and make another query that checks that the id is IN that set of id's and that visibility isn't ever 0 and whala! But joining these into one query seems to be quite a task. Much searching has shown a few answers but none really do what I want. SELECT * FROM t1 WHERE id = 99; 99's ancestry column reads '1/34/87' SELECT * FROM t1 WHERE visibility = 0 AND id IN (1,34,87); kind of backwards, but if this returns no rows then the item is visible. Has anyone come across this before and come up with a solution. I don't really want to go the stored procedure route. It's for a rails app.

    Read the article

  • Correct algorith for checking leap year

    - by Debanjan
    What will be the exact definition of leap year ? AFAIK "A year which is divisible by 4 is a leap year.But for century years' the years which are divisible by 400 is a leap year." But that definition makes 100, 200, 300, 400.... upto 1700 NOT LEAP years! But in Gregorian calender all of them are all leap year,check this out. You can also try "call 1700" in Linux to verify. So the correct algorithm foe leap year would be if ( (year % 4 == 0) && ( year <= 1700 || year % 100 != 0 || year % 400 == 0 )) printf("%d is a leap year.\n", year); else printf("%d is not a leap year.\n", year); But is this specific to Gregorian calender ? Even if that is the case why is it not mentioned here ? Regards, PS:The history of Gregorian callender seems interesting check out the September month of 1752.

    Read the article

  • Why doesn't is operator take in consideration if the explicit operator is overriden when checking ty

    - by Galilyou
    Hey Guys, Consider this code sample: public class Human { public string Value { get; set;} } public class Car { public static explicit operator Human (Car c) { Human h = new Human(); h.Value = "Value from Car"; return h; } } public class Program { public static void Mani() { Car c = new Car(); Human h = (Human)c; Console.WriteLine("h.Value = {0}", h.Value); Console.WriteLine(c is Human); } } Up I provide a possibility of an explicit cast from Car to Human, though Car and Human hierarchically are not related! The above code simply means that "Car is convertible to human" However, if you run the snippet you will find the expression c is Human evaluates to false! I used to believe that the is operator is kinda expensive cause it attempts to do an actual cast that might result in an InvalidCastException. If the operator is trying to cast, then the cast should succeed as there's an operator logic that should perform the cast! What does "is" test? Does test a hierarchical "is-a" relationship? Does test whether a variable type is convertible to a type?

    Read the article

  • Checking for Value in JS Object

    - by pagewil
    I have a JS Object like so: var ob{ 1 : { id:101, name:'john', email:'[email protected]' }, 2 : { id:102, name:'jim', email:'[email protected]' }, 3 : { id:103, name:'bob', email:'[email protected]' }, } I want to check if this JS object already contains a record. If it doesn't then I want to add it. For example. if(ob contains an id of 101){ //don't add john }else{ //add john } Catch my drift? Pretty simple question. I just want to know the best way of doing it. Thanks Guys! W.

    Read the article

  • Checking if an int is prime more efficiently

    - by SipSop
    I recently was part of a small java programming competition at my school. My partner and I have just finished our first pure oop class and most of the questions were out of our league so we settled on this one (and I am paraphrasing somewhat): "given an input integer n return the next int that is prime and its reverse is also prime for example if n = 18 your program should print 31" because 31 and 13 are both prime. Your .class file would then have a test case of all the possible numbers from 1-2,000,000,000 passed to it and it had to return the correct answer within 10 seconds to be considered valid. We found a solution but with larger test cases it would take longer than 10 seconds. I am fairly certain there is a way to move the range of looping from n,..2,000,000,000 down as the likely hood of needing to loop that far when n is a low number is small, but either way we broke the loop when a number is prime under both conditions is found. At first we were looping from 2,..n no matter how large it was then i remembered the rule about only looping to the square root of n. Any suggestions on how to make my program more efficient? I have had no classes dealing with complexity analysis of algorithms. Here is our attempt. public class P3 { public static void main(String[] args){ long loop = 2000000000; long n = Integer.parseInt(args[0]); for(long i = n; i<loop; i++) { String s = i +""; String r = ""; for(int j = s.length()-1; j>=0; j--) r = r + s.charAt(j); if(prime(i) && prime(Long.parseLong(r))) { System.out.println(i); break; } } System.out.println("#"); } public static boolean prime(long p){ for(int i = 2; i<(int)Math.sqrt(p); i++) { if(p%i==0) return false; } return true; } } ps sorry if i did the formatting for code wrong this is my first time posting here. Also the output had to have a '#' after each line thats what the line after the loop is about Thanks for any help you guys offer!!!

    Read the article

  • Deep Null checking, is there a better way?

    - by Mattias Konradsson
    We've all been there, we have some deep property like cake.frosting.berries.loader that we need to check if it's null so there's no exception. The way to do is is to use a short-circuiting if statement if (cake != null && cake.frosting != null && cake.frosting.berries != null) ... This strikes me however as not very elegant, there should perhaps be an easier way to check the entire chain and see if it comes up against a null variable/property. So is it possible using some extension method or would it be a language feature, or is it just a bad idea?

    Read the article

  • Use continue or Checked Exceptions when checking and processing objects

    - by Johan Pelgrim
    I'm processing, let's say a list of "Document" objects. Before I record the processing of the document successful I first want to check a couple of things. Let's say, the file referring to the document should be present and something in the document should be present. Just two simple checks for the example but think about 8 more checks before I have successfully processed my document. What would have your preference? for (Document document : List<Document> documents) { if (!fileIsPresent(document)) { doSomethingWithThisResult("File is not present"); continue; } if (!isSomethingInTheDocumentPresent(document)) { doSomethingWithThisResult("Something is not in the document"); continue; } doSomethingWithTheSucces(); } Or for (Document document : List<Document> documents) { try { fileIsPresent(document); isSomethingInTheDocumentPresent(document); doSomethingWithTheSucces(); } catch (ProcessingException e) { doSomethingWithTheExceptionalCase(e.getMessage()); } } public boolean fileIsPresent(Document document) throws ProcessingException { ... throw new ProcessingException("File is not present"); } public boolean isSomethingInTheDocumentPresent(Document document) throws ProcessingException { ... throw new ProcessingException("Something is not in the document"); } What is more readable. What is best? Is there even a better approach of doing this (maybe using a design pattern of some sort)? As far as readability goes my preference currently is the Exception variant... What is yours?

    Read the article

  • Checking if a blob exists in Azure Storage

    - by John
    Hi, I've got a very simple question (I hope!) - I just want to find out if a blob (with a name I've defined) exists in a particular container. I'll be downloading it if it does exist, and if it doesn't then I'll do something else. I've done some searching on the intertubes and apparently there used to be a function called DoesExist or something similar... but as with so many of the Azure APIs, this no longer seems to be there (or if it is, has a very cleverly disguised name). Or maybe I'm missing something simple... :) John

    Read the article

  • Checking for empty arrays: count vs empty

    - by Dan McG
    This question on 'How to tell if a PHP array is empty' had me thinking of this question Is there a reason that count should be used instead of empty when determining if an array is empty or not? My personal thought would be if the 2 are equivalent for the case of empty arrays you should use empty because it gives a boolean answer to a boolean question. From the question linked above, it seems that count($var) == 0 is the popular method. To me, while technically correct, makes no sense. E.g. Q: $var, are you empty? A: 7. Hmmm... Is there a reason I should use count == 0 instead or just a matter of personal taste? As pointed out by others in comments for a now deleted answer, count will have performance impacts for large arrays because it will have to count all elements, whereas empty can stop as soon as it knows it isn't empty. So, if they give the same results in this case, but count is potentially inefficient, why would we ever use count($var) == 0?

    Read the article

  • Checking COM Port Availability in C#

    - by Jim Fell
    Hello. My C# application populates a comboBox with the COM ports found on the system. I would like the mark the COM ports that are in use as such. I know that I can use try / catch blocks to attempt to open every COM port, but I was wondering if there is a more graceful way to do this. Perhaps using a WMI query? I am using Microsoft Visual C# 2008 Express Edition (.NET 2.0). Any thoughts or suggestions you may have would be appreciated. Thanks.

    Read the article

  • Enforce strong type checking in C (type strictness for typedefs)

    - by quinmars
    Is there a way to enforce explicit cast for typedefs of the same type? I've to deal with utf8 and sometimes I get confused with the indices for the character count and the byte count. So it be nice to have some typedefs: typedef unsigned int char_idx_t; typedef unsigned int byte_idx_t; With the addition that you need an explicit cast between them: char_idx_t a = 0; byte_idx_t b; b = a; // compile warning b = (byte_idx_t) a; // ok I know that such a feature doesn't exist in C, but maybe you know a trick or a compiler extension (preferable gcc) that does that. EDIT: I still don't really like the Hungarian notation in general, I couldn't used it for this problem because of project coding conventions, but I used it now in another similar case, where also the types are the same and the meanings are very similar. And I have to admit: it helps. I never would go and declare every integer with a starting "i", but as in Joel's example for overlapping types, it can be life saving.

    Read the article

  • Continuously checking database from a Windows service

    - by JonF
    I am making a Windows service which needs to continuously check for database entries that can be added at any time to tell it to execute some code. It is looking to see if it's status is set to pending, and it's execute time entry is than the current time. Is the only way to do this to just run select statements over and over? It might need to execute the code every minute which means I need to run the select statement every minute looking for entries in the database. I'm trying to avoid unneccesary cpu time because I'm probably going to end up paying for cpu cycles on the hosting provider

    Read the article

  • Checking For Word Wrap In Table Column

    - by Sparafusile
    I'm writing part of a web page that allows a user to build a table and fill it with information. In the course of building the table, the user will be adding additional columns with headers. I'd like to code it so when the combined width of all the headers causes one of them to wrap that the table columns switch to using vertical text (writing-mode: tb-rl). Is there any way, using JavaScript, to determine if the contents of a specific cell have wrapped? Thanks, Spara

    Read the article

  • JUnit: checking if a void method gets called

    - by nkr1pt
    I have a very simple filewatcher class which checks every 2 seconds if a file has changed and if so, the onChange method (void) is called. Is there an easy way to check ik the onChange method is getting called in a unit test? code: public class PropertyFileWatcher extends TimerTask { private long timeStamp; private File file; public PropertyFileWatcher(File file) { this.file = file; this.timeStamp = file.lastModified(); } public final void run() { long timeStamp = file.lastModified(); if (this.timeStamp != timeStamp) { this.timeStamp = timeStamp; onChange(file); } } protected void onChange(File file) { System.out.println("Property file has changed"); } } @Test public void testPropertyFileWatcher() throws Exception { File file = new File("testfile"); file.createNewFile(); PropertyFileWatcher propertyFileWatcher = new PropertyFileWatcher(file); Timer timer = new Timer(); timer.schedule(propertyFileWatcher, 2000); FileWriter fw = new FileWriter(file); fw.write("blah"); fw.close(); Thread.sleep(8000); // check if propertyFileWatcher.onChange was called file.delete(); }

    Read the article

  • checking and replacing a value in an array jquery

    - by liz
    i have a table of data: <table id="disparities" class="datatable"> <thead> <tr> <th scope="col">Events</th> <th scope="col">White</th> <th scope="col">Black</th> <th scope="col">Hispanic</th><th scope="col">Asian/Pacific Islands</th> </tr> </thead> <tbody> <tr> <th scope="row">Hospitalizations</th> <td>0.00</td> <td>20</td> <td>10</td> <td>5</td> </tr> <tr> <th scope="row">ED Visits</th> <td>19</td> <td>90</td> <td>40</td> <td>18</td> </tr> </tbody> </table> i have a function that retrieves the values from the above table into an array like so (0.00,19) var points1 = $('#disparities td:nth-child(2)').map(function() { return $(this).text().match(/\S+/)[0]; }).get(); i want to check if there is a 0.00 value (or it could be just 0) and change that value to NA... so my resulting array is then (NA,19) not really sure how to go about this, whether in the initial match or as a separate action...

    Read the article

  • Checking for a variable in the executable

    - by rboorgapally
    Is there a way to know whether a variable is defined, by looking at the executable. Lets say I declare int i; in the main function. By compiling and linking I get an executable my_program.exe. Now, by looking inside my_program.exe, can I say if it has an int eger variable i ?

    Read the article

  • checking player prefs from unity in xcode

    - by user313100
    I made a simple scene that has some GUI buttons in Unity. When you press a button it will set a player preference to 1. I have a button for facebook, twitter and a store. In XCode, when the value hits 1, it switches to a new window with facebook, twitter or the store. My problem is that when I try and retrieve the player preferences in XCode, they always come up as null. To compound my confusion, my code seems to respond to the switch to 1 and it switches to the new window when the value hits 1. Any ideas why it manages to switch to the other window and why I am getting null values? - (void) applicationDidFinishLaunching:(UIApplication*)application { printf_console("-> applicationDidFinishLaunching()\n"); NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; [userDefaults setInteger:0 forKey:@"Store"]; [userDefaults setInteger:0 forKey:@"Facebook"]; [userDefaults setInteger:0 forKey:@"Twitter"]; _storeWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; _facebookWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; _twitterWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; viewControllerSK = [[SKViewController alloc]initWithNibName:@"SKViewController" bundle:nil]; viewControllerFacebook = [[xutils_exampleViewController alloc]initWithNibName:@"FacebookViewController" bundle:nil]; viewControllerTwitter = [[xutils_exampleViewController2 alloc]initWithNibName:@"TwitterViewController" bundle:nil]; [_storeWindow addSubview:viewControllerSK.view]; [_facebookWindow addSubview:viewControllerFacebook.view]; [_twitterWindow addSubview:viewControllerTwitter.view]; [SKStoreManager sharedManager]; [self startUnity:application]; } - (void) applicationDidBecomeActive:(UIApplication*)application { printf_console("-> applicationDidBecomeActive()\n"); if (gDidResignActive == true) { UnitySetAudioSessionActive(true); UnityPause(false); } gDidResignActive = false; [self newTimer]; } - (void) applicationWillResignActive:(UIApplication*)application { printf_console("-> applicationDidResignActive()\n"); UnitySetAudioSessionActive(false); UnityPause(true); gDidResignActive = true; } - (void) applicationDidReceiveMemoryWarning:(UIApplication*)application { printf_console("WARNING -> applicationDidReceiveMemoryWarning()\n"); } - (void) applicationWillTerminate:(UIApplication*)application { printf_console("-> applicationWillTerminate()\n"); UnityCleanup(); } -(void)newTimer { NSTimer *theTimer = [self getTimer]; [theTimer retain]; [[NSRunLoop currentRunLoop] addTimer: theTimer forMode: NSDefaultRunLoopMode]; } -(NSTimer *)getTimer { NSTimer *theTimer; theTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector: @selector(onLoop) userInfo:nil repeats:YES]; return [theTimer autorelease]; } -(void)onLoop { NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; //NSLog(@"FB: %@", [userDefaults integerForKey:@"Facebook"]); if ([userDefaults integerForKey:@"Store"] != 1 && [userDefaults integerForKey:@"Facebook"] != 1 && [userDefaults integerForKey:@"Twitter"] != 1) { UnityPause(FALSE); _window.hidden = NO; _storeWindow.hidden = YES; _facebookWindow.hidden = YES; _twitterWindow.hidden = YES; [_window makeKeyWindow]; } if ([userDefaults integerForKey:@"Store"] == 1) { UnityPause(TRUE); _storeWindow.hidden = NO; _window.hidden = YES; [_storeWindow makeKeyWindow]; } if ([userDefaults integerForKey:@"Facebook"] == 1) { UnityPause(TRUE); _facebookWindow.hidden = NO; _window.hidden = YES; [_facebookWindow makeKeyWindow]; } if ([userDefaults integerForKey:@"Twitter"] == 1) { UnityPause(TRUE); _twitterWindow.hidden = NO; _window.hidden = YES; [_twitterWindow makeKeyWindow]; } } -(void) dealloc { DestroySurface(&_surface); [_context release]; _context = nil; [_window release]; [_storeWindow release]; [_facebookWindow release]; [_twitterWindow release]; [viewControllerSK release]; [viewControllerFacebook release]; [viewControllerTwitter release]; [super dealloc]; }

    Read the article

  • Checking for Error during execution of a procedure in oracle

    - by Sumit Sharma
    create or replace procedure proc_advertisement(CustomerID in Number, NewspaperID in number, StaffID in Number, OrderDate in date, PublishDate in date, Type in varchar, Status in varchar, Units in number) is begin insert into PMS.Advertisement(CustomerID, NewspaperID, StaffID, OrderDate, PublishDate, Type, Status, Units) values(CustomerID,NewspaperID, StaffID, OrderDate, PublishDate, Type, Status, Units); dbms_output.put_line('Advertisement Order Placed Successfully'); end; How to check for if any error has occurred during the execution of the procedure and if any error has occurred then I wish to display an error message.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >