Search Results

Search found 834 results on 34 pages for 'looping'.

Page 4/34 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Is looping through the entityreference the correct way?

    - by Jova
    I want to get all users that have a specific role to a list of usernames. Is using .Include to include all the users, and going through the UsersReference the best way to loop through all the users that are associated with the role? I noticed I could not do a foreach(User user in role.Users) but UsersReference seem to work, but is that how it's supposed to be done? Going through the reference? using (var context = new MyEntities()) { List<string> users = new List<string>(); Role role = (from r in context.Roles.Include("Users") where r.RoleName == roleName select r).FirstOrDefault(); foreach (User user in role.UsersReference) users.Add(user.UserName); return users.ToArray(); }

    Read the article

  • Php - Looping For Different CSS

    - by bob
    MySQL $selectSize = "SELECT * FROM products"; $querySize = $db->select($selectSize); while ($product = $db->fetcharray($querySize)) { HTML <ul> <li>Product A</li> <li>Product B</li> <li class='right'>Product C</li> <li>Product D</li> <li>Product E</li> <li class='right'>Product F</li> </ul> Question While getting the product, I want the Product C and Product F or any product after 3 loops will have class='right' to the list style. Let me know Thanks

    Read the article

  • Looping trough feed entries with rome

    - by Gandalf StormCrow
    I'm trying to loop trough Atom feed entries, and get the title attribute lets say, I found this article, I tried this snipped of code : for (final Iterator iter = feeds.getEntries.iterator(); iter.hasNext(); ) { element = (Element)iter.next(); key = element.getAttributeValue("href"); if ((key != null) && (key.length() > 0)) { marks.put(key, key); } } But I get exception saying : java.lang.ClassCastException: com.sun.syndication.feed.synd.SyndEntryImpl cannot be cast to org.jdom.Element at com.emir.altantbh.FeedReader.main(FeedReader.java:47) What did I do wrong? can anyone direct me towards better tutorial or show me where did I make mistake, I need to loop trough entries and extract title tag value. thank you

    Read the article

  • Problem with looping a video in Flash

    - by Blaze
    I am trying to loop a video and i am having some issues with this in flash. You can view the video here: http://www.healthcarepros.net/travel.html Here the specific code for the flash video: <script language="javascript"> if (AC_FL_RunContent == 0) { alert("This page requires AC_RunActiveContent.js."); } else { AC_FL_RunContent( 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0', 'width', '330', 'height', '245', 'src', 'healthcare-video', 'quality', 'high', 'pluginspage', 'http://www.macromedia.com/go/getflashplayer', 'align', 'middle', 'play', 'true', 'loop', 'true', 'scale', 'showall', 'wmode', 'window', 'devicefont', 'false', 'id', 'healthcare-video', 'bgcolor', '#ffffff', 'name', 'healthcare-video', 'menu', 'true', 'allowFullScreen', 'false', 'allowScriptAccess','sameDomain', 'movie', 'healthcare-video', 'salign', '' ); //end AC code } </script> <noscript> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="330" height="245" id="healthcare-video" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="false" /> <param name="loop" value="true" /> <param name="play" value="true" /> <param name="movie" value="healthcare-video.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="healthcare-video.swf" play="true" flashvars="autoplay=true&play=true" quality="high" bgcolor="#ffffff" width="330" height="245" name="healthcare-video" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> Additionally, i have added in the parameter code that calls the loop function but for some reason it still doesnt seem to work, any suggestions?

    Read the article

  • Noob Question: Wordpress Looping

    - by dclowd9901
    Can someone give me an essential Wordpress Loop and explain to me what's happening with it? I'd like to put together some templates, but I don't do well with blackboxing. In other words, I'm fully capable of writing my own CMS, but when it comes to using someone else's and its arbitrary rules, I'm completely at a loss, and I just can't get my head around the standard loop Wordpress uses. Thanks for your patient guidance.

    Read the article

  • Better way of looping to detect change.

    - by Dremation
    As of now I'm using a while(true) method to detect changes in memory. The problem with this is it's kill the applications performance. I have a list of 30 pointers that need checked as rapidly as possible for changes, without sacrificing a huge performance loss. Anyone have ideas on this? memScan = new Thread(ScanMem); public static void ScanMem() { int i = addy.Length; while (true) { Thread.Sleep(30000); //I do this to cut down on cpu usage for (int j = 0; j < i; j++) { string[] values = addy[j].Split(new char[] { Convert.ToChar(",") }); //MessageBox.Show(values[2]); try { if (Memory.Scanner.getIntFromMem(hwnd, (IntPtr)Convert.ToInt32(values[0], 16), 32).ToString() != values[1].ToString()) { //Ok, it changed lets do our work //work if (Globals.Working) return; SomeFunction("Results: " + values[2].ToString(), "Memory"); Globals.Working = true; }//end if }//end try catch { } }//end for }//end while }//end void

    Read the article

  • Looping login with Facebook JS SDK and Rails

    - by nafe
    I'm using the Facebook JS SDK for single-sign with my rails app. I translated the php code from the Facebook example (at the bottom of the page under "Single Sign-on with the JavaScript SDK") into ruby. This appeared to be working great but I've noticed one user that gets continual redirects when trying to login. The logs look like: Processing UsersController#login (for X.X.X.X at 2010-05-22 17:25:55) [GET] Redirected to http://myapp.com/ Completed in 0ms (DB: 0) | 302 Found [http://myapp.com/login] (times as many entries as my unfortunate user leaves the browser redirecting in a loop). My client side code includes a callback with the "auth.sessionChange": FB.Event.subscribe('auth.sessionChange', function(response) { if (response.session) { // A user has logged in, and a new cookie has been saved window.location = "/login"; } else { // The user has logged out, and the cookie has been cleared window.location = "/logout"; } }); So it seems to me like this event is continually firing. Although, I can't test this theory because I can't recreate this scenario locally. I don't think it's the rails controller. The code here is just: def login # if first time user create db entry # now redirect back to where the user came from begin redirect_to :back rescue ActionController::RedirectBackError redirect_to root_url end end Does anyone have any idea on what's going on?

    Read the article

  • Looping through list items with jquery

    - by Gallen
    I have this block of code listItems = $("#productList").find("li"); for (var li in listItems) { var product = $(li); var productid = product.children(".productId").val(); var productPrice = product.find(".productPrice").val(); var productMSRP = product.find(".productMSRP").val(); totalItemsHidden.val(parseInt(totalItemsHidden.val(), 10) + 1); subtotalHidden.val(parseFloat(subtotalHidden.val()) + parseFloat(productMSRP)); savingsHidden.val(parseFloat(savingsHidden.val()) + parseFloat(productMSRP - productPrice)); totalHidden.val(parseFloat(totalHidden.val()) + parseFloat(productPrice)); } and I'm not getting the desired results - totalItems is coming out as 180+ and the rest all NaN. I suspect its where i use var product = $(li); or perhaps with the expression on the loop itself. Either way - I need to loop through the <li> items in the <ul> labelled #productList

    Read the article

  • MS-Access nested DIR - check if a file exists elsewhere whilst looping through a folder

    - by David Carle
    I have used the DIR() command in Microsoft Access 2003 to loop through the files in folder A. This works fine, but I need to check if each file also exists in another location (folder B), and only process the file if it doesn't exist in folder B. The problem is that checking for the file existing in folder B also uses the DIR() function and this then resets or confuses the original one, with the result that no further files are found in folder A. Is there a way to check if a file exists without using DIR? Or, is there a way to have a separate instance of DIR? I suppose I could build a list of the files in folder A into an array and then process the entries in the array, but this seems rather 'clunky' Any suggestions for a better solution? Thanks

    Read the article

  • Performance of looping over an Unboxed array in Haskell

    - by Joey Adams
    First of all, it's great. However, I came across a situation where my benchmarks turned up weird results. I am new to Haskell, and this is first time I've gotten my hands dirty with mutable arrays and Monads. The code below is based on this example. I wrote a generic monadic for function that takes numbers and a step function rather than a range (like forM_ does). I compared using my generic for function (Loop A) against embedding an equivalent recursive function (Loop B). Having Loop A is noticeably faster than having Loop B. Weirder, having both Loop A and B together is faster than having Loop B by itself (but slightly slower than Loop A by itself). Some possible explanations I can think of for the discrepancies. Note that these are just guesses: Something I haven't learned yet about how Haskell extracts results from monadic functions. Loop B faults the array in a less cache efficient manner than Loop A. Why? I made a dumb mistake; Loop A and Loop B are actually different. Note that in all 3 cases of having either or both Loop A and Loop B, the program produces the same output. Here is the code. I tested it with ghc -O2 for.hs using GHC version 6.10.4 . import Control.Monad import Control.Monad.ST import Data.Array.IArray import Data.Array.MArray import Data.Array.ST import Data.Array.Unboxed for :: (Num a, Ord a, Monad m) => a -> a -> (a -> a) -> (a -> m b) -> m () for start end step f = loop start where loop i | i <= end = do f i loop (step i) | otherwise = return () primesToNA :: Int -> UArray Int Bool primesToNA n = runSTUArray $ do a <- newArray (2,n) True :: ST s (STUArray s Int Bool) let sr = floor . (sqrt::Double->Double) . fromIntegral $ n+1 -- Loop A for 4 n (+ 2) $ \j -> writeArray a j False -- Loop B let f i | i <= n = do writeArray a i False f (i+2) | otherwise = return () in f 4 forM_ [3,5..sr] $ \i -> do si <- readArray a i when si $ forM_ [i*i,i*i+i+i..n] $ \j -> writeArray a j False return a primesTo :: Int -> [Int] primesTo n = [i | (i,p) <- assocs . primesToNA $ n, p] main = print $ primesTo 30000000

    Read the article

  • XSLT-Looping and recursion based on parameter passed

    - by contactkx
    I have an XML organized like below- <section name="Parent 1 Text here" ID="1" > <section name="Child 1 Text here" ID="11"> </section> <section name="Child 2 Text here" ID="12"> <section name="GrandChild Text here" ID="121" > </section> </section> </section> <section name="Parent 2 Text here" ID="2" > <section name="Child 1 Text here" ID="22"> </section> <section name="Child 2 Text here" ID="23"> <section name="GrandChild Text here" ID="232" > </section> </section> </section> I have to produce the below output XML - <section name="Parent 1 Text here" ID="1" > <section name="Child 2 Text here" ID="12"> <section name="GrandChild Text here" ID="121" > </section> </section> </section> <section name="Parent 2 Text here" ID="2" > <section name="Child 2 Text here" ID="23"> </section> </section> I have to achive above using XSLT 1.0 transformation. I was planning to pass a comma separated string as a parameter with value= "1,12,121,2,23" My question- How to loop the comma separated parameter in XSLT 1.0 ? Is there a simpler way to achieve the above. Please remember I have to do this in XSLT 1.0 Your help is appreciated.

    Read the article

  • PHP While() Stop Looping

    - by Axel
    Hi, i have a php loop which displays only one record even if there is hundreds. here is the code: <?php $result1 = mysql_query("SELECT * FROM posts") or die(mysql_error()); $numexem = mysql_num_rows($result1); $s="0"; while($s<$numexem){ $postid=mysql_result($result1,$s,"id"); echo "Post id:".$postid; $result2 = mysql_query("SELECT * FROM pics WHERE postid='$postid'") or die(mysql_error()); $rows = mysql_fetch_array($result2) or die(mysql_error()); $pnum = mysql_num_rows($result2); echo " There is ".$pnum." Attached Pictures"; $s++; } ?> I'm wondering if the loop stop because there is other SQL query inside it or what? and i don't think so. Thanks

    Read the article

  • AJAX in Rails - doing simple looping to update information when available

    - by Acidburn2k
    I am trying to get put out a simple site, which would pool the database every few seconds and update the information on the page dynamicly, when theres something new inserted. I am farily new to ruby, but I understand the whole concept of RJS, link_to_function and soforth. The question is, what is the best way how to implement some kind of simple loop, which would run after the page is loaded and update the DOM if there is something new to display. Thanks in advance for any tips!

    Read the article

  • Why is this HTTP request continually looping?

    - by alex
    I'm probably overlooking something really obvious here. Comments are in to help explain any library specific code. public function areCookiesEnabled() { $random = 'cx67ds'; // set cookie cookie::set('test_cookie', $random); // try and get cookie, if not set to false $testCookie = cookie::get('test_cookie', false); $cookiesAppend = '?cookies=false'; // were we able to get the cookie equal ? $cookiesEnabled = ($testCookie === $random); // if $_GET['cookies'] === false , etc try and remove $_GET portion if ($this->input->get('cookies', false) === 'false' AND $cookiesEnabled) { url::redirect(str_replace($cookiesAppend, '', url::current())); // redirect return false; } // all else fails, add a $_GET[] if ( ! $cookiesEnabled) { url::redirect(url::current().$cookiesAppend); } return $cookiesEnabled; }

    Read the article

  • Looping an executable to get the result from Python script

    - by fx
    In my python script, I need to call within a for loop an executable, and waiting for that executable to write the result on the "output.xml". How do I manage to use wait() & how do I know when one of my executable is finished generating the result to get the result? How do I close that process and open a new one to call again the executable and wait for the new result? import subprocess args = ("bin/bar") popen = subprocess.Popen(args) I need to wait for the output from "bin/bar" to generate the "output.xml" and from there, read it's content. for index, result in enumerate(results): myModule.callSubProcess(index) #this is where the problem is. fileOutput = open("output.xml") parseAndStoreInSQLiteFileOutput(index, file)

    Read the article

  • Looping and recursion based on parameter passed

    - by contactkx
    I have an XML organized like below- <section name="Parent 1 Text here" ID="1" > <section name="Child 1 Text here" ID="11"> </section> <section name="Child 2 Text here" ID="12"> <section name="GrandChild Text here" ID="121" > </section> </section> </section> <section name="Parent 2 Text here" ID="2" > <section name="Child 1 Text here" ID="22"> </section> <section name="Child 2 Text here" ID="23"> <section name="GrandChild Text here" ID="232" > </section> </section> </section> I have to produce the below output XML - <section name="Parent 1 Text here" ID="1" > <section name="Child 2 Text here" ID="12"> <section name="GrandChild Text here" ID="121" > </section> </section> </section> <section name="Parent 2 Text here" ID="2" > <section name="Child 2 Text here" ID="23"> </section> </section> I have to achive above using XSLT 1.0 transformation. I was planning to pass a comma separated string as a parameter with value= "1,12,121,2,23" My question- How to loop the comma separated parameter in XSLT 1.0 ? Is there a simpler way to achieve the above. Please remember I have to do this in XSLT 1.0 Your help is appreciated.

    Read the article

  • jQuery event "looping"

    - by Deryck
    Hi I´m trying to code a tooltip (Yes I know, I have my reasons to avoid plugins in this case) in jQuery. Whe I show the tooltip and leave the mouse in the same place the show and hide repeats forever. It´s like the element triggers the hover event again and again and again. I try unbind for the event but it does not work neither. $("td.with-tooltip").mouseover( function() { var offset = $(this).offset(); var baseX = offset.left; var baseY = offset.top; var inputWidth = $(this).width(); var baseX = baseX + 50; var baseY = baseY - $(".desc").height(); $(".desc div").html($(this).attr("title")); $(".desc").css({"position":"absolute", "left": baseX, "top": baseY }).fadeIn(); $(this).unbind("mouseover"); }).mouseleave( function() { $(".desc").fadeOut(); }); What can I do? thanks.

    Read the article

  • iPhone - UIView Animation not looping correctly

    - by Robert
    Hey all, got a little problem here and can't figure out what I am doing wrong. I am trying to animate a UIView up and down repeatedly. When I start it, it goes down correctly and then back up but then immediately shoots to the "final" position of the animation. Code is as follows: UIImageView *guide = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]; guide.frame = CGRectMake(250, 80, 30, 30); [self.view addSubview:guide]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:2]; [UIView setAnimationRepeatAutoreverses:YES]; [UIView setAnimationBeginsFromCurrentState:YES]; guide.frame = CGRectMake(250, 300, 30, 30); [UIView setAnimationRepeatCount:10]; [UIView commitAnimations]; Thanks in advance!

    Read the article

  • Memory Leak Looping cfmodule inside cffunction

    - by orangepips
    Hoping someone else can confirm or tell me what I'm doing wrong. I am able to consistently reproduce an OOM running by calling the file oom.cfm (shown below). Using jconsole I am able to see the request consumes memory and never releases it until complete. The issue appears to be calling <cfmodule> inside of <cffunction>, where if I comment out the <cfmodule> call things are garbage collected while the request is running. ColdFusion version: 9,0,1,274733 JVM Arguments java.home=C:/Program Files/Java/jdk1.6.0_18 java.args=-server -Xms768m -Xmx768m -Dsun.io.useCanonCaches=false -XX:MaxPermSize=512m -XX:+UseParallelGC -Xbatch -Dcoldfusion.rootDir={application.home}/ -Djava.security.policy={application.home}/servers/41ep8/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/coldfusion.policy -Djava.security.auth.policy={application.home}/servers/41ep8/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib/neo_jaas.policy -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=56033 Test Case oom.cfm (this calls template.cfm below) <cffunction name="fun" output="false" access="public" returntype="any" hint=""> <cfset var local = structNew()/> <!--- comment out cfmodule and no OOM ---> <cfmodule template="template.cfm"> </cffunction> <cfset size = 1000 * 200> <cfloop from="1" to="#size#" index="idx"> <cfset fun()> <cfif NOT idx mod 1000> <cflog file="se-err" text="#idx# of #size#"> </cfif> </cfloop> template.cfm <!--- I am empty! --->

    Read the article

  • Looping through all attributes of a XML element in XSLT

    - by TheGNUGuy
    Hey everyone, I am trying to use <xsl:for-each select="@*"> to grab all the attributes of a given element but when i do that my <xsl:choose> statement doesn't execute. Here is the element that I'm working with: <textBox id="Airfare" value="" label="text 1"/> Here is the XSLT template I'm using: <xsl:template match="textBox"> <div> <xsl:choose> <xsl:when test="@label"> <xsl:value-of select="@label"/> </xsl:when> <xsl:otherwise> <xsl:text>No Label Defined</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:element name="input"> <xsl:attribute name="type">text</xsl:attribute> <xsl:for-each select="@*"> <xsl:choose> <xsl:when test="@id"> <xsl:attribute name="name">form_<xsl:value-of select="@id"/></xsl:attribute> <xsl:attribute name="id">form_<xsl:value-of select="@id"/></xsl:attribute> </xsl:when> <xsl:when test="@label"> </xsl:when> <xsl:otherwise> <xsl:copy-of select="current()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:element> </div> And when I generate the HTML using PHP I get this: <div>text 1<input type="text" id="Airfare" value="" label="text 1"></div> As you can see it didn't add form_ to the id attribute it didn't generate a name attribute and it didn't skip over the label attribute. Thanks for your help!

    Read the article

  • Looping through values in NSDictionary throws fault

    - by jud
    I have a plist file that I am loading into an NSDictionary *setDictionary that contains a set of fields, pictureDesc1, pictureDesc2, etc. Once the NSDictionary is loaded, I can retrieve a value using [setDictionary objectForKey:@"pictureDesc1"]; But I cannot do a loop like this: for (int i=1; i<=numberOfPictures; i++) { NSString *keyName = [NSString stringWithFormat:@"pictureDesc%d",i]; NSString *description = [NSString stringWithFormat:@"%@", [setDictionary objectForKey:keyName]]; } Is there a different way to dynamically call keys from within an NSDictionary?

    Read the article

  • Looping through an array to remove a touched object (iPhone/Cocos2d)

    - by Michael Lowe
    I am using cocos2d to build a game. I have an array of CCSprites and I want to be able to touch them and delete the one that was touched. Right now I have this... -(void) spawn { mySprite = [CCSprite spriteWithFile:@"image.png"]; mySprite.position = ccp(positionX,positionY); [myArray addObject:mySprite]; [self addChild:mySprite]; } - (void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* touch = [touches anyObject]; CGPoint location = [touch locationInView: [touch view]]; NSUInteger i, count = [myArray count]; for (i = 0; i < count; i++) { mySprite = (CCSprite *)[myArray objectAtIndex:i]; if (CGRectContainsPoint([mySprite boundingBox], location)) { [self removeChild:mySprite cleanup:YES]; } } I have never done this before. Does anyone have a solution? Thanks, Michael

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >