Search Results

Search found 1491 results on 60 pages for 'inputs'.

Page 39/60 | < Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >

  • Shuffle array variables in a pre-specified order, without using extra memory of "size of input array"

    - by Eternal Learner
    Input : A[4] = {0,4,-1,1000} - Actual Array P[4] = {1,0,3,2} - Order to be reshuffled Output: A[4] = {4,0,1000,-1} Condition : Don't use an additional array as memory. Can use an extra variable or two. Problem : I have the below program in C++, but this fails for certain inputs of array P. #include<iostream> using namespace std; void swap(int *a_r,int *r) { int temp = *r; *r = *a_r; *a_r = temp; } int main() { int A[4] = {0,4,-1,1000}; int P[4] = {3,0,1,2}; int value = A[0] , dest = P[0]; for(int i=0; i<4;i++) { swap(&A[dest],&value); dest = P[dest]; } for(int i=0;i<4;i++) cout<<A[i]<<" "; }

    Read the article

  • Whats wrong with this C program?

    - by Prab
    It should give me the number of inputs entered by the user. But it gives 100. I compiled with gcc. #include <stdio.h> int arr[100]; int count=0; int max=100; int main(){ int i, input; printf("Enter integer values one by one, q to quit.\n"); for(i=0;i<max;i++){ scanf("%d",&input); arr[i]=input; if(input=='q')break; count++; } printf("You entered %d values.\n",count); return 0; }

    Read the article

  • Retrieving Data From formData in Rails jquery-file-upload

    - by CanCeylan
    I am trying to add additional form data by using https://github.com/blueimp/jQuery-File-Upload/wiki/How-to-submit-additional-form-data this tutorial for jQuery-File-Upload plugin in my Rails app. I'm following the instructions for Setting formData on upload start for each individual file upload. My problem is, after saving the files with their titles as explained in tutorial, I cannot show them in the final table, because I don't know how to reach the formData's values. How should I reach the data inside data.formData = inputs.serializeArray(); and post them next to each item ? Thanks.

    Read the article

  • Detecting when a process has finished (but not exited)

    - by Egwor
    I have a program that's run in unix (that I have no control over) that when finished prints 'Completed successfully' but does not exit. I want to automatically detect when the process finishes (by checking the output of the command), so that I can kill the process and so that I can proceed do other activities. The complexity comes because I want to be able to run multiples of these scripts concurrently. (One activity I need to do requires the script to be called with various inputs, but each time the script runs it takes a while to return, and so I want to do them in parallel) Has anyone done something similar to this? I could redirect the stderr and stdout output of the command to a temporary file which has a random file name, then tail the file and pipe to grep for the end conditions (I.e. the certain log lines). The problem is, surely tail -f would keep running, and so it would never exit. Should I poll? If so, what's the best approach?

    Read the article

  • Best way to save info in hash

    - by qwertymk
    I have a webpage that the user inputs data into a textarea and then process and display it with some javascript. For example if the user types: _Hello_ *World* it would do something like: <underline>Hello</underline> <b>World</b> Or something like that, the details aren't important. Now the user can "save" the page to make it something like site.com/page#_Hello_%20*World* and share that link with others. My question is: Is this the best way to do this? Is there a limit on a url that I should be worried about? Should I do something like what jsfiddle does? I would prefer not to as the site would work offline if the full text would be in the hash, and as the nature of the site is to be used offline, the user would have to first cache the jsfiddle-like hash before they could use it. What's the best way to do this?

    Read the article

  • jQuery selector depending on children

    - by wiradikusuma
    Hi guys, I have an HTML form consisting of some text-inputs. I'm using jqTransform to prettify them. Now I want to add two buttons that will add and remove text-input dynamically. Adding is easy: $('#container').append(''); $('input[name=foo]:last-child').jqTransInputText(); But removing is tricky: $('WHAT-TO-SELECT').remove(); I can't do "input[name=foo]:last-child" since it's already wrapped (some divs) by jqTransform. To put this question in another way: How do I select based on "who has child of type input with 'foo' as its name"?

    Read the article

  • What is an appropriate way to programmatically exit an application?

    - by denchr
    I am evaluating user inputs as commands for my application. If the user presses Q, or q, and then hits enter, the application quits and execution terminates. Is there a proper context, or best practices on how to do that? I do not have any resources to release, or anything like that. Should I just use System.exit(0);? Is there a recommended way to do that? As my first approach I do something like this: while (true){ try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //Other logic goes here... if (br.readLine().equalsIgnoreCase("Q")){ System.exit(0); } } catch (IOException ioe) { System.out.println("IO error trying to read your selection"); } }

    Read the article

  • Looking for a jquery plugin to serialize a form to an object

    - by John
    I'm looking for a jQuery function or plugin that serializes form inputs to an object using the naming convention for deep-serialization supported by param() in jQuery 1.4: <form> <input name="a[b]" value="1"/> <input name="a[c]" value="2"/> <input name="d[]" value="3"/> <input name="d[]" value="4"/> <input name="d[2][e]" value="5"/> </form> $('form').serializeObject(); // { a: { b:1,c:2 }, d: [3,4,{ e:5 }] } Prototype's Form.serialize method can do exactly this. What's the jQuery equivalent? I found this plugin but it doesn't follow this naming convention.

    Read the article

  • Saving PHP Table as CSV

    - by user2403705
    I have been looking everywhere for a way to do this. There are a lot of people that have asked the questions but when I try myself i cant seem to get it to work. Often I get the format correct but it inputs the information into a new page instead of saving it. I did manage to get one to work for google chrome but when i ran it in internet explorer it didnt work. I have a table being created from a MYSQL query and i would like the table to be able to be saved as a CSV. Could anyone help me out?

    Read the article

  • Fractional Calculator in Java

    - by user2888881
    I am trying to create a fractional calculator in Java with inputs of mixed fractions, proper fractions, improper fractions or integers. It should include the four basic operators as well. The program should be set up as a loop where it is continuous until the user types "quit". I have coded the beginning loop but have no idea where to go from there. Please help, I am a beginner and would really appreciate it. Thank you again. This is what I have so far: import java.util.*; public class FractionCalculator { private static Scanner input; public static void main(String[] args) { input = new Scanner(System.in); String x = "quit"; System.out.println("Enter a fraction"); while (true) { String y = input.next(); if (y.equals(x)) { break; } } } }

    Read the article

  • Web Service Security java

    - by WhoAmI
    My web service was created some time back using IBM JAX-RPC. As a part of enhancement, I need to provide some security to the existing service. One way is to provide a handler, all the request and response will pass through that handler only. In the request I can implement some authentication rules for each and every application/user accessing it. Other than this, What are the possible ways for securing it? I have heard someting called wsse security for web service. Is it possible to implement it for the JAX-RPC? Or it can be implemented only for JAX-WS? Need some helpful inputs on the wsse security so that i can jump learning it. Other than handler and wsse security, any other possible way to make a service secure? Please help.

    Read the article

  • boost test case for function taking user input

    - by oadams
    I have a function that takes in user input via std::cin: std::getline(std::cin, in); and creates a corresponding data structure by matching it with a regular expression. The function then returns this data structure. I'm using boost.test and I want to create a unit test to check that the output data type is correct given some inputs. However I don't know how to go about it since the input isn't passed as an argument to the function. EDIT: Is there a simple way to create a boost test case that feeds the function a string via standard input?

    Read the article

  • ActiveMQ Message Queue Slows Down after 2 million plus message

    - by pongs
    I have a message queue named amq570queue, after accumulating 2 million messages it started to slow down. What broker settings do I need to adjust to fix this issue? I temporarily moved it into a new message queue(in the same broker) and it is working fine. I initially thought that the kahadb has reached its size limit that is why it is getting slow. Is there a way to limit the size of Message Dequeued? Thank you in advance for any inputs. Regards, Walter

    Read the article

  • Submit multiple forms as one

    - by Stephen Sarcsam Kamenar
    I have two forms on the page. To the user it looks like 1 form, and I actually wish it was one form. But the way I'm trying to reuse code and include things, I can't avoid two forms in the source code... trying to act as one. I don't want to do ajax submit, I want a normal post submit, my form handler has redirects in it. How can I submit both of these, and get values that make sense on the server side. something like $_POST['form1]['whatever'] $_POST['form2]['thing'] Maybe take all the inputs from form 2, rename all of them with a prefix, and append them to form 1? I can't find a non-messy way of doing this. I don't think I need code, just a plan. Least messy idea wins.

    Read the article

  • return type while using GMP.h header file

    - by Raveesh_Kumar
    While i m using gmp.h header file. i need a fuction which takes inputs of type mpz_t and return mpz_t type too. I m very beginner of using gmp.h So, Here is snaps follows of my approached code.... mpz_t sum_upto(mpz_t max) { mpz_t sum; mpz_init(sum); mpz_init(result); for(int i=0;i<=max-1;i++) mpz_add_ui(sum,sum,pow(2,i)); return sum; } but it will show error 1 ." pow has been not used in this scope.",although i have added math.h in very beginnig of the file. 2 . sum_upto declared as function returning an array... do tell as soon as possible. i have to complete my very big project....

    Read the article

  • C# + String Formatting

    - by user208662
    Hello, I feel like I'm trying to do something simple but I am not getting the result I want. I want to display a basic number, that will always be positive. I do not want any leading zeros but I want thousands separators. For instance, for the following inputs, I want the following outputs: 3 -> 3 30 -> 30 300 -> 300 3000 -> 3,000 30000 -> 30,000 300000 -> 300,000 Currently, in an attempt to do this, I'm using the following formatting code: string text = "*Based on " + String.Format("{0:0,0}", total) + " entries"; Currently, the output looks like this: 3 -> 03 3000 -> 3,000 You can see how a leading "0" is added when the thousands separator is not necessary. How do I properly format my numbers? Thank you

    Read the article

  • Gradient boosting predictions in low-latency production environments?

    - by lockedoff
    Can anyone recommend a strategy for making predictions using a gradient boosting model in the <10-15ms range (the faster the better)? I have been using R's gbm package, but the first prediction takes ~50ms (subsequent vectorized predictions average to 1ms, so there appears to be overhead, perhaps in the call to the C++ library). As a guideline, there will be ~10-50 inputs and ~50-500 trees. The task is classification and I need access to predicted probabilities. I know there are a lot of libraries out there, but I've had little luck finding information even on rough prediction times for them. The training will happen offline, so only predictions need to be fast -- also, predictions may come from a piece of code / library that is completely separate from whatever does the training (as long as there is a common format for representing the trees).

    Read the article

  • PHP: Remove all fcn not acting as expected, Code Inside

    - by Josh K
    I made this simple function (remove all $elem from $array): function remall($array, $elem) { for($i=0; $i < count($array); $i++) if($array[$i] == $elem) unset($array[$i]); $newarray = array_values($array); return $newarray; } But it isn't working perfectly, here are some inputs and outputs $u = array(1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7); $r = remall($u, 7); Output of $r: 12345767 $n = array(7, 7, 1, 7, 3, 4, 6, 7, 2, 3, 1, -3, 10, 11, 7, 7, 7, 2, 7); $r = remall($n, 7); Output of $r: 1346231-30117727 Notice how there are still 7s in my outputs. Also, My function will only be removing numbers from an array. Let me know if you spot something, thanks.

    Read the article

  • jquery ajax sucess - possible to return JSON instead of string?

    - by Haroldo
    To return an error from a $.ajax call, there's gotta be a better way than echoing an error in the ajax.php file and then trimming it! this seems very clumsy and in-robust: success: function(e){ var e = trim(e); if(e == 'SUCCESS') {alert('your password has been changed!');} if(e == 'ERROR1') {alert('please fill in all inputs!');} if(e == 'ERROR2') {alert('password incorrect!');} if(e == 'ERROR3') {alert('change failed!');} } what should i be doing instead?!

    Read the article

  • cant get ajax response (JSON) to call 'success' function?

    - by Haroldo
    for some reason the success function isnt being called? javscript: $.ajax({ type: 'POST', url: 'http://localhost/hf_latest_desktop/st_pages/user_area/acc_buttons/pass_change/pass_change_ajax.php', data: data, dataType: 'json', success: function(e){ console.log(e); if(e.status == 'success'){ alert('your password has been changed!'); } if(e.status == 'error1'){ alert('please fill in all inputs!'); } if(e.status == 'error2'){ alert('password incorrect!'); } if(e.status == 'error3'){ alert('change failed!'); } } }); php file ajax is calling to: <?php session_start(); session_cache_limiter('nocache'); header('Expires: ' . gmdate('r', 0)); header('Content-type: application/json'); $status = 'error1'; //for sake of example ?> {'status':'<?php echo $status; ?>'}

    Read the article

  • Artificial Intelligence Project - What language should I go for?

    - by Kremlin Yocepf
    Hi, I am a computer science student and I am going to work on an artificial intelligence project which will compose a musical tune according to the genre and mood inputs. Are the algorithms to be used for this project likely to be very resource-consuming? Would it make any difference (in terms of speed) if I choose to go with Java rather than C++? (Note : I know only these two languages and I am more comfortable with Java than C++.) NB : Sorry for my poor English. If someone can, please clean up this post wherever necessary. Thanks.

    Read the article

  • How to tell MATLAB to open and save specific files in the same directory

    - by its-me
    I have to run an image processing algorithm on numerous images in a directory. An image is saved as name_typeX.tif, so there are X different type of images for a given name. The image processing algorithm takes an input image and outputs an image result. I need to save this result as name_typeX_number.tif, where 'number' is also an output from the algorithm for a given image. Now.. How do I tell MATLAB to open a specific 'typeX' file? Also note that there are other non-tif files in the same directory. How to save the result as name_typeX_number.tif? The results have to be saved in the same directory where the input images are present. How do I tell MATLAB NOT to treat the results that have been saved as an input images? I have to run this as background code on a server... so no user inputs allowed Thanks

    Read the article

  • Explanation of NSMutableURLRequest : setHTTPMethod

    - by kkmoslehpour
    I am new to objective c programming. I am currently trying to insert data into mysql database. I have read a couple links on this and could not find the exact answer I am looking for. Here is what I am trying to do: I have my app that user inputs a name in a text field and once the press the add button, it makes a connection to my php file and my php file does the rest of the work (using POST method) and adds the name to the mysql dataase. I have seen a lot of people use NSMutableURLRequest : setHTTPMethod :POST`` in their code (in my case my php file does that and I don't haveNSMutableURLRequest` included in my code and it works perfectly fine.) My questions are: Are there any benefits of including NSMutableURLRequest in your code when you can just call your php code to take care of the POST for you? What does NSMutableURLRequest exactly do and which way is more efficient?

    Read the article

  • Implementing prompts in text-input

    - by AntonAL
    Hi, I have a form with some text-inputs: login, password. If user sees this form the first time, input-texts should "contain" prompts, like "enter login", "enter password". If user clicks text-input, it's prompt should disappear to allow typing. I have seen various examples, that uses background image with prerendered text on it. Those images are appearing with following jQuery: $("form > :text").focus(function(){ // hide image }).blur(function(){ // show image, if text-input is still empty if ( $(this).val() == "" ) // show image with prompt }); This approach has following problems: localization is impossible need to pre-render images for various textual prompts overhead with loading images How do you overcomes such a problems ?

    Read the article

  • Dynamic decision on which class to use

    - by Sirupsen
    Hello, Let's say I have a class named Klass, and a class called Klass2. Depending on the user's input, I'd like to decide whether I'll call "hello_world" on Klass, or Klass2: class Klass def self.hello_world "Hello World from Klass1!" end end class Klass2 def self.hello_world "Hello World from Klass2!" end end input = gets.strip class_to_use = input puts class_to_use.send :hello_world The user inputs "Klass2" and the script should say: Hello World from Klass2! Obviously this code doesn't work, since I'm calling #hello_world on String, but I'd like to call #hello_world on Klass2. How do I "convert" the string into a referrence to Klass2 (or whatever the user might input), or how could I else would I achieve this behavior?

    Read the article

< Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >