Search Results

Search found 2682 results on 108 pages for 'michael mao'.

Page 60/108 | < Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >

  • Create links programmatically inside an EmberJS view

    - by Michael Gallego
    I have a pretty complex view to render which involves some kind of recursion (the typical folder/file nested list). The fact that it contains heterogeneous objects (folders and files) make it even harder to write Handlebars templates. Therefore, the only solution I've found is to create a view, and manually fill the render buffer. I came with the following solution: App.LibraryContentList = Ember.View.extend({ tagName: 'ol', classNames: ['project-list', 'dd-list'], nameChanged: function() { this.rerender(); }.observes('[email protected]'), render: function(buffer) { // We only start with depth of zero var content = this.get('content').filterProperty('depth', 0); content.forEach(function(item) { this.renderItem(buffer, item); }, this); }, renderItem: function(buffer, item) { switch (item.constructor.toString()) { case 'Photo.Folder': this.renderFolder(buffer, item); break; case 'Photo.File': this.renderFile(buffer, item); break; } }, renderFolder: function(buffer, folder) { buffer.push('<li class="folder dd-item">'); buffer.push('<span class="dd-handle">' + folder.get('name') + '</span>'); // Merge sub folders and files, and sort them by sort order var content = this.mergeAndSort(); if (content.get('length') > 0) { buffer.push('<ol>'); content.forEach(function(item) { this.renderItem(buffer, item); }, this); buffer.push('</ol>'); } buffer.push('</li>'); }, renderFile: function(buffer, album) { buffer.push('<li class="album dd-item">'); buffer.push('<span class="dd-handle">' + file.get('name') + '</span>'); buffer.push('</li>'); } }); Now, what I'd like is to be able to add links so that each folder and each file is clickable and redirect to another route. But how am I supposed to do that, as I don't have access to the linkTo helper? I've tried to play with the LinkView view, but without any success. Should I register handlers manually for each item? I've also thought about breaking that with a CollectionView instead, and splitting the content by depth so that I could render it using templates, but it seems more complicated. Any thoughts?

    Read the article

  • Raphael JS image animation performance.

    - by michael
    Hi, I'm trying to create an image animation using Raphael JS. I want the effect of a bee moving randomly across the page, I've got a working example but it's a bit "jittery", and I'm getting this warning in the console: "Resource interpreted as image but transferred with MIME type text/html" I'm not sure if the warning is causing the "jittery" movement or its just the way I approached it using maths. If anyone has a better way to create the effect, or improvements please let me know. I have a demo online here and heres my javascript code: function random(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function BEE(x, y, scale) { this.x = x; this.y = y; this.s = scale; this.paper = Raphael("head", 915, 250); this.draw = function() { this.paper.clear(); this.paper.image("bee.png", this.x, this.y, 159*this.s, 217*this.s); } this.update = function() { var deg = random(-25, 25); var newX = Math.cos(Raphael.rad(deg)) * 2; var newY = Math.sin(Raphael.rad(deg)) * 2; this.x += newX; this.y += newY; if( this.x > 915) { this.x = 0; } if( this.y > 250 || this.y < 0 ) { this.y = 125; } } } $(document).ready(function() { var bee = new BEE(100, 150, 0.4); var timer = setInterval(function(){ bee.draw(); bee.update(); }, 15); }

    Read the article

  • Impact of ordering of correlated subqueries within a projection

    - by Michael Petito
    I'm noticing something a bit unexpected with how SQL Server (SQL Server 2008 in this case) treats correlated subqueries within a select statement. My assumption was that a query plan should not be affected by the mere order in which subqueries (or columns, for that matter) are written within the projection clause of the select statement. However, this does not appear to be the case. Consider the following two queries, which are identical except for the ordering of the subqueries within the CTE: --query 1: subquery for Color is second WITH vw AS ( SELECT p.[ID], (SELECT TOP(1) [FirstName] FROM [Preference] WHERE p.ID = ID AND [FirstName] IS NOT NULL ORDER BY [LastModified] DESC) [FirstName], (SELECT TOP(1) [Color] FROM [Preference] WHERE p.ID = ID AND [Color] IS NOT NULL ORDER BY [LastModified] DESC) [Color] FROM Person p ) SELECT ID, Color, FirstName FROM vw WHERE Color = 'Gray'; --query 2: subquery for Color is first WITH vw AS ( SELECT p.[ID], (SELECT TOP(1) [Color] FROM [Preference] WHERE p.ID = ID AND [Color] IS NOT NULL ORDER BY [LastModified] DESC) [Color], (SELECT TOP(1) [FirstName] FROM [Preference] WHERE p.ID = ID AND [FirstName] IS NOT NULL ORDER BY [LastModified] DESC) [FirstName] FROM Person p ) SELECT ID, Color, FirstName FROM vw WHERE Color = 'Gray'; If you look at the two query plans, you'll see that an outer join is used for each subquery and that the order of the joins is the same as the order the subqueries are written. There is a filter applied to the result of the outer join for color, to filter out rows where the color is not 'Gray'. (It's odd to me that SQL would use an outer join for the color subquery since I have a non-null constraint on the result of the color subquery, but OK.) Most of the rows are removed by the color filter. The result is that query 2 is significantly cheaper than query 1 because fewer rows are involved with the second join. All reasons for constructing such a statement aside, is this an expected behavior? Shouldn't SQL server opt to move the filter as early as possible in the query plan, regardless of the order the subqueries are written?

    Read the article

  • Advanced Rails Routing of short URL's and usernames off of root url

    - by Michael Waxman
    I want to have username URL's and Base 58 short URL's to resources both off of the root url like this: http://mydomain.com/username #=> goes to given user http://mydomain.com/a3x9 #=> goes to given story I am aware of the possibilities of a user names conflicting with short urls, and I have a workaround, but what I can't figure out is the best way to set this up in rails. Can I do it in rails routes? Should I do something with a piece of Rack middleware? Should I set up a routing controller? Please let me know the best way to do this. Thanks so much!

    Read the article

  • What's a good way of building up a String given specific start and end locations?

    - by Michael Campbell
    (java 1.5) I have a need to build up a String, in pieces. I'm given a set of (sub)strings, each with a start and end point of where they belong in the final string. Was wondering if there were some canonical way of doing this. This isn't homework, and I can use any licensable OSS, such as jakarta commons-lang StringUtils etc. My company has a solution using a CharBuffer, and I'm content to leave it as is (and add some unit tests, of which there are none (?!)) but the code is fairly hideous and I would like something easier to read. As I said this isn't homework, and I don't need a complete solution, just some pointers to libraries or java classes that might give me some insight. The String.Format didn't seem QUITE right... I would have to honor inputs too long and too short, etc. Substrings would be overlaid in the order they appear (in case of overlap). As an example of input, I might have something like: String:start:end FO:0:3 (string shorter than field) BAR:4:5 (String larger than field) BLEH:5:9 (String overlays previous field) I'd want to end up with FO BBLEH 01234567890

    Read the article

  • Create image from scratch with JMagick

    - by Michael IV
    I am using Java port of ImageMagick called JMagick .I need to be able to create a new image and write an arbitrary text chunk into it.The docs are very poor and what I managed to get so far is to write text into the image which comes from IO.Also , in all the examples I have found it seems like the very first operation ,before writing new image data , is always loading of an existing image into ImageInfo instance.How do I create an image from scratch with JMagick and then write a text into it? Here is what I do now : try { ImageInfo info = new ImageInfo(); info.setSize("512x512"); info.setUnits(ResolutionType.PixelsPerInchResolution); info.setColorspace(ColorspaceType.RGBColorspace); info.setBorderColor(PixelPacket.queryColorDatabase("red")); info.setDepth(8); BufferedImage img = new BufferedImage(512,512,BufferedImage.TYPE_4BYTE_ABGR); byte[] imageBytes = ((DataBufferByte) img.getData().getDataBuffer()).getData(); MagickImage mimage = new MagickImage(info,imageBytes); DrawInfo aInfo = new DrawInfo(info); aInfo.setFill(PixelPacket.queryColorDatabase("green")); aInfo.setUnderColor(PixelPacket.queryColorDatabase("yellow")); aInfo.setOpacity(0); aInfo.setPointsize(36); aInfo.setFont("Arial"); aInfo.setTextAntialias(true); aInfo.setText("JMagick Tutorial"); aInfo.setGeometry("+40+40"); mimage.annotateImage(aInfo); mimage.setFileName("text.jpg"); mimage.writeImage(info); } catch (MagickException ex) { Logger.getLogger(LWJGL_IDOMOO_SIMPLE_TEST.class.getName()).log(Level.SEVERE, null, ex); } It doesn't work , the JVM crashes with access violation as it probably expects for the input image from IO.

    Read the article

  • Adobe AIR: problem with OpenID / rpxnow logins

    - by michael
    Does Adobe Air work with OpenID/rpxnow? I'm having a developer build me an AIR app to work with my website so I can have access to desktop photos. However, my site uses OpenID logins via the rpxnow.com implementation. Works fine in the web version, but my developer has told me that he cannot do rpxnow/openid logins from the AIR app because it doesn't allow pop-ups and/or redirects. Has anyone found a workaround? m.

    Read the article

  • Problems with html forms.

    - by Michael
    My form views fine in IE7 and IE8 but FireFox does not display the form correctly: The problem is it does not display the form inside my "mainContent1" Note my code below: <div id="mainContent1"> <form action="forms.php" target="_self"> <fieldset> <legend>Postal Address</legend> <label for="street">Street address:</label> <input id="street" name="street" type="text" /> <label for=" suburb">County</label> <input id="county" name="county" type="text" /> <label for="state">State</label> <input id="state" name="state" type="text" /> <label for="zip">Zip Code</label> <input id="zip" name="zip" type="text" /> </fieldset> </form> </div>

    Read the article

  • Pushing to a UITable inside a UIView from a UITableview

    - by Michael Robinson
    I can firgure out how to push a UIView from a Tableview and have the "child" details appear. Here is the view I'm trying to load: Here is the code that checks for children and either pushes a itemDetail.xib or an additional UITable, I want to use the above .xib but load the correct contents "tableDataSource" into the UItable: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //Get the dictionary of the selected data source. NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row]; //Get the children of the present item. NSArray *Children = [dictionary objectForKey:@"Children"]; if([Children count] == 0) { ItemDetailViewController *dvController = [[ItemDetailViewController alloc] initWithNibName:@"ItemDetailView" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:dvController animated:YES]; [dvController release]; } else { //Prepare to tableview. FirstTab *rvController = [[FirstTab alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]]; //Increment the Current View rvController.CurrentLevel += 1; //Set the title; rvController.CurrentTitle = [dictionary objectForKey:@"Title"]; //Push the new table view on the stack [self.navigationController pushViewController:rvController animated:YES]; rvController.tableDataSource = Children; [rvController release]; } } Thanks for the help. I see lots of stuff on this but can't find the correct push instructions.

    Read the article

  • Problems with show hide jquery

    - by Michael
    I am trying to get show hide to work on multiple objects but I am unable to get it to work. Any help would be nice an much appreciated... I am lost on how to do this. If I only do one show hide it works fine but more than one it does not work properly. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Show Hide Sample</title> <script src="js/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $('#content1').hide(); $('a').click(function(){ $('#content1').show('slow'); }); $('a#close').click(function(){ $('#content1').hide('slow'); }) }); </script> <style> body{font-size:12px; font-family:"Trebuchet MS"; background: #CCF} #content1{ border:1px solid #DDDDDD; padding:10px; margin-top:5px; width:300px; } </style> </head> <body> <a href="#" id="click">Test 1</a> <div class="box"> <div id="content1"> <h1 align="center">Hide 1</h1> <P> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam pulvinar, enim ac hendrerit mattis, lorem mauris vestibulum tellus, nec porttitor diam nunc tempor dui. Aenean orci. Sed tempor diam eget tortor. Maecenas quis lorem. Nullam semper. Fusce adipiscing tellus non enim volutpat malesuada. Cras urna. Vivamus massa metus, tempus et, fermentum et, aliquet accumsan, lectus. Maecenas iaculis elit eget ipsum cursus lacinia. Mauris pulvinar.</p> <p><a href="#" id="close">Close</a></p> </div> </div> <a href="#" id="click">Test 2</a> <div class="box"> <div id="content1"> <h1 align="center">Hide 2</h1> <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam pulvinar, enim ac hendrerit mattis, lorem mauris vestibulum tellus, nec porttitor diam nunc tempor dui. Aenean orci. Sed tempor diam eget tortor. Maecenas quis lorem. Nullam semper. Fusce adipiscing tellus non enim volutpat malesuada. Cras urna. Vivamus massa metus, tempus et, fermentum et, aliquet accumsan, lectus. Maecenas iaculis elit eget ipsum cursus lacinia. Mauris pulvinar.</p> <p><a href="#" id="close">Close</a></p> </div> </div> </body> </html>

    Read the article

  • How can I 'mirror' my git repository locally?

    - by michael
    Hi, I have followed the following instructions in setting a git repository locally in one of my hard drive (1): https://trac.webkit.org/wiki/UsingGitWithWebKit I would like to know if it is possible for me to set up another repository in a different hard drive which mirrors the one I setup in (1)? By mirrors, I mean if I commit some changes the other repository can retrieve it. Thank you.

    Read the article

  • Compiler error: memset was not declared in this scope

    - by michael
    Hi, I am trying to compile my c program in ubuntu 9.10 (gcc 4.4.1). I am getting this error: Rect.cpp:344: error: ‘memset’ was not declared in this scope But the problem is I have already included in my cpp file: #include <stdio.h> #include <stdlib.h> And the same program compiles fine under ubuntu 8.04 gcc 4.2.4). Please tell me what am i missing. Thank you.

    Read the article

  • revoked client certificate

    - by Michael
    Hi guys, I have little problem. I used certificate authority in windows server 2003 and revoked client certificate. The client certificate is in revoked certificate. I try verify this client certificate on revocation in winform app in windows server 2003. Code is here : private bool VefiryCert(X509Certificate2 cert) { X509Chain chain = new X509Chain(); chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain; chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 0, 1000); chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags; X509VerificationFlags.AllowUnknownCertificateAuthority; return chain.Build(cert); } But this client certificate is verify as true. I am confuse, where can be problem ? How can I check revocation list, which is loaded in winform application and used on verification this client certificate? So the problem is I verify client certificate, which is in revoked list (in certification authority) with method VefiryCert, an the certificate is verify as TRUE. Can somebody help me ?

    Read the article

  • Using phpFlickr, how would one display the primary photo from each photoset?

    - by Michael
    Referring to this question: http://stackoverflow.com/questions/2561475/flickr-phpflickr-api how would you display a primary photo from a photoset rather than all photos and photosets? this is the code I have so far: photosets_getList($user); ? <?php $photoset_id = $ph_set['id']; $photos = $f->photosets_getPhotos($photoset_id); foreach ($photos['photoset']['photo'] as $photo): ?> <?php if($parentID == $ph_set['parent']): ?> <a rel="lightbox[album<?=$count;?>]" href="<?= $f->buildPhotoURL($photo, 'medium') ?>" title="<?= $photo['title'] ?>"> <?php endif;?> <img src="<?= $f->buildPhotoURL($photo, 'square') ?>" alt="<?= $photo['title'] ?>" width="75" height="75" title="<?= $photo['title'] ?>" /> <h3><?=$ph_set['title']?></h3> <?php if($parentID == $ph_set['parent']): ?> </a> </div> <?php endif;?>

    Read the article

  • MySQL ORDER BY date and team

    - by Michael
    I would like to order by date and then team in a MySQL query. It should be something similar to this: SELECT * FROM games ORDER BY gamedate ASC, team_id AND it should output something like this: 2010-04-12 10:20 Game 1 Team 1 2010-04-12 11:00 Game 3 Team 1 2010-04-12 10:30 Game 2 Team 2 2010-04-14 10:00 Game 4 Team 1 So that Team 1 is under each other on the same date, but separate on a new date

    Read the article

  • Unit Testing Error - The unit test adapter failed to connect to the data source or to read the data

    - by michael.lukatchik
    I'm using VSTS 2K8 and I've set up a Unit Test Project. In it, I have a test class with a method that does a simple assertion. I'm using an Excel 2007 spreadsheet as my data source. My test method looks like this: [DataSource("System.Data.Odbc", "Dsn=Excel Files;dbq=|DataDirectory|\\MyTestData.xlsx;defaultdir=C:\\TestData;driverid=1046;maxbuffersize=2048;pagetimeout=5", "Sheet1", DataAccessMethod.Sequential)] [DeploymentItem("MyTestData.xlsx")] [TestMethod()] public void State_Value_Is_Set() { string expected = "MD"; string actual = TestContext.DataRow["State"] as string; Assert.AreEqual(expected, actual); } As indicated in the method decoration attributes, my Excel spreadsheet is on my local C:/ Drive. In it, the sheet where all of my data is located is named "Sheet1". I've copied the Excel spreadsheet into my project and I've set its Build Action = "Content" and I've set its Copy to Output Directory = "Copy if Newer". When trying to run this simple unit test, I receive the following error: The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library. Error details: ERROR [42S02] [Microsoft][ODBC Excel Driver] The Microsoft Office Access database engine could not find the object 'Sheet1'. Make sure the object exists and that you spell its name and the path name correctly. I've verified that the sheet name is spelled correctly (i.e. Sheet1) and I've verified that my data sources are set correctly. Web searches haven't turned up much at all. And I'm totally stumped. All help or input is appreciated!!!!

    Read the article

  • count clicks using actionscript 3.0 in flash

    - by Michael Stone
    I want to change the variable value based on the number of clicks. So if you click the button once, the cCount should equal 1 and twice it should equal 2. Right now all I'm returning for the value is 0, no matter the amount of clicks. Any ideas? btnRaw.addEventListener(MouseEvent.CLICK, flip); btnRaw.addEventListener(MouseEvent.MOUSE_UP,count); //create the flipping function //create the variable to store the click count var cCount:Number = 0; function flip(Event:MouseEvent):void{ raw_patty_mc.gotoAndPlay(1); } function count(Event:MouseEvent):void{ cCount = cCount+1; if(cCount>3 || cCount<6){ titleText.text="See you're doing a great job at flipping the burger! "+String(cCount); } }

    Read the article

  • Will Apple's new "originally written in" clause affect your decision to target the iPhone?

    - by Michael Aaron Safyan
    So, you've probably heard about Apple's change to its agreement to prohibit source-to-source translation, thereby blocking translation from Flash (in CS5) and also from Android (via XMLVM). You may also have read about a response by a well-known Adobe developer, and calls to boycott development for the iPhone. Given that this audience is a better representative of the developer community than those who post comments on the NYT, Digg, and other news sites, I was wondering what your opinions were about this decision. Will any of you switch to Android from the iPhone or avoid development on the iPhone as a result of this? Since this is fairly subjective, I am making this a community wiki. Also, please, keep things civil.

    Read the article

  • cakephp Activation Email Sending slow

    - by Michael
    Hi all, I have a simple email sender for user account activation. Depending on which email address I use, I get significantly different response times: University email - 1 minute, Gmail - 3-4 hours, Yahoo - 1 or 2 days -- which seems bizarre. Has anyone else seen this phenomenon? EDIT: There weren't many responses (even for a bounty), but I'll try to explain my problem more clearly. This probably isn't greylsting -- If I so a simple: php mail ($to, $subject, $body) // this delivers instantly. My cakephp code: function __sendActivationEmail($id) { $User = $this->User->read ( null, $id ); $this->set ( 'suffix_url', $User ['User'] ['id'] . '/' . $this->User->getActivationHash () ); $this->set ( 'username', $User ['User'] ['username'] ); $this->Email->to = $User ['User'] ['email']; $this->Email->subject = 'Test.com - ' . __ ( 'please confirm your email address', true ); $this->Email->from = '[email protected]'; $this->Email->template = 'user_confirm'; $this->Email->sendAs = 'text'; $this->Email->delivery = 'mail'; $this->Email->send (); } Causes delays from 13 minutes (ok; we'll deal with it) to 5-6 hours (less okay, since this is an activation email). For some of my users, it works instantly, but for other users (of the same service provider, i.e., gmail, it sees these delays). Any clues?

    Read the article

  • PyML 0.7.2 - How to prevent accuracy from dropping after stroing/loading a classifier?

    - by Michael Aaron Safyan
    This is a followup from "Save PyML.classifiers.multi.OneAgainstRest(SVM()) object?". The solution to that question was close, but not quite right, (the SparseDataSet is broken, so attempting to save/load with that dataset container type will fail, no matter what. Also, PyML is inconsistent in terms of whether labels should be numbers or strings... it turns out that the oneAgainstRest function is actually not good enough, because the labels need to be strings and simultaneously convertible to floats, because there are places where it is assumed to be a string and elsewhere converted to float) and so after a great deal of hacking and such I was finally able to figure out a way to save and load my multi-class classifier without it blowing up with an error.... however, although it is no longer giving me an error message, it is still not quite right as the accuracy of the classifier drops significantly when it is saved and then reloaded (so I'm still missing a piece of the puzzle). I am currently using the following custom mutli-class classifier for training, saving, and loading: class SVM(object): def __init__(self,features_or_filename,labels=None,kernel=None): if isinstance(features_or_filename,str): filename=features_or_filename; if labels!=None: raise ValueError,"Labels must be None if loading from a file."; with open(os.path.join(filename,"uniquelabels.list"),"rb") as uniquelabelsfile: self.uniquelabels=sorted(list(set(pickle.load(uniquelabelsfile)))); self.labeltoindex={}; for idx,label in enumerate(self.uniquelabels): self.labeltoindex[label]=idx; self.classifiers=[]; for classidx, classname in enumerate(self.uniquelabels): self.classifiers.append(PyML.classifiers.svm.loadSVM(os.path.join(filename,str(classname)+".pyml.svm"),datasetClass = PyML.VectorDataSet)); else: features=features_or_filename; if labels==None: raise ValueError,"Labels must not be None when training."; self.uniquelabels=sorted(list(set(labels))); self.labeltoindex={}; for idx,label in enumerate(self.uniquelabels): self.labeltoindex[label]=idx; points = [[float(xij) for xij in xi] for xi in features]; self.classifiers=[PyML.SVM(kernel) for label in self.uniquelabels]; for i in xrange(len(self.uniquelabels)): currentlabel=self.uniquelabels[i]; currentlabels=['+1' if k==currentlabel else '-1' for k in labels]; currentdataset=PyML.VectorDataSet(points,L=currentlabels,positiveClass='+1'); self.classifiers[i].train(currentdataset,saveSpace=False); def accuracy(self,pts,labels): logger=logging.getLogger("ml"); correct=0; total=0; classindexes=[self.labeltoindex[label] for label in labels]; h=self.hypotheses(pts); for idx in xrange(len(pts)): if h[idx]==classindexes[idx]: logger.info("RIGHT: Actual \"%s\" == Predicted \"%s\"" %(self.uniquelabels[ classindexes[idx] ], self.uniquelabels[ h[idx] ])); correct+=1; else: logger.info("WRONG: Actual \"%s\" != Predicted \"%s\"" %(self.uniquelabels[ classindexes[idx] ], self.uniquelabels[ h[idx] ])) total+=1; return float(correct)/float(total); def prediction(self,pt): h=self.hypothesis(pt); if h!=None: return self.uniquelabels[h]; return h; def predictions(self,pts): h=self.hypotheses(self,pts); return [self.uniquelabels[x] if x!=None else None for x in h]; def hypothesis(self,pt): bestvalue=None; bestclass=None; dataset=PyML.VectorDataSet([pt]); for classidx, classifier in enumerate(self.classifiers): val=classifier.decisionFunc(dataset,0); if (bestvalue==None) or (val>bestvalue): bestvalue=val; bestclass=classidx; return bestclass; def hypotheses(self,pts): bestvalues=[None for pt in pts]; bestclasses=[None for pt in pts]; dataset=PyML.VectorDataSet(pts); for classidx, classifier in enumerate(self.classifiers): for ptidx in xrange(len(pts)): val=classifier.decisionFunc(dataset,ptidx); if (bestvalues[ptidx]==None) or (val>bestvalues[ptidx]): bestvalues[ptidx]=val; bestclasses[ptidx]=classidx; return bestclasses; def save(self,filename): if not os.path.exists(filename): os.makedirs(filename); with open(os.path.join(filename,"uniquelabels.list"),"wb") as uniquelabelsfile: pickle.dump(self.uniquelabels,uniquelabelsfile,pickle.HIGHEST_PROTOCOL); for classidx, classname in enumerate(self.uniquelabels): self.classifiers[classidx].save(os.path.join(filename,str(classname)+".pyml.svm")); I am using the latest version of PyML (0.7.2, although PyML.__version__ is 0.7.0). When I construct the classifier with a training dataset, the reported accuracy is ~0.87. When I then save it and reload it, the accuracy is less than 0.001. So, there is something here that I am clearly not persisting correctly, although what that may be is completely non-obvious to me. Would you happen to know what that is?

    Read the article

  • onmouseover problems with JavaScript (rendered using django and django-imagekit)

    - by Michael Moreno
    I'm using Imagekit. View.py includes: def pics(request): p = Photo.objects.all() return render_to_response('Shots.html', {'p': p}) The following simple code in the template will generate associated images: {% for p in p %} <img src = "{{ p.display.url }}"> <img src = "{{ p.thumbnail_image.url }}"> {% endfor %} I'm attempting to generate a series of thumbnails {{ p.thumbnail_image.url }} which, when mouseover'd, will generate the slightly larger version of the image, {{ p.display.url }} via Javascript. The following code in the template attempts to do so: <html> <head> <HEAD> <script language="Javascript"> { image1 = new Image image2 = new Image image1.src = {{ p.thumbnail_image.url }} image2.src = {{ p.display.url }} </script> </head> <body> {% for p in p %} <a href="" onMouseOver="document.rollover.src= image2.src onMouseOut="document.rollover.src= image1.src"> <img src="{{ p.thumbnail_image.url }}" border=0 name="rollover"></a> {% endfor %} </body> </html> This will display the series of thumbnails, but the larger image will not display when mouseover'd. I believe it has to do with how I'm specifying the variable {{ p.display.url }}.

    Read the article

  • Can I inject a SessionBean into a JEE AroundInvoke-Interceptor?

    - by Michael Locher
    I have an EAR with modules: foo-api.jar foo-impl.jar interceptor.jar In foo-api there is: @Local FooService // (interface of a local stateless session bean) In foo-impl there is: @Stateless FooServiceImpl implements FooService //(implementation of the foo service) In interceptor.jar I want public class BazInterceptor { @EJB private FooService foo; @AroundInvoke public Object intercept( final InvocationContext i) throws Exception { // do someting with foo service return i.proceed(); } The question is: Will a Java EE 5 compliant application server (e.g. JBoss 5) inject into the interceptor? If no, what is good strategy for accessing the session bean? To consider: Deployment ordering / race conditions

    Read the article

  • Should I Return "500" or "404" if a Requested Image is not Found?

    - by Michael Robinson
    I work with code written by other people, occasionally I am left somewhat confused and at these times Stack Overflow saves me. Please, save me again. Our site allows people to upload images and later embed them within text in our site like so: <img src="http://site.com/image_script.php?p=some_image_identifier"/> My question is: If the identifier, "p", does not lead us to an image should the server return "500" or "404"? I would have thought it should be "404", but that's not what is happening right now.

    Read the article

< Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >