Daily Archives

Articles indexed Saturday January 15 2011

Page 21/28 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • python - returns incorrect positive #

    - by tekknolagi
    what i'm trying to do is write a quadratic equation solver but when the solution should be -1, as in quadratic(2, 4, 2) it returns 1 what am i doing wrong? #!/usr/bin/python import math def quadratic(a, b, c): #a = raw_input("What\'s your `a` value?\t") #b = raw_input("What\'s your `b` value?\t") #c = raw_input("What\'s your `c` value?\t") a, b, c = float(a), float(b), float(c) disc = (b*b)-(4*a*c) print "Discriminant is:\n" + str(disc) if disc = 0: root = math.sqrt(disc) top1 = b + root top2 = b - root sol1 = top1/(2*a) sol2 = top2/(2*a) if sol1 != sol2: print "Solution 1:\n" + str(sol1) + "\nSolution 2:\n" + str(sol2) if sol1 == sol2: print "One solution:\n" + str(sol1) else: print "No solution!" EDIT: it returns the following... import mathmodules mathmodules.quadratic(2, 4, 2) Discriminant is: 0.0 One solution: 1.0

    Read the article

  • on click checkbox set input attr

    - by Tommy Arnold
    html form with 4 columns the first 2 columns are the sizes inside input boxes with disabled ='disabled', when they click radio button to select a size a checkbox appears, when they click that checkbox I would like to change the class and disabled attr of the inputs on that table row to allow them to edit the input box <table width="388" border="1" id="product1"> <tr> <td width="100">Width</td> <td width="100">Height</td> <td width="48">Price</td> <td width="65">Select</td> </tr> <tr> <td><input type="text" disabled='disabled'value="200"/><span> CMS</span></td> <td><input disabled='disabled'type="text" value="500"/><span> CMS</span></td> <td>£50.00</td> <td><input type="radio" name="product1" value="size1" /> Customise<input type="checkbox" name="custom[size1]" class="custombox" value="1"/></td> </tr> <tr> <td>200</td> <td>1000</td> <td>£100.00</td> <td><input type="radio" name="product1" value="size2" /> Customise<input disabled='disabled' type="checkbox" name="custom[size2]" class="custombox" value="1"/></td> </tr> <tr> <td>200</td> <td>1500</td> <td>£150</td> <td><input type="radio" name="product1" value="size3" /> Customise<input type="checkbox" name="custom[size3]" class="custombox" value="1"/></td> </tr> </table> <table width="288" border="1" id="product2"> <tr> <td width="72">Width</td> <td width="75">Height</td> <td width="48">Price</td> <td width="65">&nbsp;</td> </tr> <tr> <td>200</td> <td>500</td> <td>£50.00</td> <td><input type="radio" name="product2" value="size1" /> Customise<input type="checkbox" name="custom[size1]" class="custombox" value="1"/></td> </tr> <tr> <td>200</td> <td>1000</td> <td>£100.00</td> <td><input type="radio" name="product2" value="size2" /> Customise<input type="checkbox" name="custom[size2]" class="custombox" value="1"/></td> </tr> <tr> <td>200</td> <td>1500</td> <td>£150</td> <td><input type="radio" name="product2" value="size3" /> Customise<input type="checkbox" name="custom[size3]" class="custombox" value="1"/></td> </tr> <table> CSS input[type=checkbox] { display: none; } input[type=checkbox].shown { display: inline; } input .edit{ border:1px solid red; } input[disabled='disabled'] { border:0px; width:60px; padding:5px; float:left; background:#fff; } span{float:left; width:30px; padding:5px;} Jquery $("body :checkbox").hide(); // The most obvious way is to set radio-button click handlers for each table separatly: $("#product1 :radio").click(function() { $("#product1 :checkbox").hide(); $("#product1 .cbox").hide(); $(this).parent().children(":checkbox").show(); $(this).parent().children(".cbox").show(); }); $("#product2 :radio").click(function() { $("#product2 :checkbox").hide(); $("#product2 .cbox").hide(); $(this).parent().children(":checkbox").show(); $(this).parent().children(".cbox").show(); }); This is what I thought but its not working $("#product1 :checkbox").click(function(){ $(this).parent("tr").children("td :input").attr('disabled',''); $(this).parent("tr").children("td :input").toggleClass(edit); }); $("#product2 :checkbox").click(function(){ $(this).parent("tr").children("td :input").attr('disabled',''); $(this).parent("tr").children("td :input").toggleClass(edit); }); Thanks in advance for any help.

    Read the article

  • Int Showing as Long Odd Value

    - by Josh Kahane
    Hi I am trying to send an int in my iphone game for game center multiplayer. The integer is coming up and appearing as an odd long integer value rather than the expected one. I have this in my .h: typedef enum { kPacketTypeScore, } EPacketTypes; typedef struct { EPacketTypes type; size_t size; } SPacketInfo; typedef struct { SPacketInfo packetInfo; int score; } SScorePacket; Then .m: Sending data: scoreData *score = [scoreData sharedData]; SScorePacket packet; packet.packetInfo.type = kPacketTypeScore; packet.packetInfo.size = sizeof(SScorePacket); packet.score = score.score; NSData* dataToSend = [NSData dataWithBytes:&packet length:packet.packetInfo.size]; NSError *error; [self.myMatch sendDataToAllPlayers: dataToSend withDataMode: GKMatchSendDataUnreliable error:&error]; if (error != nil) { // handle the error } Receiving: SPacketInfo* packet = (SPacketInfo*)[data bytes]; switch (packet->type) { case kPacketTypeScore: { SScorePacket* scorePacket = (SScorePacket*)packet; scoreData *score = [scoreData sharedData]; [scoreLabel setString:[NSString stringWithFormat:@"You: %d Challenger: %d", score.score, scorePacket]]; break; } default: CCLOG(@"received unknown packet type %i (size: %u)", packet->type, packet->size); break; } Any ideas? Thanks.

    Read the article

  • Generate a pdf thumbnail (open source/free)

    - by AndrewB
    Looking at other posts for this could not find an adequate solution that for my needs. Trying to just get the first page of a pdf document as a thumbnail. This is to be run as a server application so would not want to write out a pdf document to file to then call a third application that reads the pdf to generate the image on disk. doc = new PDFdocument("some.pdf"); page = doc.page(1); Image image = page.image; Thanks.

    Read the article

  • Wolfram Workbench and Mathematica Help System

    - by belisarius
    I find the Wolfram Workbench a nice environment for Mathematica development. However, as I program in Mathematica, I need to navigate the Help System very often. The Workbench provides a tooltip tool that shows a very basic help for the Mma functions (just the usage messages), and is not enough for my usual needs. So: Is there a way to bring up and navigate the whole Mma Help System from inside the Workbench? Alternative solutions are also welcome. Re-entering the function name in a notebook and pressing F1 is not :)

    Read the article

  • Facebook Hacker Cup: Power Overwhelming

    - by marcog
    A lot of people at Facebook like to play Starcraft II™. Some of them have made a custom game using the Starcraft II™ map editor. In this game, you play as the noble Protoss defending your adopted homeworld of Shakuras from a massive Zerg army. You must do as much damage to the Zerg as possible before getting overwhelmed. You can only build two types of units, shield generators and warriors. Shield generators do no damage, but your army survives for one second per shield generator that you build. Warriors do one damage every second. Your army is instantly overrun after your shield generators expire. How many shield generators and how many warriors should you build to inflict the maximum amount of damage on the Zerg before your army is overrun? Because the Protoss value bravery, if there is more than one solution you should return the one that uses the most warriors. Constraints 1 = G (cost for one shield generator) = 100 1 = W (cost for one warrior) = 100 G + W = M (available funds) = 1000000000000 (1012)

    Read the article

  • "Dereference" var in C#

    - by chris12892
    I have some code in C# that uses a structure as such: ArrayList addrs = new ArrayList(); byte[] addr = new byte[8]; while (oneWire.Search_GetNextDevice(addr)) { addrs.Add(addr); } In this example, every element in the ArrayList is the same as the last device that was found because it would appear as though addr is passed out by reference and I am simply copying that reference into the ArrayList. Is there any way to "Dereference" addr to only extract it's value? It's also possible my assessment of the situation is incorrect, if that appears to be the case, please let me know Thanks!

    Read the article

  • Firefox released beta 9 for version 4

    - by anirudha
    Firefox yesterday released 9 beta of Firefox 4. now many plug-in work inside Firefox 4. How to get plugin work in Firefox 4 :- if you like any plug-in who you like to use but not worked in Firefox 4 go to developer site may be they work on them so it’s chance you can get the version who is in development from developer site. because many of plugin wait for a time period for testing or making same version for all plateform like linux or mac osX. How to work with stable and Beta version [standalone] sometime we fell that it’s time wasting because something we need the beta version can’t give. so you can use Firefox 3.6.13 or Firefox 4 both by a trick. you need to install them in other directory. when you trying to install another version beware because they also override the last installation directory so you need to choose the directory where you want to get another version manually.

    Read the article

  • Install KVM based Windows 2008 remotely over SSH on a headless, no graphics Ubuntu 10.04 server?

    - by taazaa
    Hi, I have a Dell server at a remote data center with Ubuntu 10.04 as the host. It is a minimal install with the necessary virtulization packages. There is no X and the machine is headless. I have the win2008 DVD in the machine and want to remotely install it. I tried: virt-install --connect qemu:///system -n vmwin2k8 -r 1024 --disk path=server2k8.qcow2,size=50 --cdrom /dev/sr0 --vnc --noautoconsole --os-type windows --os-variant win2k8 The qcow2 image get created However I don't understand how to connect to see the install via VNC. This is my first time doing it so it may be trivial or may not be possible. Remotely I have a Win 7 machine with Putty and RealVNC viewer. Where is the graphic output of VNC going? Do I have to have VNC server running on the host or some other machine and then connect to it from my VNC client? Please let me know or point me to the right direction. I have been searching the web for several days to figure out how this is suppose to work. Thanks!

    Read the article

  • Microsoft VirtualPC Networking Issue

    - by Joda Maki
    I am using Microsoft VPC running the supplied microsoft images to test IE6/7. The ip addresses that get assigned to these images are via dhcp and get valid ip addresses in my subnet. They can access the external internet just fine. However, they cannot ping my host machine, nor can my host machine ping them (using internal ip addresses). Thus, they can't access my webserver to test with. How is this possible and how do I fix it?

    Read the article

  • Webpage / Other application does not fit fully on screen

    - by Frank Levebre
    I have an ASUS Eee PC 1008 HA The problem is that I have to move the cursor up/down in order to see the start control / icons at the bottom of the screen and the cursor up in order to see the menu bar / etc at the top of the screen, ie the whole page does not fit on the screen anymore. It has nothing to do with the zoom % in the bottom right hand corner. This also is the case whatever application I am running, ie Internet explorer , word, excel or whatever. Does anybody have an idea what is the problem and how I can resolve this?

    Read the article

  • Bios wont post unless I restart power supply.

    - by remy
    I have an annoying problem with a computer. The BIOS wont post after it has been turned off and started again unless I turn the switch off/on on the power supply. The fans, cdrom hdd and everything starts running but the bios never beeps and the monitor stays black. I HAVE TRIED: reinstalling windows xp, flashed bios to latest, cmos clear, new power supply, other hdd, new memory sticks, graphics card. I also removed the motherboard from the computer case and laid it on a cardboard box and only connected the PSU, RAM and CPU. Other than this the computer works great but its annoying having to off/on the power supply switch before turning it on after its been off. My guess is that the motherboard is faulty but I would just like to hear what you guys think. Sorry for my english / Remy

    Read the article

  • Suddenly can't send E-Mails with Apple Mail to Gmail SMTP

    - by slhck
    Hi all, I have a weird problem that started just today. I am using Apple Mail on a Leopard machine, connecting to Gmail. Fetching e-mail works just fine. My SMTP settings are also correct. Still, I can't send mail, it will display a pop up saying that "transferring the content to the mail server" failed (translation from German, could be different in English OS X versions). I have verified the following: My SMTP settings are definitely correct. I have not changed them and the issue appeared today. Also, I went through the Apple online configuration for Gmail accounts and did not have to adjust any setting. I can run network diagnosis and it will connect to both POP and SMTP servers without a problem (all green lights) The Telnet details will show me the HELO message from the Gmail servers, so there's no authentication failure. Console.app will not show any messages related to "mail" when I try to send the mail, so there's no specific error message The mail I'm trying to send does not have an attachment, it is plaintext only I can login to gmail.com and send mails without a problem The recipient address exists and contains no syntax errors I can also not send mails to myself When using another IP and ISP (through VPN), it still doesn't work As for my settings: I connect to smtp.gmail.com and for advanced settings I choose password-based authentication with user: [email protected] and my password. I let Apple Mail try the default ports (for SSL and TLS, respectively). Again: I have not changed a thing between yesterday and today. What is causing that strange behavior? Any help would be much appreciated.

    Read the article

  • Understanding node.js: some real-life examples

    - by steweb
    Hi all! As a curious web developer I've been hearing about node.js for several months and (just) now I'd like to learn it and, most of all, understand its "engine". So, as a real newbie about node.js I'm going to follow some tutorials. And as every new technology over the internet, find a very good and exhaustive tutorial is like looking for a needle in a haystack :) My "big question" can be split into this 3 sub-questions: I know node.js can be very useful to build web-chats. But, apart from this example (and from helloworld one :D), how could I use it? Which are the real-life examples that let me think i.e. "oh, it's fantastic, I could really integrate it for my daily projects"? I also know it implements some JS specifications. It is required to deeply know other programming languages apart from JS? Where can I find a good reference (basically, I don't want to search "node.js reference" on google hoping to be lucky enough to get some good websites)? Thanks everyone!

    Read the article

  • MVC design pattern in complex iPad app: is one fat controller acceptable?

    - by nutsmuggler
    I am building a complex iPad application; think of it as a scrapbook. For the purpose of this question, let's consider a page with two images over it. My main view displays my doc data rendered as a single UIImage; this because I need to do some global manipulation over them. This is my DisplayView. When editing I need to instantiate an EditorView with my two images as subviews; this way I can interact with a single image, (rotate it, scale it, move it). When editing is triggered, I hide my DisplayView and show my EditorView. In a iPhone app, I'd associate each main view (that is, a view filling the screen) to a view controller. The problem is here there is just one view controller; I've considered passing the EditorView via a modal view controller, but it's not an option (there a complex layout with a mask covering everything and palettes over it; rebuilding it in the EditorView would create duplicate code). Presently the EditorView incorporates some logic (loads data from the model, invokes some subviews for fine editing, saves data back to the model); EditorView subviews also incorporate some logic (I manipulate images and pass them back to the main EditorView). I feel this logic belongs more to a controller. On the other hand, I am not sure making my only view controller so fat a good idea. What is the best, cocoa-ish implementation of such a class structure? Feel free to ask for clarifications. Cheers.

    Read the article

  • jQuery: bind generated elements

    - by superUntitled
    Hello, thank you for taking time to look at this. I am trying to code my very first jQuery plugin and have run into my first problem. The plugin is called like this <div id="kneel"></div> <script type="text/javascript"> $("#kneel").zod(1, { }); </script> It takes the first option (integer), and returns html content that is dynamically generated by php. The content that is generated needs to be bound by a variety of functions (such as disabling form buttons and click events that return ajax data. The plugin looks like this (I have included the whole plugin in case that matters)... (function( $ ){ $.fn.zod = function(id, options ) { var settings = { 'next_button_text': 'Next', 'submit_button_text': 'Submit' }; return this.each(function() { if ( options ) { $.extend( settings, options ); } // variables var obj = $(this); /* these functions contain html elements that are generated by the get() function below */ // disable some buttons $('div.bario').children('.button').attr('disabled', true); // once an option is selected, enable the button $('input[type="radio"]').live('click', function(e) { $('div.bario').children('.button').attr('disabled', false); }) // when a button is clicked, return some data $('.button').bind('click', function(e) { e.preventDefault(); $.getJSON('/returnSomeData.php, function(data) { $('.text').html('<p>Hello: ' + data + '</p>'); }); // generate content, this is the content that needs binding... $.get('http://example.com/script.php?id='+id, function(data) { $(obj).html(data); }); }); }; })( jQuery ); The problem I am having is that the functions created to run on generated content are not binding to the generated content. How do I bind the content created by the get() function?

    Read the article

  • How to pass a linc to class function and call it?

    - by Kabumbus
    So I have a class like class mySafeData { public: void Set( int i ) { myMutex.lock(); myData = i; myMutex.unlock(); } void Get( int& i) { myMutex.lock(); i = myData; myMutex.unlock(); } private: int myData; boost::mutex myMutex; }; its instance is running. Lets call instance A. I want to create a new class that would take as a start up argument some kind of link to Getter from A and would be capable to somehow save link to thet getter for calling it inside its private methods vhen needed. how to do such thing?

    Read the article

  • Entering to index page?

    - by FullmetalBoy
    // // Post: /Search/Alternativ1/txtBoxTitle) [HttpPost] public ActionResult Alternativ1(int txtBoxTitle) { SokningMedAlternativ1 test= new SokningMedAlternativ1(); if (txtBoxTitel != null) { var codeModel = test.FilteraBokLista(txtBoxTitel); } return View(codeModel); } Problem: I have problem to find a solution to go back to my index page (first page when entering a website for the first time) view if txtBoxTitle has null. My request: How shall I enter to my index page view automatically if txtBoxTitle contains null? // Fullmetalboy

    Read the article

  • identify documents from results of mahout clustering

    - by Tejas
    I am using mahout to cluster text documents indexed using solr. I have used the "text" field in the document to form vectors. Then I used the k-means driver in mahout for clustering and then the clusterdumper utility to dump the results. I am having difficulty in understanding the output results from the dumper. I could see the clusters formed with term vectors in those clusters. But how do I extract the documents from these clusters. I want the result to be the input documents appearing in different clusters.

    Read the article

  • Java: Making concurrent MySQL queries from multiple clients synchronised

    - by Misha Gale
    I work at a gaming cybercafe, and we've got a system here (smartlaunch) which keeps track of game licenses. I've written a program which interfaces with this system (actually, with it's backend MySQL database). The program is meant to be run on a client PC and (1) query the database to select an unused license from the pool available, then (2) mark this license as in use by the client PC. The problem is, I've got a concurrency bug. The program is meant to be launched simultaneously on multiple machines, and when this happens, some machines often try and acquire the same license. I think that this is because steps (1) and (2) are not synchronised, i.e. one program determines that license #5 is available and selects it, but before it can mark #5 as in use another copy of the program on another PC tries to grab that same license. I've tried to solve this problem by using transactions and table locking, but it doesn't seem to make any difference - Am I doing this right? Here follows the code in question: public LicenseKey Acquire() throws SmartLaunchException, SQLException { Connection conn = SmartLaunchDB.getConnection(); int PCID = SmartLaunchDB.getCurrentPCID(); conn.createStatement().execute("LOCK TABLE `licensekeys` WRITE"); String sql = "SELECT * FROM `licensekeys` WHERE `InUseByPC` = 0 AND LicenseSetupID = ? ORDER BY `ID` DESC LIMIT 1"; PreparedStatement statement = conn.prepareStatement(sql); statement.setInt(1, this.id); ResultSet results = statement.executeQuery(); if (results.next()) { int licenseID = results.getInt("ID"); sql = "UPDATE `licensekeys` SET `InUseByPC` = ? WHERE `ID` = ?"; statement = conn.prepareStatement(sql); statement.setInt(1, PCID); statement.setInt(2, licenseID); statement.executeUpdate(); statement.close(); conn.commit(); conn.createStatement().execute("UNLOCK TABLES"); return new LicenseKey(results.getInt("ID"), this, results.getString("LicenseKey"), results.getInt("LicenseKeyType")); } else { throw new SmartLaunchException("All licenses of type " + this.name + "are in use"); } }

    Read the article

  • Manually Increasing the Amount of CPU a Java Application Uses

    - by SkylineAddict
    I've just made a program with Eclipse that takes a really long time to execute. It's taking even longer because it's loading my CPU to 25% only (I'm assuming that is because I'm using a quad-core and the program is only using one core). Is there any way to make the program use all 4 cores to max it out? Java is supposed to be natively multi-threaded, so I don't understand why it would only use 25%.

    Read the article

  • HTML5, CSS3 columns

    - by DrGizmondo
    Hay all im building a news aggregator with SimplePie, the SP elements are working fine but I would like to have the feeds that it pulls in displayed in columns across the page using HTML5 and CSS3. I have managed to implement it so that the columns are formed and display the feeds, but at the moment the stories are being ordered one on to of the other from left to right with the newest being displayed top left, the second newest bellow the first in column one and so on. What I would like is for the stories to be displayed from left to right across the column so that the newest is at the top of the first column, the second newest at the top of the second column, the third newest in the third column and so on. The code that Im using at the moment is as follows: <div id="page-wrap"> <?php if ($feed->error): ?> <p><?php echo $feed->error; ?></p> <?php endif; ?> <?php foreach ($feed->get_items() as $item): ?> <div class="chunk"> <h4 style="background:url(<?php $feed = $item->get_feed(); echo $feed->get_favicon(); ?>) no-repeat; text-indent: 25px; margin: 0 0 10px;"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h4> <p class="footnote">Source: <a href="<?php $feed = $item->get_feed(); echo $feed->get_permalink(); ?>"><?php $feed = $item->get_feed(); echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a T'); ?></p> </div> <?php endforeach; ?> And this CSS: #page-wrap { width: 100%; margin: 25px auto; height:400px; text-align: justify; -moz-column-count: 3; -moz-column-gap: 1.5em; -moz-column-rule: 1px solid #c4c8cc; -webkit-column-count: 3; -webkit-column-gap: 1.5em; -webkit-column-rule: 1px solid #c4c8cc; } If anyone could help me out with this that would be great.

    Read the article

  • BackOffice Database Application FrontEnd - Program in C#/VB.Net or PHP?

    - by HK1
    I'm working on a project where there will be a MySQL database containing data that will mostly be displayed on the web using PHP. However, there is a need here for a back-office data entry application (linked to the same MySQL database) that is feature rich and easy to use. what I'm trying to understand is where we are at with web-based frontends. I find that there are still so many events and features that I can make use of in a Windows Desktop GUI written in something like C#, VB.Net or MS Access. I don't have a lot of experience programming UI for web but it's my impression that it's still more difficult and takes longer to get similar or the same functionality using non-MS web technologies (I dislike ASP.net, sorry) as compared to programming the desktop portion in a traditional desktop application language like C#, VB.Net, or MS Access. jQuery and jQuery UI are definately making things easier. Also, there's very rich online applications like Google Docs and Zoho but it's my impression that these are programmed by some of the top web UI programmers around, not to mention that it takes longer to write it and intensive testing to make it work in all of your target browsers. It also takes extra time and code to "block" browsers that don't meet the requirements. What programming language would you recommend? I know I may not have given enough information here but I'm not sure what I'm missing. If you have questions just leave a comment below so I can edit this post and answer the questions.

    Read the article

  • Not found in protocol

    - by Alex
    I've subclassed MKAnnotation so that i can assign objects to annotations and then assign this object to a view controller like so: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { PlaceDetailView *detailView = [[PlaceDetailView alloc] initWithStyle:UITableViewStyleGrouped]; detailView.place = [view.annotation place]; [self.navigationController pushViewController:detailView animated:YES]; [detailView release]; } This is working great but i'm having the following issues: If i try and access the place getter method like so view.annotation.place i recieve an error: Accessing unknown place getter method If i acces the place getter method like so [view.annotation place] i receive a warning: place not found in protocol From my understanding this is because the place object is not defined in the MKAnnotation protocol, although i'm aware of this i'm not sure how to tell the complier that place does exist and it's not calling it blind.

    Read the article

  • jQuery - UI Dialog - looking for a smart solution for a timed close

    - by AnApprentice
    Hello, I wrote the following: // Called with setTimeout(magicDialogDelayedClose, 2500); function magicDialogDelayedClose() { $(".ui-dialog").fadeOut(function() { dialog_general.dialog('close'); }); } The above is called with setTimeout when I show a notice dialog that I want to auto close in 2.5 secs. The problem I'm noticing with this is that if the use Manually closes a dialog this timer still is running. If the user then opens a new dialog (which is very possible) the timer can then close that NEW dialog. What's a smart way to handle this?j

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >