Daily Archives

Articles indexed Saturday January 15 2011

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

  • Converting from samplerate/cutoff frequency to pi-radians/sample in a discrete time sampled IIR filter system.

    - by Fake Name
    I am working on doing some digital filter work using Python and Numpy/Scipy. I'm using scipy.signal.iirdesign to generate my filter coefficents, but it requires the filter passband coefficents in a format I am not familiar with wp, ws : float Passband and stopband edge frequencies, normalized from 0 to 1 (1 corresponds to pi radians / sample). For example: Lowpass: wp = 0.2, ws = 0.3 Highpass: wp = 0.3, ws = 0.2 (from here) I'm not familiar with digital filters (I'm coming from a hardware design background). In an analog context, I would determine the desired slope and the 3db down point, and calculate component values from that. In this context, how do I take a known sample rate, a desired corner frequency, and a desired rolloff, and calculate the wp, ws values from that? (This might be more appropriate for math.stackexchange. I'm not sure)

    Read the article

  • lighttpd virtual host config

    - by muncherelli
    Trying to get these two vhosts set up correctly. I have two sites on this domain that i'm hosting: www.example.com/example.com and test.example.com. How do I get both of these to work in my vhost definitions? I have: $HTTP["host"] == "test.example.com" { and $HTTP["host"] =~ "(^|.)example.com$" { (I think this is for *.example.com) It always goes to the second one, even if I am trying to go to test.example.com. I need to be able to host www.example.com/example.com and test.example.com

    Read the article

  • SMTP server (IIS) is running but can't test it with telnet

    - by NitroxDM
    I have a Windows 2003 web edition server that I can't seem to get the SMTP relay working. BT4 shows port 25 open. When I try use telnet to test it on my desktop I get: Connecting To XXX.XXX.XXX.XXX...Could not open connection to the host, on port 25: Connect failed. From the server I get: Microsoft Telnet> o 127.0.0.1 25 Connecting To 127.0.0.1... Connection to host lost. There isn't anything useful in the logs. Any ideas?

    Read the article

  • external drive enclosure -> software RAID 5?

    - by memilanuk
    Hello all, I have two older PCs on my LAN posing as 'servers'... one running FreeNAS off a USB stick using three 500GB hdds in a ZFS RAID-Z pool serving as storage for the LAN and one running Debian Lenny with an 80GB drive used as a general purpose 'tinker' box that I can ssh into, etc. Problem is that the SMART report for one of those 500GB drives in the FreeNAS box is showing some pre-failure attributes, and the whole array is a little small anyways. Rather than simply replace one 500GB drive with another 500GB drive, and have no backup of the file server, I'd like to upgrade all the drives to 2TB ones - but I have no where to store that much data in the mean while. As such, I started looking at getting a 4-bay external drive enclosure with an eSATA card for the Debian box, with the hopes of creating a RAID5 + LVM setup using those drives and backing the data up to that external drive enclosure. After the backup is done, replace the drives in the FreeNAS box and rebuild the array there and mirror the data back. Then, I'd have both the primary storage (on the FreeNAS box) and a backup (which I don't have currently) using the external drive enclosure on the Debian box. My big question is... most of these external drive boxes seem to claim support for JBOD, RAID 0, 1, 10, 5, etc. - should I presume that is simply fake RAID like many commodity mobos have, and not really usable in Linux? In that case, with all the drives hanging off the one eSATA connection, will Linux (specifically Debian Squeeze, as I plan on upgrading that box here shortly) see all four drives, or just the first one? Will I be able to configure them in a RAID5 array as desired? Thanks, Monte

    Read the article

  • Can I install Microsoft Visual Web Developer w/o a SQL Server Express installation?

    - by lavinio
    When I attempt to install Microsoft Visual Web Developer 2010 Express, it forces an installation of SQL Server 2008 Express, which is okay. However, it forces it to have the instance name SQLEXPRESS instead being the default instance. I tried installing SQL Server 2008 Express first, but the Web Platform Installer 3.0 still wants to download and install the named instance, which then I have to uninstall. I'm putting together a guide that several others in my group will follow, so I'd like to not have to tell them to "install, then uninstall". So, is there any reasonable way to either (1) install VWD w/o SS, or (2) install VWD but configure SS do use the default instance?

    Read the article

  • Is there a remote file transfer command that preserves nanosecond timestamps?

    - by Denver Gingerich
    I've tried transferring files using scp and rsync on Ubuntu 10.04, but neither of them preserves more than second precision. Here's an example: $ touch test1 $ scp -p test1 localhost:test2 $ ls -l --full-time test* -rw-r--r-- 1 user user 0 2011-01-14 18:46:06.579717282 -0500 test1 -rw-r--r-- 1 user user 0 2011-01-14 18:46:06.000000000 -0500 test2 $ cp -p test1 test2 $ ls -l --full-time test* -rw-r--r-- 1 user user 0 2011-01-14 18:46:06.579717282 -0500 test1 -rw-r--r-- 1 user user 0 2011-01-14 18:46:06.579717282 -0500 test2 $ A straight copy works fine, but scp truncates the timestamp. Are there any tools (preferably similar to scp or rsync in their usage) that do remote file transfers while preserving nanosecond timestamps? I could write a hacky script to do it, but I'd rather not.

    Read the article

  • What kind of users stories should be written in the initial stages of a project?

    - by Domenic
    When just starting a project, you have nothing---no UI, no data layer, nothing in between. Thus, a single story like "users should be able to view their foos" will entail a lot of work. Once you have that story, one like "users should be able to edit their foos" is more realistic, but that first story will involve setting up a UI layer, a presentation logic layer, a domain logic layer, and a data access layer. This doesn't fit with my concept of "tasks": to me, I'd rather have something like the following "tasks": Show dummy data for a user's foos in HTML, derived from JavaScript objects. Set up a presentation logic layer, and connect the JavaScript objects to it. Set up a domain logic layer, and connect the presentation logic layer to it. Set up a data access layer, and connection the domain logic layer to it. Do all of these fall under the single "story" above? If so, I feel like stories are not a terribly useful framework in the early stages of a project. If so, that's fine---I just want to make sure I'm not missing something, since I'm really trying to learn this agile methodology as best I can.

    Read the article

  • Is OpenGL after C++ job oriented?

    - by Ani
    First, my regards to all programmers out there who have put their endless efforts in learning and becoming expert, wise, efficient and best. Let me describe my situation. I have just graduated from Electronics and Communication Stream. Though I have more interest in software development and hence I have opted to become a software developer rather than Electronics engg. I have learned C++ and wish to wish to go more deep. I have started to learn OpenGL. Guide me in the following: Is OpenGL good to learn and is it job oriented? Should I learn some other language rather then OpenGL after C++?

    Read the article

  • Advice needed on how to start web programming? [closed]

    - by Recursion
    Possible Duplicate: Best approach to learning web programming I have resisted doing web programming for a while, but I have come to the realization that I need to learn it and may have resisted do to fear of the unknown. I am a regular applications and systems programmer with no real idea of how to even get started. I have tried to start a few times, rails, django, tornado, web.py, cherrypy, but always get discouraged and quit. The most web programming I have done was in HTML during 1995 for my geocities site. I have pretty decent experience with regular programming in C, Python, Assembly and Java. Just looking for a way to get started and get a good overview of the different technologies and frameworks. I am not doing this for a job or employment, just to learn.

    Read the article

  • How to install 3d support?

    - by Gonzalo
    I'm trying Natty and after an upgrade I received this message: "Sorry, you don't have 3d support, install it for your graphic hardware to get Unity or please reboot and select 'Classic session' at startup." So I want to install 3D support but I don't know how to. My machine is a Sony Vaio VGN-SR29XN Laptop with Intel Graphics, but I would like to know the general instructions. P.S. : I've no problem with the CLI, I just don't know how to proceed in this particular case (what driver, or program...).

    Read the article

  • Meta package / quick reference for string manipulation commands?

    - by Dylan McCall
    The latest version of the Scribes text editor lets us select some text, hit Alt+X, and then run an arbitrary command. For example, I can run the sort command and the selected text is replaced appropriately. This is quite useful but I am also not very well-versed in awk and the like. Is there something I can grab that will provide more of these commands like sort? Maybe a package with a whole bunch of handy, task-specific string manipulation commands?

    Read the article

  • Can't checkin to Facebook Places by post to api?

    - by MarcusJoe
    Hey everybody, I am trying to build an app where I let my registered user be able to check in to places on Facebook Places. I however for some reason can't seem to make this work. I assumed this is possible with the Api as write functionality has been added to it, but I couldn't find an clear explanation on the web. this is what I currently have, after I have asked the user for permission to publish checkins and for user_checkins. <?php require("src/facebook.php"); $facebook = new Facebook(array( 'appId' => 'xxxxxxxxx', 'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'cookie' => true )); # see if active session $session = $facebook->getSession(); if(!empty($session)) { try{ $uid = $facebook->getUser(); $api_call = array( 'method' => 'users.hasAppPermission', 'uid' => $uid, 'ext_perm' => 'publish_checkins' ); $can_post = $facebook->api($api_call); if($can_post){ $facebook->api('/'.$uid.'/checkins', 'POST', array( 'access_token' => $facebook->getAccessToken(), 'place' => 'place_id', 'message' =>'I went to placename today', 'picture' => 'http://www.place.com/logo.jpg', 'coordinates' => array( 'latitude' => 'lattiude', 'longitude' => 'lattitude', 'tags' => $uid, ) ) ); echo 'You were checked in'; } else { die('Permissions required!'); } } catch (Exception $e){} } else { # There's no active session,generate one $login_url = $facebook->getLoginUrl(); header("Location: ".$login_url); } ?> The code works when I change it 'checkins' to 'feed'. Is there something wrong with my code or am I trying to do somethign that isn't possible (or do it the wrong way). Any help will be greatly appreciated as I already spent quite a significant amount of time trying to fix this, but I just can't seem to make it work. Best regards, Marcus Joe

    Read the article

  • Creating a Compilation Unit with type bindings

    - by hizki
    I am working with the AST API in java, and I am trying to create a Compilation Unit with type bindings. I wrote the following code: private static CompilationUnit parse(ICompilationUnit unit) { ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setSource(unit); parser.setResolveBindings(true); CompilationUnit compiUnit = (CompilationUnit) parser.createAST(null); return compiUnit; } Unfortunately, when I run this code in debug mode and inspect compiUnit I find that compiUnit.resolver.isRecoveringBindings is false. Can anyone think of a reason why it wouldn't be true, as I specified it to be? Thank you

    Read the article

  • PHP Curl's Proxy feature causes no information to be returned

    - by Grant David Bachman
    I'm working on a PHP script right now which sends requests to our school's servers to get real-time information about class sizes for different courses. The script runs perfectly fine when I don't use a proxy, returning a string full of course numbers and available seats. However, I want to make this a service for the students, and I'm afraid that if I make too many requests my ip will get blocked. So I'm attempting to do this through a proxy, with no success. As soon as I add the CURLOPT_HTTPPROXYTUNNEL and CURLOPT_PROXY fields to my requests nothing gets returned. I'm not even sure how to troubleshoot it at this point since I'm not getting an error message of any kind. Does anyone know what's going on or how to at least troubleshoot it?

    Read the article

  • problem disposing class in Dictionary it is Still in the heap memory although using GC.Collect

    - by Bahgat Mashaly
    Hello i have a problem disposing class in Dictionary this is my code private Dictionary<string, MyProcessor> Processors = new Dictionary<string, MyProcessor>(); private void button1_Click(object sender, EventArgs e) { if (!Processors.ContainsKey(textBox1.Text)) { Processors.Add(textBox1.Text, new MyProcessor()); } } private void button2_Click(object sender, EventArgs e) { MyProcessor currnt_processor = Processors[textBox1.Text]; Processors.Remove(textBox2.Text); currnt_processor.Dispose(); currnt_processor = null; GC.Collect(); } public class MyProcessor: IDisposable { private bool isDisposed = false; string x = ""; public MyProcessor() { for (int i = 0; i < 20000; i++) { //this line only to increase the memory usage to know if the class is dispose or not x = x + "gggggggggggg"; } this.Dispose(); GC.SuppressFinalize(this); } public void Dispose() { this.Dispose(true); GC.SuppressFinalize(this); } public void Dispose(bool disposing) { if (!this.isDisposed) { isDisposed = true; this.Dispose(); } } ~MyProcessor() { Dispose(false); } } i use "ANTS Memory Profiler" to monitor heap memory the disposing work only when i remove all keys from dictionary how can i destroy the class from heap memory ? thanks in advance

    Read the article

  • Can I separate portions of my plugin.xml file into multiple xml files for an Eclipse plugin?

    - by wildabeast
    I have created an eclipse plugin, with a plugin.xml file. I have created an extension to the org.eclipse.wst.common.snippets.SnippetContributions extension point. The xml contents of this extension point has gotten really big. Is there a way that I can move the contents of my snippets extension to a separate file? Something like this: In plugin.xml: <extension point="org.eclipse.wst.common.snippets.SnippetContributions" file="snippets.xml"></extenstion> and in snippets.xml: <category ....> <item..../item> </category>...

    Read the article

  • Visitor pattern and compiler code generation, how to get children attributes?

    - by LeleDumbo
    I'd like to modify my compiler's code generator to use visitor pattern since the current approach must use multiple conditional statement to check the real type of a child before generating the corresponding code. However, I have problems to get children attributes after they're visited. For instance, in binary expression I use this: LHSCode := GenerateExpressionCode(LHSNode); RHSCode := GenerateExpressionCode(RHSNode); CreateBinaryExpression(Self,LHS,RHS); In visitor pattern the visit method is usually void, so I can't get the expression code from LHS and RHS. Keeping shared global variables isn't an option since expression code generation is recursive thus could erase previous values kept in the variables. I'll just show the binary expression as this is the most complicated part (for now): function TLLVMCodeGenerator.GenerateExpressionCode( Expr: TASTExpression): TLLVMValue; var BinExpr: TASTBinaryExpression; UnExpr: TASTUnaryExpression; LHSCode, RHSCode, ExprCode: TLLVMValue; VarExpr: TASTVariableExpression; begin if Expr is TASTBinaryExpression then begin BinExpr := Expr as TASTBinaryExpression; LHSCode := GenerateExpressionCode(BinExpr.LHS); RHSCode := GenerateExpressionCode(BinExpr.RHS); case BinExpr.Op of '<': Result := FBuilder.CreateICmp(ccSLT, LHSCode, RHSCode); '<=': Result := FBuilder.CreateICmp(ccSLE, LHSCode, RHSCode); '>': Result := FBuilder.CreateICmp(ccSGT, LHSCode, RHSCode); '>=': Result := FBuilder.CreateICmp(ccSGE, LHSCode, RHSCode); '==': Result := FBuilder.CreateICmp(ccEQ, LHSCode, RHSCode); '<>': Result := FBuilder.CreateICmp(ccNE, LHSCode, RHSCode); '/\': Result := FBuilder.CreateAnd(LHSCode, RHSCode); '\/': Result := FBuilder.CreateOr(LHSCode, RHSCode); '+': Result := FBuilder.CreateAdd(LHSCode, RHSCode); '-': Result := FBuilder.CreateSub(LHSCode, RHSCode); '*': Result := FBuilder.CreateMul(LHSCode, RHSCode); '/': Result := FBuilder.CreateSDiv(LHSCode, RHSCode); end; end else if Expr is TASTPrimaryExpression then if Expr is TASTBooleanConstant then with Expr as TASTBooleanConstant do Result := FBuilder.CreateConstant(Ord(Value), ltI1) else if Expr is TASTIntegerConstant then with Expr as TASTIntegerConstant do Result := FBuilder.CreateConstant(Value, ltI32) else if Expr is TASTUnaryExpression then begin UnExpr := Expr as TASTUnaryExpression; ExprCode := GenerateExpressionCode(UnExpr.Expr); case UnExpr.Op of '~': Result := FBuilder.CreateXor( FBuilder.CreateConstant(1, ltI1), ExprCode); '-': Result := FBuilder.CreateSub( FBuilder.CreateConstant(0, ltI32), ExprCode); end; end else if Expr is TASTVariableExpression then begin VarExpr := Expr as TASTVariableExpression; with VarExpr.VarDecl do Result := FBuilder.CreateVar(Ident, BaseTypeLLVMTypeMap[BaseType]); end; end; Hope you understand it :)

    Read the article

  • Jquery show function issue - not animating or showing the hidden paragraph, why

    - by dave
    Here is the html: $( document ).ready( function( ) { $( "#testing" ).click ( function( ) { $( "#testing2" ).show( "slow" ); } ); } ); Link lksjflksjdlkflskdjflksjdflkjslkjdflk lsdkflksjgliowtjlskdfjlskdfjlskgs lksjlk,.x,cmlkvjlkjlwkeoltklfnjsklkj lksjf.m,.jlkjoliwekjtlkjgkjjlkjlkjll llvalkiwujoitjlkgskjdkgjlsd,fjlsllll Here is the css: testing { width: 100px; height: 50px; border: 1px solid; font-size: 22px; display: block; text-align: center; padding: 25px 0px 0px 0px; } testing2 { display: none; width: 270px; height: 300px; background: yellow; border: 1px solid; } For some reason, when i click the link, it does not show the paragraph #testing2, why?

    Read the article

  • adding zeros in objective-c string formats

    - by Chris
    Hello- Quick question: I am trying to fill in empty spaces with a specific number of zeroes in an NSString stringWithFormat formatting string. For example, I want: @"The number is %d", 5 // I want this to output 'the number is 05' @"the number is %d", 10 // I want this to output 'the number is 10' I know how to do this in Java, but I cant seem to find the same function in objective-c. Any help would be great.

    Read the article

  • Sparse O(1) array with indices being consecutive products

    - by Kos
    Hello, I'd like to pre-calculate an array of values of some unary function f. I know that I'll only need the values for f(x) where x is of the form of a*b, where both a and b are integers in range 0..N. The obvious time-optimized choice is just to make an array of size N*N and just pre-calculate just the elements which I'm going to read later. For f(a*b), I'd just check and set tab[a*b]. This is the fastest method possible - however, this is going to take a lot of space as there are lots of indices in this array (starting with N+1) which will never by touched. Another solution is to make a simple tree map... but this slows down the lookup itself very heavily by introducing lots of branches. No. I wonder - is there any solution to make such an array less sparse and smaller, but still quick branchless O(1) in lookup?

    Read the article

  • R - find and calculate with unique combinations of values

    - by lecodesportif
    I would like to work with unique combinations of var1 and var2. foo <- data.frame(var1= c(1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4), var2=c(1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 3, 3)) As has been noted (+1 for answers), unique(foo) results in this: var1 var2 1 1 1 2 2 1 3 2 2 4 3 1 5 3 2 6 4 2 7 4 3 Based on the unique combinations, how do I get the number of occurrences of a var1 value and the sum (bla) of each var1 value's var2 values. The output could look like this: var1 n bla 1 1 1 1 2 2 2 3 3 3 2 3 4 4 2 5 edit: The question was too basic and probably duplicate so I extended it.

    Read the article

  • problem with revalidating a jframe.

    - by John Quesie
    I have this code which should take the radio button input do a little math and display a popup. which it does fine. but then it is supposed to re validate and ask the next question. when i get to the second question, the answer always comes out as the isSelected(true) value no matter which radio button you click on. SO to be clear the first time through it works fin but when the second question comes up, it just takes the default radio button every time. public class EventHandler implements ActionListener { private Main gui; public EventHandler(Main gui){ this.gui = gui; } public void actionPerformed(ActionEvent e){ String answer = ""; double val = 1; //get current answer set String [] anArr = gui.getAnswers(gui.currentStage, gui.currentQuestion); if(e.getSource() == gui.exit){ System.exit(0); } if(e.getSource() == gui.submit){ if(gui.a1.isSelected()){ answer = anArr[0]; val = gui.getScore(1); } if(gui.a2.isSelected()){ answer = anArr[1]; val = gui.getScore(2); } if(gui.a3.isSelected()){ answer = anArr[2]; val = gui.getScore(3); } if(gui.a4.isSelected()){ answer = anArr[3];; val = gui.getScore(4); } JOptionPane.showMessageDialog(null, popupMessage(answer, val), "Your Answer", 1); //compute answer here //figure out what next question is to send gui.moveOn(); gui.setQA(gui.currentStage, gui.currentQuestion); //resets gui gui.goWest(); gui.q.revalidate(); } } public String popupMessage(String ans, double val){ //displays popup after an answer has been choosen gui.computeScore(val); String text = " You Answered " + ans + " Your score is now " + gui.yourScore ; return text; } } public class Main extends JFrame { public JLabel question; public JButton exit; public JButton submit; public JRadioButton a1; public JRadioButton a2; public JRadioButton a3; public JRadioButton a4; public ButtonGroup bg; public double yourScore = 1; public int currentQuestion = 1; public String currentStage = "startup"; JPanel q; public Main(){ setTitle("Ehtics Builder"); setLocation(400,400); setLayout(new BorderLayout(5,5)); setQA("startup", 1); goNorth(); goEast(); goWest(); goSouth(); goCenter(); pack(); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } public void goNorth(){ } public void goWest(){ q = new JPanel(); q.setLayout(new GridLayout(0,1)); q.add(question); bg.add(a1); bg.add(a2); bg.add(a3); bg.add(a4); a1.setSelected(true); q.add(a1); q.add(a2); q.add(a3); q.add(a4); add(q, BorderLayout.WEST); System.out.println(); } public void goEast(){ } public void goSouth(){ JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); exit = new JButton("Exit"); submit = new JButton("Submit"); p.add(exit); p.add(submit); add(p, BorderLayout.SOUTH); EventHandler myEventHandler = new EventHandler(this); exit.addActionListener(myEventHandler); submit.addActionListener(myEventHandler); } public void goCenter(){ } public static void main(String[] args) { Main open = new Main(); } public String getQuestion(String type, int num){ //reads the questions from a file String question = ""; String filename = ""; String [] ques; num = num - 1; if(type.equals("startup")){ filename = "startup.txt"; }else if(type.equals("small")){ filename = "small.txt"; }else if(type.equals("mid")){ filename = "mid.txt"; }else if(type.equals("large")){ filename = "large.txt"; }else{ question = "error"; return question; } ques = readFile(filename); for(int i = 0;i < ques.length;i++){ if(i == num){ question = ques[i]; } } return question; } public String [] getAnswers(String type, int num){ //reads the answers from a file String filename = ""; String temp = ""; String [] group; String [] ans; num = num - 1; if(type.equals("startup")){ filename = "startupA.txt"; }else if(type.equals("small")){ filename = "smallA.txt"; }else if(type.equals("mid")){ filename = "midA.txt"; }else if(type.equals("large")){ filename = "largeA.txt"; }else{ System.out.println("Error"); } group = readFile(filename); for(int i = 0;i < group.length;i++){ if(i == num){ temp = group[i]; } } ans = temp.split("-"); return ans; } public String [] getValues(String type, int num){ //reads the answers from a file String filename = ""; String temp = ""; String [] group; String [] vals; num = num - 1; if(type.equals("startup")){ filename = "startupV.txt"; }else if(type.equals("small")){ filename = "smallV.txt"; }else if(type.equals("mid")){ filename = "midV.txt"; }else if(type.equals("large")){ filename = "largeV.txt"; }else{ System.out.println("Error"); } group = readFile(filename); for(int i = 0;i < group.length;i++){ if(i == num){ temp = group[i]; } } vals = temp.split("-"); return vals; } public String [] readFile(String filename){ //reads the contentes of a file, for getQuestions and getAnswers String text = ""; int i = -1; FileReader in = null; File f = new File(filename); try{ in = new FileReader(f); }catch(FileNotFoundException e){ System.out.println("file does not exist"); } try{ while((i = in.read()) != -1) text += ((char)i); }catch(IOException e){ System.out.println("Error reading file"); } try{ in.close(); }catch(IOException e){ System.out.println("Error reading file"); } String [] questions = text.split(":"); return questions; } public void computeScore(double val){ //calculates you score times the value of your answer yourScore = val * yourScore; } public double getScore(int aNum){ //gets the score of an answer, stage and q number is already set in the class aNum = aNum - 1; double val = 0; double [] valArr = new double[4]; for(int i = 0;i < getValues(currentStage, currentQuestion).length;i++){ val = Double.parseDouble(getValues(currentStage, currentQuestion)[i]); valArr[i] = val; } if(aNum == 0){ val = valArr[0]; } if(aNum == 1){ val = valArr[1]; } if(aNum == 2){ val = valArr[2]; } if(aNum == 3){ val = valArr[3]; } // use current stage and questiion and trhe aNum to get the value for that answer return val; } public void nextQuestion(int num){ //sets next question to use currentQuestion = num; } public void nextStage(String sta){ // sets next stage to use currentStage = sta; } public void moveOn(){ // uses the score and current question and stage to determine wher to go next and what stage to use next nextQuestion(2); nextStage("startup"); } public void setQA(String level, int num){ String [] arr = getAnswers(level, num); question = new JLabel(getQuestion(level, num)); bg = new ButtonGroup(); a1 = new JRadioButton(arr[0]); a2 = new JRadioButton(arr[1]); a3 = new JRadioButton(arr[2]); a4 = new JRadioButton(arr[3]); } }

    Read the article

  • How to parse xml with multiple, changing namespaces?

    - by sweenrace
    I have the following xml that I'm trying to parse and get the Account Data from <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns2:SearchResults xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns:ns3="http://www.intuit.com/sb/cdm/qbopayroll/v1"> <ns2:CdmCollections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Accounts"> <Account> <Id idDomain="QBO">31</Id> <SyncToken>0</SyncToken> <MetaData> <CreateTime>2010-02-16T18:03:50-08:00</CreateTime> <LastUpdatedTime>2010-02-16T18:03:50-08:00</LastUpdatedTime> </MetaData> <Name>Accounts Payable</Name> <Subtype>AccountsPayable</Subtype> <CurrentBalance>34002.00</CurrentBalance> </Account> <Account> <Id idDomain="QBO">36</Id> <SyncToken>0</SyncToken> <MetaData> <CreateTime>2011-01-11T13:24:14-08:00</CreateTime> <LastUpdatedTime>2011-01-11T13:24:14-08:00</LastUpdatedTime> </MetaData><Name>Accounts Receivable (A/R)</Name> <Subtype>AccountsReceivable</Subtype> <CurrentBalance>1125.85</CurrentBalance> </Account> </ns2:CdmCollections> <ns2:Count>10</ns2:Count> <ns2:CurrentPage>1</ns2:CurrentPage> </ns2:SearchResults> The following code sometimes work such that the I can see that children tags and values of CdmCollections. However, it doesnt always work for the same query. Looking at the raw xml I can see the namespaces change, e.g. sometimes ns2="http://www.intuit.com/sb/cdm/qbo" (works) and other times ns2 = "http://www.intuit.com/sb/cdm/v2" (doesnt work). I thought by using the namespaces array I could handle that issue but its not working. Any suggestions how I can fix this? $account_xml = new SimpleXMLElement($account_query_response); $namespaces = $account_xml->getNamespaces(true); $account_xml->registerXPathNamespace('c', $namespaces["ns2"]); $x = 0; foreach($account_xml->xpath('//c:SearchResults') as $search) { echo "<br>row " . $x; $search->registerXPathNamespace('c', $namespaces["ns2"]); var_dump($search->xpath('//c:CdmCollections')); }

    Read the article

  • How does one quickly access ruby and rails documentation when using vim?

    - by 46and2
    Hey all, What method are vim users out there using to quickly access documentation for both ruby and rails (other than switching to the browser to use ruby-doc or railsapi?). I was trying to adapt this script (http://vim.wikia.com/wiki/Online_documentation_for_word_under_cursor) to do the trick however it's only going to work if the cursor is over a class name and I'd like it to work with both class and methods. Thanks.

    Read the article

  • scraping text from multiple html files into a single csv file

    - by Lulu
    I have just over 1500 html pages (1.html to 1500.html). I have written a code using Beautiful Soup that extracts most of the data I need but "misses" out some of the data within the table. My Input: e.g file 1500.html My Code: #!/usr/bin/env python import glob import codecs from BeautifulSoup import BeautifulSoup with codecs.open('dump2.csv', "w", encoding="utf-8") as csvfile: for file in glob.glob('*html*'): print 'Processing', file soup = BeautifulSoup(open(file).read()) rows = soup.findAll('tr') for tr in rows: cols = tr.findAll('td') #print >> csvfile,"#".join(col.string for col in cols) #print >> csvfile,"#".join(td.find(text=True)) for col in cols: print >> csvfile, col.string print >> csvfile, "===" print >> csvfile, "***" Output: One CSV file, with 1500 lines of text and columns of data. For some reason my code does not pull out all the required data but "misses" some data, e.g the Address1 and Address 2 data at the start of the table do not come out. I modified the code to put in * and === separators, I then use perl to put into a clean csv file, unfortunately I'm not sure how to work my code to get all the data I'm looking for!

    Read the article

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