Search Results

Search found 34207 results on 1369 pages for 'query output'.

Page 118/1369 | < Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >

  • Ruby on Rails: having two xmlbuilder templates per action , one for errors one for regular output

    - by randombits
    What's the best way to handle having two templates (or should it be one, DRY?) for xml builder templates? I'm building a web api with Rails and wanted to see an example of how to have a view that does regular output vs one that does error output. I've been using @obj.to_xml for a while, but my requirements have changed and require me building my own error templates. do you typically have both views in one with a condition above for errors such as app/views/myresource/create.xml.builder unless @myobj.errors.empty? // xml for errors here? end // regular xml view

    Read the article

  • Redirect console input and output to a textbox.

    - by Peter
    Hi there and thanking in advance I am trying (very hard) to redirect Console input and output into a textbox. So far output is working fine but the trouble is with input. For example I cannot execute a simple program that will do the following: Console.WriteLine("Please enter your name: "); string name = Console.ReadLine(); Console.WriteLine("Hi there " + name); The reason I can't achieve this is because that the program has to stop while waiting for user to type his/her name and press enter. If I wait for user input on a new thread then the main GUI thread freezes and the textbox can never receive the KeyPress. This thing has me totally stumped. Any advice (or better still code) would be greatly appreciated. Cheers

    Read the article

  • C# UTF8 output keep encoded characters intact

    - by Stefan Pohl
    Hello, i have a very simple question I can't seem to get my head around. I have a properly encoded UTF8-String I parse into a JObject with Json.NET, fiddle around with some values and write it to the commandline, keeping the encoded characters intact. Everything works great except for the keeping the encoded characters intact part. Code: var json = "{roster: [[\"Tulg\u00f4r\", 990, 1055]]}"; var j = JObject.Parse(json); for (int i = 0; i < j["roster"].Count(); i++) { j["roster"][i][1] = ((int)j["roster"][i][1]) * 3; j["roster"][i][2] = ((int)j["roster"][i][2]) * 3; } Console.WriteLine(JsonConvert.SerializeObject(j, Formatting.None)); Actual Output: {"roster":[["Tulgôr",2970,3165]]} Desired Output: {"roster":[["Tulg\u00f4r",2970,3165]]} It seems like my phrasing in Google is inappropriate since nothing useful came up. I'm sure it's something uber-easy and i will feel pretty stupid afterwards. :)

    Read the article

  • unexpected output

    - by tech-ref
    hi, i wrote a function wich works as expected but i don't understand why the output is like that. function datatype prop = Atom of string | Not of prop | And of prop*prop | Or of prop*prop; (* XOR = (A And Not B) OR (Not A Or B) *) local fun do_xor (alpha,beta) = Or( And( alpha, Not(beta) ), Or(Not(alpha), beta)) in fun xor (alpha,beta) = do_xor(alpha,beta); end; test val result = xor(Atom "a",Atom "b"); output val result = Or (And (Atom #,Not #),Or (Not #,Atom #)) : prop thanks again (specially zeuxcg)

    Read the article

  • Preventing referenced assembly PDB and XML files copied to output

    - by Jason Morse
    I have a Visual Studio 2008 C#/.NET 3.5 project with a post build task to ZIP the contents. However I'm finding that I'm also getting the referenced assemblies' .pdb (debug) and .xml (documentation) files in my output directory (and ZIP). For example, if MyProject.csproj references YourAssembly.dll and there are YourAssembly.xml and YourAssembly.pdb files in the same directory as the DLL they will show up in my output directory (and ZIP). I can exclude *.pdb when ZIP'ing but I cannot blanket exclude the *.xml files as I have deployment files with the same extension. Is there a way to prevent the project from copying referenced assembly PDB and XML files?

    Read the article

  • Pretty output question

    - by sid_com
    Hello! #!/usr/bin/env perl use warnings; use strict; my $text = 'hello ' x 30; printf "%-20s : %s\n", 'very important text', $text; the output of this script looks more ore less like this: very important text : hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello ... but I would like an output like this: very important text: hello hello hello hello hello hello hello hello hello hello hello hello ... How could I change my script to reach my goal?

    Read the article

  • Problem with printing output using PHP library

    - by Jack
    I am using the PHP library tools on a we hosting service( with cURL enabled). I have so far tried 2 tools but I cant get the output of my code to print to the screen. http://github.com/jdp/twitterlibphp - PHP library Sample code - <?php require("twitter.lib.php"); $twitter = new Twitter("xxxx", "xxxxx"); $public_timeline = $twitter->getPublicTimeline(); echo'<pre>'; print_r( $public_timeline ); echo'</pre>'; ?> I don't get any output. What can be the problem? Do I need to install any modules or packages? Please Help

    Read the article

  • BioPython: extracting sequence IDs from a Blast output file

    - by Jon
    Hi, I have a BLAST output file in XML format. It is 22 query sequences with 50 hits reported from each sequence. And I want to extract all the 50x22 hits. This is the code I currently have, but it only extracts the 50 hits from the first query. from Bio.Blast import NCBIXM blast_records = NCBIXML.parse(result_handle) blast_record = blast_records.next() save_file = open("/Users/jonbra/Desktop/my_fasta_seq.fasta", 'w') for alignment in blast_record.alignments: for hsp in alignment.hsps: save_file.write('>%s\n' % (alignment.title,)) save_file.close() Somebody have any suggestions as to extract all the hits? I guess I have to use something else than alignments. Hope this was clear. Thanks! Jon

    Read the article

  • Unbuffered subprocess output (last line missing)

    - by plok
    I must be overlooking something terribly obvious. I need to execute a C program, display its output in real time and finally parse its last line, which should be straightforward as the last line printed is always the same. process = subprocess.Popen(args, shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE) # None indicates that the process hasn't terminated yet. while process.poll() is None: # Always save the last non-emtpy line that was output by the child # process, as it will write an empty line when closing its stdout. out = process.stdout.readline() if out: last_non_empty_line = out if verbose: sys.stdout.write(out) sys.stdout.flush() # Parse 'out' here... Once in a while, however, the last line is not printed. The default value for Popens's bufsize is 0, so it is supposed to be unbuffered. I have also tried, to no avail, adding fflush(stdout) to the C code just before exiting, but it seems that there is absolutely no need to flush a stream before exiting a program. Ideas anyone?

    Read the article

  • Have problems designing input and output for a calculator app

    - by zoul
    Hello! I am writing a button calculator. I have the code split into model, view and a controller. The model knows nothing about formatting, it is only concerned with numbers. All formatting is done in the view. The model gets its input as keypresses, each keypress is a part of an enum: typedef enum { kButtonUnknown = 0, kButtonMemoryClear = 100, kButtonMemoryPlus = 112, kButtonMemoryMinus = 109, kButtonMemoryRecall = 114, kButtonClear = 99, … }; When the user presses a button (say 1), the model receives a button code (kButtonNum1), adds the corresponding number to a string input buffer ("1") and updates the numeric output value (1.0). The controller then passes the numeric output value to the view that formats it (1). This is all plain, simple and clean, but does not really work. The problem is that when user enters a part of a number (say 0.00, going to enter 0.001), the input does not survive the way through model to view and the display says 0 instead of 0.00. I know why this happens ("0.00"::string parses to 0::double and that gets formatted as 0). What I don’t know is how to design the calculator so that the code stays clean and simple and the numbers will show up on screen exactly as the user types them. I’ve already come with some kind of solution, but that’s essentially a hack and breaks the beautiful and simple flow from the calculator model to the display. Ideas? Current solution keeps track of the calculator state. If the calculator is building a number, I take the calculator input buffer (a string) and directly set the display contents (also a string). Otherwise I take the proper path, ie. take the numeric calculator output, pass it to the view as a double and the view uses its internal formatter to create a string for the display. Example input: input | display | mode ------+---------+------------ 0 | 0 | from string 0. | 0. | from string 0.0 | 0.0 | from string 0.0+ | 0 | from number This is ugly. (1) The calculator has to expose its input buffer and state. (2) The view has to expose its display and allow setting its contents directly using a string. (3) I have to duplicate some of the formatting code to format the string I got from the calculator input buffer. If user enters 12345.000, I have to display 12,345.000 and therefore I’ve got to have a commification code for strings. Yuck.

    Read the article

  • Difference in output from use of synchronized keyword and join()

    - by user2964080
    I have 2 classes, public class Account { private int balance = 50; public int getBalance() { return balance; } public void withdraw(int amt){ this.balance -= amt; } } and public class DangerousAccount implements Runnable{ private Account acct = new Account(); public static void main(String[] args) throws InterruptedException{ DangerousAccount target = new DangerousAccount(); Thread t1 = new Thread(target); Thread t2 = new Thread(target); t1.setName("Ravi"); t2.setName("Prakash"); t1.start(); /* #1 t1.join(); */ t2.start(); } public void run(){ for(int i=0; i<5; i++){ makeWithdrawl(10); if(acct.getBalance() < 0) System.out.println("Account Overdrawn"); } } public void makeWithdrawl(int amt){ if(acct.getBalance() >= amt){ System.out.println(Thread.currentThread().getName() + " is going to withdraw"); try{ Thread.sleep(500); }catch(InterruptedException e){ e.printStackTrace(); } acct.withdraw(amt); System.out.println(Thread.currentThread().getName() + " has finished the withdrawl"); }else{ System.out.println("Not Enough Money For " + Thread.currentThread().getName() + " to withdraw"); } } } I tried adding synchronized keyword in makeWithdrawl method public synchronized void makeWithdrawl(int amt){ and I keep getting this output as many times I try Ravi is going to withdraw Ravi has finished the withdrawl Ravi is going to withdraw Ravi has finished the withdrawl Ravi is going to withdraw Ravi has finished the withdrawl Ravi is going to withdraw Ravi has finished the withdrawl Ravi is going to withdraw Ravi has finished the withdrawl Not Enough Money For Prakash to withdraw Not Enough Money For Prakash to withdraw Not Enough Money For Prakash to withdraw Not Enough Money For Prakash to withdraw Not Enough Money For Prakash to withdraw This shows that only Thread t1 is working... If I un-comment the the line saying t1.join(); I get the same output. So how does synchronized differ from join() ? If I don't use synchronize keyword or join() I get various outputs like Ravi is going to withdraw Prakash is going to withdraw Prakash has finished the withdrawl Ravi has finished the withdrawl Prakash is going to withdraw Ravi is going to withdraw Prakash has finished the withdrawl Ravi has finished the withdrawl Prakash is going to withdraw Ravi is going to withdraw Prakash has finished the withdrawl Ravi has finished the withdrawl Account Overdrawn Account Overdrawn Not Enough Money For Ravi to withdraw Account Overdrawn Not Enough Money For Prakash to withdraw Account Overdrawn Not Enough Money For Ravi to withdraw Account Overdrawn Not Enough Money For Prakash to withdraw Account Overdrawn So how does the output from synchronized differ from join() ?

    Read the article

  • Colour output piped to less

    - by mmacaulay
    Operating system: Mac OS 10.6.2 I'd like to be able to see colour output when piping certain commands through less. Two examples: I've got ls aliased to ls --color=auto, so I'd like to be able to see colour when I do this: ls -l | less I've also got the color extension turned on in Mercurial, so I'd like to see colour output from: hg diff | less and hg st | less After some googling, it seems like some versions of less support either -r or -R to make this work, but no dice for me. I can't see anything in the man page that looks like what I need. (-r or -R SEEM to be the right options, but again, they don't seem to work)

    Read the article

  • XML Output is Truncated in SQL

    - by Muhammad Akhtar
    Hi, I need to return my result set in XML and this works fine, but if the number of records are increased, my xml output is truncated here is my query select t.id,t.name,t.address from test FOR XML AUTO, ROOT('Response'), ELEMENTS However I have set some option to increase the output result set like.. Tools --> Options --> Query Results --> SQL Server --> Results to Text --> Maximum number of characters displayed in each column Tools --> Options --> Results --> Maximum characters per column but still I am unable to get my desired result. please suggest my solution Thanks....

    Read the article

  • How to format output using MATLAB's num2str

    - by Doresoom
    I'm trying to ouput an array of numbers as a string in MATLAB. I know this is easily done using num2str, but I wanted commas followed by a space to separate the numbers, not tabs. The array elements will at most have resolution to the tenths place, but most of them will be integers. Is there a way to format output so that unnecessary trailing zeros are left off? Here's what I've managed to put together: data=[2,3,5.5,4]; datastring=num2str(data,'%.1f, '); datastring=['[',datastring(1:end-1),']'] which gives the output: [2.0, 3.0, 5.5, 4.0] rather than: [2, 3, 5.5, 4] Any suggestions? EDIT: I just realized that I can use strrep to fix this by calling datastring=strrep(datastring,'.0','') but that seems even more kludgey than what I've been doing.

    Read the article

  • CUDA threads output different value

    - by kar
    HAi, I wrote a cuda program , i have given the kernel function below. The device memory is allocated through CUDAMalloc(); the value of *md is 10; __global__ void add(int *md) { int x,oper=2; x=threadIdx.x; * md = *md*oper; if(x==1) { *md = *md*0; } if(x==2) { *md = *md*10; } if(x==3) { *md = *md+1; } if(x==4) { *md = *md-1; } } executed the above code add<<<1,5>>(*md) , add<<<1,4>>>(*md) for <<<1,5>>> the output is 19 for <<<1,4>>> the output is 21 1) I have doubt that cudaMalloc() will allocate in device main memory? 2) Why the last thread alone is executed always in the above program? Thank you

    Read the article

  • Exclude category from custom taxonomy output

    - by Nordin
    Hello, I'm using the query below to output all links from a custom taxonomy. It outputs all posts that are tagged 'http' from the taxonomy 'words'. I would like to exclude some general categories from the output. So, fe. it only outputs links in the media and news categories. What would be the best way to achieve this. $wp_query->request = " SELECT DISTINCT * FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) WHERE $wpdb->posts.post_type = 'post' AND $wpdb->posts.post_status = 'publish' AND $wpdb->term_taxonomy.taxonomy = 'words' AND $wpdb->terms.slug = 'http' ORDER BY $wpdb->posts.post_date DESC LIMIT $ppp OFFSET $offset"; $pagelinkposts = $wpdb->get_results($wp_query->request, OBJECT);

    Read the article

  • Rails 3 time output

    - by Oluf Nielsen
    Hi, I'm now working on my output of the feeds I'm taking in from some site. What I'm currently doing is Time, and i want it to be displayed in a maybe, little be special way.. like this.. today, 14:12 yesterday, 15:34 27/12, 15:24 i have this in my code = news.entry_published.strftime("%d/%m, %H:%M") That gives me an error saying undefined method `strftime' for "2010-12-30 19:26:00.000000":String And it dosn't do what i want with the days.. Edit: - @date = DateTime.strptime(news.entry_published, "%Y-%m-%d %H:%M:%S") = @date.strftime("%d/%m, %H:%M") Now works, and gives this output 30/12, 19:26 But i still have to check if it is today, yesterday or just another day. Cheers, Oluf.

    Read the article

  • symfony sfValidatorSchemaCompare and dateformat output problem

    - by Gerbrand
    public function configure() { $this->widgetSchema['start_date'] = new sfWidgetFormInput(); $this->widgetSchema['end_date'] = new sfWidgetFormInput(); $this->validatorSchema->setPostValidator( new sfValidatorOr ( array( new sfValidatorAnd( array (new sfValidatorSchemaCompare('start_date', sfValidatorSchemaCompare::NOT_EQUAL, null), new sfValidatorSchemaCompare('end_date', sfValidatorSchemaCompare::EQUAL, null) )), new sfValidatorSchemaCompare('start_date', sfValidatorSchemaCompare::LESS_THAN_EQUAL, 'end_date', array('throw_global_error' => false), array('invalid' => 'The start date ("%left_field%") must be before the end date ("%right_field%")'))))); } I've got following input dates which I want to check if the end date isn't before the start date: Input: Start = 31/03/10 End= 07/03/10 Output: The start date (2010-03-31) must be before the end date (2010-03-07) Can you in some way change the date output? I need the error message to set the date format the same as the input. Also my input fields are set with the wrong date format when the error appears. Tried several things, but no luck at this moment. Didn't find a solution or information on symfony it self. I'm using symfony version 1.2.11

    Read the article

  • 'client_errors' warning in output from cron job that runs PHP on GoDaddy

    - by Kevin
    Hi. I have several cron jobs that I've set up on my GoDaddy hosting account through their control panel. The commands look like this: /web/cgi-bin/php5 "$HOME/html/myfolder/cron_do_stuff.php" The jobs runs as scheduled, and the scripts work perfectly, and the output from the scripts always gets sent to my email address. I would love a way to disable this (since the PHP script can send it's own emails if it's necessary). But my real question is about the output, which always contains this on the first line: /web/cgi-bin/php5: Symbol `client_errors' has different size in shared object, consider re-linking Looks like a server configuration error to me, and after talking with GoDaddy they said it's a benign warning and not to worry about it. I was just curious if anyone had ideas for fixing it.

    Read the article

  • cURL - put output into variable?

    - by Mike
    Hi, I'm currently using this C code: CURL *curl; CURLcode res; curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://my-domain.org/"); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } It prints the output on the console. How can I get the same output, but read it into, say, a string? (This is a probably a basic question, but I do not yet understand the libcurl API...) Thanks for any help! Mike

    Read the article

< Previous Page | 114 115 116 117 118 119 120 121 122 123 124 125  | Next Page >