Search Results

Search found 14182 results on 568 pages for 'andrew answer'.

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

  • Ruby custom class to and from YAML;

    - by Sanarothe
    Hi. I'm having trouble deserializing a ruby class that I wrote to YAML. Where I want to be I want to be able to pass one object around as a full 'question' which includes the question text, some possible answers (For multi. choice) and the correct answer. One module (The encoder) takes input, builds a 'question' class out of it and appends it to the question pool. Another module reads a question pool and builds an array of 'question' objects. Where I am currently Sample Question Pool --- | --- !ruby/object:MultiQ a: "no" answer: "no" b: "no" c: "no" d: "no" text: "yes?" Encoder dump to YAML file. Object is a MultiQ filled up with input. (See below.) def dump(file, object) File.open(file, 'a') do |out| YAML.dump(object.to_yaml, out) end object = nil end MultiQ Class definition class MultiQ attr_accessor :text, :answer, :a, :b, :c, :d def initialize(text, answer, a, b, c, d) @text = text @answer = answer @a = a @b = b @c = c @d = d end end The decoder (I've been trying different things, so what's here wasn't my first or best guess. But I'm at a loss and the documentation doesn't really explain things thoroughly enough.) File.open( "test_set.yaml" ) do |yf| YAML.load_documents( yf ) { |item| new = YAML.object_maker( MultiQ, item) puts new } end Questions you can answer How do I achieve my goal? What methods should I use, between parsing, loading files or documents, to successfully deserialize a Ruby class? I've already looked over the YAML Rdoc, and I didn't absorb very much, so please don't just link me to it. What other methods would you suggest using? Is there a better way to store questions like this? Should I be using document db, relational db, xml? Some other format?

    Read the article

  • iPhone SDK math - pythagorean theorem problem!

    - by Flafla2
    Just as a practice, I am working on an app that solves the famous middle school pythagorean theorem, a squared + b squared = c squared. Unfortunately, the out-coming answer has, in my eyes, nothing to do with the actual answer. Here is the code used during the "solve" action. - (IBAction)solve { int legoneint; int legtwoint; int hypotenuseint; int lonesq = legoneint * legoneint; int ltwosq = legtwoint * legtwoint; int hyposq = hypotenuseint * hypotenuseint; hyposq = lonesq + ltwosq; if ([legone.text isEqual:@""]) { legtwoint = [legtwo.text intValue]; hypotenuseint = [hypotenuse.text intValue]; answer.text = [NSString stringWithFormat:@"%d", legoneint]; self.view.backgroundColor = [UIColor blackColor]; } if ([legtwo.text isEqual:@""]) { legoneint = [legone.text intValue]; hypotenuseint = [hypotenuse.text intValue]; answer.text = [NSString stringWithFormat:@"%d", legtwoint]; self.view.backgroundColor = [UIColor blackColor]; } if ([hypotenuse.text isEqual:@""]) { legoneint = [legone.text intValue]; legtwoint = [legtwo.text intValue]; answer.text = [NSString stringWithFormat:@"%d", hypotenuseint]; self.view.backgroundColor = [UIColor blackColor]; } } By the way, legone, legtwo, and hypotenuse all represent the UITextField that corresponds to each mathematical part of the right triangle. Answer is the UILabel that tells, you guessed it, the answer. Does anyone see any flaws in the program? Thanks in advance!

    Read the article

  • prolog recursion

    - by AhmadAssaf
    am making a function that will send me a list of all possible elemnts .. in each iteration its giving me the last answer .. but after the recursion am only getting the last answer back .. how can i make it give back every single answer .. thank you the problem is that am trying to find all possible distributions for a list into other lists .. the code test :- bp(3,12,[7, 3, 5, 4, 6, 4, 5, 2], Answer), format("Answer = ~w\n",[Answer]). bp(NB,C,OL,A):- addIn(C,OL,[[],[],[]],A); bp(NB,C,_,A). addIn(_,[],Result,Result). addIn(C,[Element|Rest],[F|R],Result):- member( Members , [F|R]), sumlist( Members, Sum), sumlist([Element],ElementLength), Cap is Sum + ElementLength, (Cap =< C, append([Element], Members,New), insert( Members, New, [F|R], PartialResult), addIn(C,Rest,PartialResult,Result)). by calling test .. am getting back all the list of possible answers .. now if i tried to do something that will fail like bp(3,11,[8,2,4,6,1,8,4],Answer). it will just enter a while loop .. more over if i changed the bp(NB,C,OL,A):- addIn(C,OL,[[],[],[]],A); bp(NB,C,_,A). to and instead of Or .. i get error : ERROR: is/2: Arguments are not sufficiently instantiated appreciate the help .. Thanks alot @hardmath

    Read the article

  • PHP: parse $_FILES[] data in multidimesional array

    - by superUntitled
    Example form here: http://jsfiddle.net/superuntitled/uaTtx/1/ I have a form that allows for dynamic duplication of the form fields. The form allows for file uploads and text input, so the data is sent in both $_POST and $_FILES arrays. The the initial set of inputs look like this: <input type="text" name="question[1][text]" /> <input type="file" name="question[1][file]" /> <input type="text" class="a" name="answer[1][text][]" /> <input type="file" name="answer[1][file][]" /> When duplicated the fields are incremented, they look like this: <input type="text" name="question[2][text]" /> <input type="file" name="question[2][file]" /> <input type="text" class="a" name="answer[2][text][]" /> <input type="file" name="answer[2][file][]" /> To complicate matters, the "answer" form fields can also be duplicated (thus the [] at the end of the 'answer' name array. How can I parse the posted $_FILES array? I have tried something like this: foreach ($_FILES['question'] as $p_num) { echo $p_num['file']['name']; foreach ($_FILES['answer'] as $a_num) { echo $a_num['file']['name']; } } but I get an "Undefined index: file... " error. How can I parse out the posted values.

    Read the article

  • Intermittent Internet Explorer Error whilst using Javascript to traverse XML Nodes

    - by Sykth
    Hi there all, Basically I use a javascript SOAP plugin to send and receive XML from a web service. Recently I've been experiencing intermittment (1 in every 20-30 times) errors in IE when trying to access data in the XML file. Bear with me on this, I'm going to try and go into a fair amount of detail to help anyone who is willing to read this: I have a html file, with an external javascript file attached. In the javascript file I include 5 global variables: var soapRes; var questionXML; var xRoot; var assessnode; var edStage = 0; Once the html file is at a readystate I request the XML file from the web service like this: function initNextStage(strA) { // Set pl Parameters here var pl = new SOAPClientParameters(); // soap call var r = SOAPClient.invoke(url, "LoadAssessment", pl, true, initStage_callBack); } function initStage_callBack(r, soapResponse) { soapRes = soapResponse; initvalues(); function initvalues(){ xRoot = soapRes.documentElement; assessnode = xRoot.getElementsByTagName("ed")[0]; questionXML = assessnode.getElementsByTagName("question")[edStage]; } } Once this is completed the XML should be loaded into memory via the global variable soapRes. I then save values to the XML before moving one node down the XML tree, and pulling the next set of values out of it. function submitAns1() { var objAns; var corElem; var corElemTxt; questionXML = assessnode.getElementsByTagName("question")[edStage]; objAns = questionXML.getElementsByTagName("item")[0].getAttribute("answer"); corElem = soapRes.createElement("correct"); corElemTxt = soapRes.createTextNode("value"); questionXML.appendChild(corElem); corElem.appendChild(corElemTxt); if(objAns == "t") { corElemTxt.nodeValue = "true"; } else { corElemTxt.nodeValue = "false"; } edStage++; questionXML = assessnode.getElementsByTagName("question")[edStage]; var inc1 = questionXML.getElementsByTagName("sentence")[0]; var inc2 = questionXML.getElementsByTagName("sentence")[1]; var edopt1 = questionXML.getElementsByTagName("item")[0]; var edopt2 = questionXML.getElementsByTagName("item")[1]; var edopt3 = questionXML.getElementsByTagName("item")[2]; var edopt4 = questionXML.getElementsByTagName("item")[3]; var edopt5 = questionXML.getElementsByTagName("item")[4]; var temp1 = edopt1.childNodes[0].nodeValue; var temp2 = edopt2.childNodes[0].nodeValue; var temp3 = edopt3.childNodes[0].nodeValue; var temp4 = edopt4.childNodes[0].nodeValue; var temp5 = edopt5.childNodes[0].nodeValue; } This is an example of our XML: <ed> <appid>Administrator</appid> <formid>ED009</formid> <question id="1"> <sentence id="1">[email protected]</sentence> <sentence id="2">[email protected]</sentence> <item id="0" answer="f" value="0">0</item> <item id="1" answer="f" value="1">1</item> <item id="2" answer="f" value="2">2</item> <item id="3" answer="t" value="3">3</item> <item id="4" answer="f" value="4">4</item> </question> <question id="2"> <sentence id="1">Beausdene 13</sentence> <sentence id="2">Beauscene 83</sentence> <item id="0" answer="f" value="0">0</item> <item id="1" answer="f" value="1">1</item> <item id="2" answer="t" value="2">2</item> <item id="3" answer="f" value="3">3</item> <item id="4" answer="f" value="4">4</item> </question> </ed> The error I receive intermittently is that "questionXML" is null or not an object. Specifically this line when I call on the submitAns1() method: questionXML = assessnode.getElementsByTagName("question")[edStage]; This solution works on FF, Opera, Chrome & Safari without any issues as far as I am aware. Am I accessing the XML nodes incorrectly? I've been toying with fixes for this bug for weeks now, I'd really appreciate any insight into what I'm doing wrong. On a side note, this is a personal project of mine - it's not university related - I'm much too old for that! Any help greatly appreciated. Regards, Sykth.

    Read the article

  • What functionality of an iPad can I use with Ubuntu?

    - by Andrew Ferrier
    What functionality of an iPad can I use with Ubuntu? I'm thinking about buying an iPad, but I only have Ubuntu PCs these days (no Windows, no Mac), and I'm nervous that it may be too reliant on the existence of iTunes. I'm less concerned about getting media onto and off it (and I have read that I can do this with libimobiledevice), but will I be able to activate it with iTunes? Does it need to be USB synced on a regular basis, or can I do most anything I want through the cloud (i.e. over wifi)? Edit: In answer to jrgifford's question, in theory, I'd like to do everything I would want to do with it were I using Windows/Mac. But more specifically, I think I'd want to: "Activate" it, if that's necessary Copy music / video onto it Install apps How much of this can I do without a Windows/Mac PC? Is it necessary to activate it? I don't think I'm that interested in backing it up (what would I back up?), but then again, maybe I'm confused as to how easy it is to get data on and off. Can I get a regular SFTP app for the iPad to copy data to my Ubuntu machine over wi-fi, for example?

    Read the article

  • Object behaviour or separate class?

    - by Andrew Stephens
    When it comes to OO database access you see two common approaches - the first is to provide a class (say "Customer") with methods such as Retrieve(), Update(), Delete(), etc. The other is to keep the Customer class fairly lightweight (essentially just properties) and perform the database access elsewhere, e.g. using a repository. This choice of approaches doesn't just apply to database access, it can crop up in many different OOD scenarios. So I was wondering if one way is preferable over the other (although I suspect the answer will be "it depends")! Another dev on our team argues that to be truly OO the class should be "self-contained", i.e. providing all the methods necessary to manipulate and interact with that object. I personally prefer the repository approach - I don't like bloating the Customer class with all that functionality, and I feel it results in cleaner code having it elsewhere, but I can't help thinking I'm seriously violating core OO concepts! And what about memory implications? If I retrieve thousands of Customer objects I'm assuming those with the data access methods will take up a lot more memory than the property-only objects?

    Read the article

  • Windows update error: Code 80072F8F (possibly datetime-not-correct, but it is)

    - by Andrew
    I have a Windows 2008 Server 64bit installation running as a virtual instance with a hosting provider. Windows Update has worked fine until IE8 (along with some other updates) managed to get installed (don't get me started). Now all of a sudden Windows Update fails to run and complains with error 80072F8F. UPDATE: I've since removed IE8 and am still having issues (tissues are on order) This apparently means that the time/timezone of the server is incorrect - which is not the case. I've synced the time with a time server and rebooted a number of times. I've followed the instructions here (http://support.microsoft.com/kb/929458) to no avail. Thanks! Andrew

    Read the article

  • Ideas for scaling out database architecture

    - by andrew
    We're looking to scale out our existing database architecture and need some advice on which way to go. We currently have 2 web servers behind a load balancer that both read & write to a single master database which replicates to a slave. Ideally, I'd like each of the webservers to point to their own master DB and have the data between the 2 synchronised but from what I've read, using any kind of master-master or ring-replication is discouraged. I'm looking for a general "what do other people do" kind of answer - database vendor isn't a concern at the moment but we'd like to stay with MySQL or convert to MSSQL. Any ideas would be gratefully received. Many thanks, Andrew

    Read the article

  • Domains propagation issues.

    - by Andrew
    Hello to all. I got very strange issue, really weird. On weekend, May 9th I changed my server location from US to UK. Of course, everything works correctly excluding domains. There's something wrong. I got few domains on this server but I still cannot access them. When I try from the other location it works correctly. The most funny situation is that everything is working correctly from my girlfriend's work, about 500 meters from our house, but they have another ISP. It also works when I access the domains via proxy server. I checked who.is informations and everything seems to be working. On Sunday and today morning I was able to access my domains but only for a while. When I refreshed website second time I got error "Firefox was not able to connect server". Since then I'm still getting this error. Could it be my ISP fault? Regards, Andrew

    Read the article

  • Logging in with a different password than the database password, PHPMyAdmin

    - by Andrew M
    I am trying to install PHPMyAdmin on my server to manage my MySQL databases. Right now I have only one I want to add, but I would like to be able to manage multiple databases from the same account on PHPMyAdmin. How would I configure PMA so I could login with "andrew" and a password of "examplepassword" instead of the annoyingly long and unchangeable database user and password I am provided (ie. db3483478234, password of random characters)? I can't seem to find an area to specify a different password than the regular database username and password.

    Read the article

  • Closing Question Rights in Stack over flow

    - by Asim Sajjad
    I have posted my Question and some one has closed that question, but i didn't get my answer from any of the viewer who have view my question or post theire answer, how can anyone close question when I don't get answer or statisfied with the answer posted against my question??? Why people close the question without permission of the question owner ???

    Read the article

  • Chain of Responsibility Pattern: is it a good practice to have interdependent handlers?

    - by wei
    I have this scenario: I have a chain of query handlers, the first is to query the cache, if the cache can't answer it or the answer is stale, then hit a database, if it can't find the answer or the answer is stale again, then query a remote web service. But I am not sure if this is the right way to use this pattern, since the work flow is pretty much fixed, and the cache and database handlers depend on the next step's return result to refresh its records.

    Read the article

  • Is there a class like a Dictionary without a Value template? Is HashSet<T> the correct answer?

    - by myotherme
    I have 3 tables: Foos, Bars and FooBarConfirmations I want to have a in-memory list of FooBarConfirmations by their hash: FooID BarID Hash 1 1 1_1 2 1 2_1 1 2 1_2 2 2 2_2 What would be the best Class to use to store this type of structure in-memory, so that I can quickly check to see if a combination exists like so: list.Contains("1_2"); I can do this with Dictionary<string,anything>, but it "feels" wrong. HashSet looks like the right tool for the job, but does it use some form of hashing algorithm in the background to do the lookups efficiently?

    Read the article

  • Illegal Start of Expression

    - by Kraivyne
    Hello there, I have just started to learn the very basics of Java programming. Using a book entitled "Programming Video Games for the Evil Genius". I have had an Illegal Start of Expression error that I can't for the life of me get rid of. I have checked the sample code from the book and mine is identical. The error is coming from the for(int i = difficulty; i = 0; i- - ) line. Thanks for helping a newbie out. import javax.swing.*; public class S1P4 {public static void main(String[] args) throws Exception { int difficulty; difficulty = Integer.parseInt(JOptionPane.showInputDialog("How good are you?\n"+ "1 = Great\n"+"10 = Terrible")); boolean cont = false; do { cont = false; double num1 = (int)(Math.round(Math.random()*10)); double num2; do { num2 = (int)(Math.round(Math.random()*10)); } while(num2==0.0); int sign = (int)(Math.round(Math.random()*3)); double answer; System.out.println("\n\n*****"); if(sign==0) { System.out.println(num1+" times "+num2); answer = num1*num2; } else if(sign==1) { System.out.println(num1+" divided by"+num2); answer = num1/num2; } else if(sign==1) { System.out.println(num1+" plus "+num2); answer = num1+num2; } else if(sign==1) { System.out.println(num1+" minus "+num2); answer = num1-num2; } else { System.out.println(num1+" % "+num2); answer = num1%num2; } System.out.println("*****\n"); for(int i = difficulty; i >= 0; i- - ) { System.out.println(i+"..."); Thread.sleep(500); } System.out.println("ANSWER: "+answer); String again; again = JOptionPane.showInputDialog("Play again?"); if(again.equals("yes")) cont = true; } while(cont); } }

    Read the article

  • .NET 2.0 Framework in C# check if 64bit os if so do this? if not do this? better answer?

    - by NightsEVil
    hi i have this little snippet of code i wrote that checks to see if a folder is present (only exists in x64) if so it does "X" commands, if not (i.e x86) does "Z" commands (x,Z are just markers for code) but what i wanna know is there a better or more reliable way to do this using only the 2.0 .net Framework? string target = @"C:\Windows\SysWow64"; { if (Directory.Exists(target)) { //do x64 stuff } else { //do x86 stuff }

    Read the article

  • How to use Regular Expression to extract information from a HTML webpage?

    - by user569248
    How to use Regular Expression to extract the answer "Here is the answer" from a HTML webpage like this? <b>Last Question:</b> <b>Here is the answer</b> ..:: Update ::.. Thanks everybody! Here is my solution by using BeautifulSoup since I'm using Python framework: response = opener.open(url) the_page = response.read() soup = BeautifulSoup(''.join(the_page)) paraText1 = soup.body.find('div', 'div_id', text = u'Last Question:') if paraText1: answer = paraText1.next

    Read the article

  • How does the following code work? It gives the answer how I want. But I want to know how it works? C

    - by user338096
    public static void ShutDownComputer() { ManagementBaseObject outParameter = null; ManagementClass sysOs = new ManagementClass("Win32_OperatingSystem"); sysOs.Get(); sysOs.Scope.Options.EnablePrivileges = true; ManagementBaseObject inParameter = sysOs.GetMethodParameters("Win32Shutdown"); inParameter["Flags"] = "8"; inParameter["Reserved"] = "0"; foreach (ManagementObject maObj in sysOs.GetInstances()) { outParameter = maObj.InvokeMethod("Win32Shutdown", inParameter, null); } }

    Read the article

  • Ubuntu 11.10 doesn't detect external usb hard drive

    - by Andrew
    I have been batting with this issue for a bit and cannot find the answer to it. So the Dmesg see's the device, being Symwave WDC WD64.... media@Media-pc:~$ dmesg | tail -n 20 [78678.719497] scsi 10:0:0:0: Direct-Access Generic- USB3.0 CRW -0 1.00 PQ: 0 ANSI: 0 CCS [78678.725621] scsi 10:0:0:1: Direct-Access Generic- USB3.0 CRW -1 1.00 PQ: 0 ANSI: 0 CCS [78684.073837] scsi 11:0:0:0: Direct-Access SYMWAVE WDC WD6400AAKS-0 3B01 PQ: 0 ANSI: 4 [78691.008126] scsi 11:0:0:0: uas_eh_abort_handler tag 0 [78691.008139] scsi 11:0:0:0: uas_eh_device_reset_handler tag 0 [78691.008147] scsi 11:0:0:0: uas_eh_target_reset_handler tag 0 [78691.008154] scsi 11:0:0:0: uas_eh_bus_reset_handler tag 0 [78691.080307] usb 2-2.4: reset high speed USB device number 9 using ehci_hcd [78691.221427] scsi 11:0:0:0: Device offlined - not ready after error recovery [78691.221498] scsi 11:0:0:0: rejecting I/O to offline device [78691.221519] scsi 11:0:0:0: rejecting I/O to offline device [78691.222952] scsi 11:0:0:1: Enclosure SYMWAVE SES 3B01 PQ: 0 ANSI: 4 [78691.223156] scsi 11:0:0:2: uas_sense_old: urb length 26 disagrees with IU sense data length 510, using 18 bytes of sense data [78691.225061] sd 11:0:0:0: Attached scsi generic sg3 type 0 [78691.225344] ses 11:0:0:1: Attached Enclosure device [78691.225495] ses 11:0:0:1: Attached scsi generic sg4 type 13 [78691.226266] sd 10:0:0:0: Attached scsi generic sg5 type 0 [78691.226653] sd 10:0:0:1: Attached scsi generic sg6 type 0 [78691.241647] sd 10:0:0:0: [sdd] Attached SCSI removable disk [78691.243832] sd 10:0:0:1: [sde] Attached SCSI removable disk It looks like it attaches sdd and sde. Now when i look in the disk utility it shows "Hard disk Symwave WD6400AAKS-0 device /dev/sdc doesn't show any other info then that, if i format, it says that it cannot open /dev/sdc no device or address error. Underneeth the device it does show two general usb3.0 CRW that are sdd and sde. Now if I do a fdisk -l it doesn't show the device: media@Media-pc:~$ sudo fdisk -l Disk /dev/sda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders, total 156301488 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000247de Device Boot Start End Blocks Id System /dev/sda1 * 2048 152176639 76087296 83 Linux /dev/sda2 152178686 156301311 2061313 5 Extended /dev/sda5 152178688 156301311 2061312 82 Linux swap / Solaris Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x948fc822 Device Boot Start End Blocks Id System /dev/sdb1 63 1953520064 976760001 7 HPFS/NTFS/exFAT So now I am confused. Any ideas how I get fdisk to see the device?

    Read the article

  • Checkout multiple revision of one file in CVS repository

    - by Andrew
    Hi, To checkout I use the following command CVSROOT="/home/projects/stuff/" cvs co mywork with the mywork directory I have text files as well as pictures, i.e., looks something like this - paper.tex - pic1.jpg - pic2.jpg etc. In particular, I am interested in checking out all the version of paper.tex over time. Is there a way how I can check all revisions of this file out at once? Or which command can I use to see when revision have been made to this particular file? many thanks for your help, Andrew

    Read the article

  • Smallest executable for Windows

    - by Andrew Warren
    Hi I need to create a very simple GUI application for Windows(open a file, do some changes based on user input, upload the file to an intranet server). The client company has the latest release versions of Java SE, .NET and Adobe AIR installed on all their machines. And their #1 requirement is to have the smallest possible package for xcopy deployment. So which of the 3 listed platforms should I use? Another option of course is a native exe. Thanks, Andrew

    Read the article

  • Checkout multiple revision of one file in SVN repository

    - by Andrew
    Hi, To checkout I use the following command CVSROOT="/home/projects/stuff/" cvs co mywork with the mywork directory I have text files as well as pictures, i.e., looks something like this - paper.tex - pic1.jpg - pic2.jpg etc. In particular, I am interested in checking out all the version of paper.tex over time. Is there a way how I can check all revisions of this file out at once? Or which command can I use to see when revision have been made to this particular file? many thanks for your help, Andrew

    Read the article

  • Any good open source online RPG starter kit for development ?

    - by Andrew Sky
    Hi there, Does anyone know of a good open source toolkit that allows level designer and graphic designer or someone with basic programming experience to create multiplayer online Role Playing Game ? The game can be a simple 2D interface in a 2d virtual world. I know Microsoft have a starter kit something like the following : http://creators.xna.com/en-US/starterkit/roleplayinggame that allows developer to create RPG game running on XBox platform but i am looking more on multiplayer role playing game on the web platform where player can play directly with their browser. regards Andrew

    Read the article

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