Daily Archives

Articles indexed Tuesday November 12 2013

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

  • How does a segment based rendering engine work?

    - by Calmarius
    As far as I know Descent was one of the first games that featured a fully 3D environment, and it used a segment based rendering engine. Its levels are built from cubic segments (these cubes may be deformed as long as it remains convex and sides remain roughly flat). These cubes are connected by their sides. The connected sides are traversable (maybe doors or grids can be placed on these sides), while the unconnected sides are not traversable walls. So the game is played inside of this complex. Descent was software rendered and it had to be very fast, to be playable on those 10-100MHz processors of that age. Some latter levels of the game are huge and contain thousands of segments, but these levels are still rendered reasonably fast. So I think they tried to minimize the amount of cubes rendered somehow. How to choose which cubes to render for a given location? As far as I know they used a kind of portal rendering, but I couldn't find what was the technique used in this particular kind of engine. I think the fact that the levels are built from convex quadrilateral hexahedrons can be exploited.

    Read the article

  • DirectX11 Swap Chain Format

    - by Nathan
    I was wondering if anyone could elaborate any further on something thats been bugging be me. In DirectX9 the main supported back buffer formats were D3DFMT_X8R8B8G8 and D3DFMT_A8R8G8B8 (Both being BGRA in layout). http://msdn.microsoft.com/en-us/library/windows/desktop/bb174314(v=vs.85).aspx With the initial version of DirectX10 their was no support for BGRA and all the textbooks and online tutorials recommend DXGI_FORMAT_R8G8B8A8_UNORM (being RGBA in layout). Now with DirectX11 BGRA is supported again and it seems as if microsoft recommends using a BGRA format as the back buffer format. http://msdn.microsoft.com/en-us/library/windows/apps/hh465096.aspx Is their any suggestions or are their performance implications of using one or the other. (I assume not as obviously by specifying the format of the underlying resource the runtime will handle what bits your passing through and than infer how to utilise them based on the format). Any feedback is appreciated.

    Read the article

  • Appending a TR to Table Not Formatting Correctly

    - by TimNguyenBSM
    My PHP script is sending back an array: $currentStatus = ( isset( $status ) ) ? "1" : "0"; $html = "<tr><td>" . $email . "</td><td>" . ( ( $status->type == 0 ) ? "View Only" : ( ( $status->type == 1 ) ? "View & Mark" : "View, Mark & Edit" ) ) . "</td><td>Invited</td></tr>"; echo json_encode( array( $html, $currentStatus ) ); Then my jquery is appending this to the table: ... success: function( result ) { var resultArray = eval( result ); $( "#myTable tr:last").append( resultArray[0] ); ... } Problem is, when it prints, it prints the following extra marks: [email protected]<\/td> View Only<\/td> Invited<\/td><\/tr>","1"] If I only echo the HTML it appends to table just fine, but I cant do that because I need the $currentStatus back too to do something with it. Thanks!

    Read the article

  • window.requestFileSystem fails/events firing multiple times in PhoneGap Cordova 3

    - by ezycheez
    cordova 3.1.0-0.2.0 Droid Razr M Android 4.1.2 Windows 7 New to PhoneGap/Cordova. Running one of the filesystem demos from http://docs.phonegap.com/en/3.1.0/cordova_file_file.md.html#File. Using "cordova run android" to compile the code and run it on the phone attached via USB. Problem #1: When the app first starts I get alert("1") twice and then nothing else. Problem #2: When I kick of the code via the button onclick I get the following alert pattern: 1, 2, 2, 3, 3, 4, 6, 5, 7, 4, 6, 5, 7. Some of that makes sense based on the code flow but most of them are firing twice. I'm suspecting problem #2 is being caused by some asynchronous calls hanging out from the first attempt but no matter how long I wait those events don't fire until I kick of the code via the button. So why is the requestFileSystem call failing even though it is waiting for deviceready and why is the other code getting intermingled? Any thoughts are appreciated. <!DOCTYPE html> <html> <head> <title>FileReader Example</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> // Wait for device API libraries to load // document.addEventListener("deviceready", onDeviceReady, false); // device APIs are available // function onDeviceReady() { alert("1"); window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); } function gotFS(fileSystem) { alert("2"); fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail); } function gotFileEntry(fileEntry) { alert("3"); fileEntry.file(gotFile, fail); } function gotFile(file) { alert("4"); readDataUrl(file); alert("5"); readAsText(file); } function readDataUrl(file) { alert("6"); var reader = new FileReader(); reader.onloadend = function (evt) { console.log("Read as data URL"); console.log(evt.target.result); }; reader.readAsDataURL(file); } function readAsText(file) { alert("7"); var reader = new FileReader(); reader.onloadend = function (evt) { console.log("Read as text"); console.log(evt.target.result); }; reader.readAsText(file); } function fail(error) { alert("8"); console.log(error.code); } </script> </head> <body> <h1>Example</h1> <p>Read File</p> <button onclick="onDeviceReady();">Read File</button> </body> </html>

    Read the article

  • How do I do event handling in php with html?

    - by TheAmazingKnight
    I am constructing a simple quiz using html and php. The problem I'm having is that I'm not sure how to do event handlers since it's my first time doing php. Simply, the user click on Take Quiz and it brings up the quiz, then submit the quiz using the same page and show score results. The quiz was written in HTML as shown below: HTML CODE: <section> <h1 id="theme"><span class="initial">Q</span>uiz</h1> <div id="message">Why not go ahead and take the quiz to test your knowledge based on what you've learned in Smartphone Photography. There are only 5 questions surrounding the content of this site. Good Luck! :) <br/> <button type="button" name="name" onclick="takeQuiz()">Take Quiz!</button> </div> </section> </div> <form action="grade.php" method="post" id="quiz"> <!--Question 1--> <h3>1. How many percent of modern camera phones use CMOS?</h3> <div> <input type="radio" name="question-1-answers" id="question-1-answers-A" value="A" /> <label for="question-1-answers-A">A) 20%</label> <br/> <input type="radio" name="question-1-answers" id="question-1-answers-B" value="B" /> <label for="question-1-answers-B">B) 80%</label> <br/> <input type="radio" name="question-1-answers" id="question-1-answers-C" value="C" /> <label for="question-1-answers-C">C) 50%</label> <br/> <input type="radio" name="question-1-answers" id="question-1-answers-D" value="D" /> <label for="question-1-answers-D">D) 90%</label> </div> <!--Question 2--> <h3>2. Which type of camera setting(s) is best for greater control and flexibility in terms of focusing on a subject?</h3> <div> <input type="radio" name="question-2-answers" id="question-2-answers-A" value="A" /> <label for="question-2-answers-A">A) Manual Focus</label> <br/> <input type="radio" name="question-2-answers" id="question-2-answers-B" value="B" /> <label for="question-2-answers-B">B) Auto Focus</label> <br/> <input type="radio" name="question-2-answers" id="question-2-answers-C" value="C" /> <label for="question-2-answers-C">C) Both A and B</label> <br/> <input type="radio" name="question-2-answers" id="question-2-answers-D" value="D" /> <label for="question-2-answers-D">D) Neither</label> </div> <!--Question 3--> <h3>3. What are the three properties included in an exposure triangle?</h3> <div> <input type="radio" name="question-3-answers" id="question-3-answers-A" value="A" /> <label for="question-3-answers-A">A) White Balance, ISO, Low Light</label> <br/> <input type="radio" name="question-3-answers" id="question-3-answers-B" value="B" /> <label for="question-3-answers-B">B) Shutter Speed, Exposure, ISO</label> <br/> <input type="radio" name="question-3-answers" id="question-3-answers-C" value="C" /> <label for="question-3-answers-C">C) Aperture, ISO, Exposure</label> <br/> <input type="radio" name="question-3-answers" id="question-3-answers-D" value="D" /> <label for="question-3-answers-D">D) ISO, Aperture, Shutter Speed</label> </div> <!--Question 4--> <h3>4. The higher the ISO, the more noise it produces in an image.</h3> <div> <input type="radio" name="question-4-answers" id="question-4-answers-A" value="A" /> <label for="question-4-answers-A">A) True</label> <br/> <input type="radio" name="question-4-answers" id="question-4-answers-B" value="B" /> <label for="question-4-answers-B">B) False</label> </div> <!--Question 5--> <h3>5. What is the name of the smartphone you've seen all over this site?</h3> <div> <input type="radio" name="question-5-answers" id="question-5-answers-A" value="A" /> <label for="question-5-answers-A">A) Nokia Pureview 808</label> <br/> <input type="radio" name="question-5-answers" id="question-5-answers-B" value="B" /> <label for="question-5-answers-B">B) Nokia Lumia 1020</label> <br/> <input type="radio" name="question-5-answers" id="question-5-answers-C" value="C" /> <label for="question-5-answers-C">C) Nokia Lumia 925</label> <br/> <input type="radio" name="question-5-answers" id="question-5-answers-D" value="D" /> <label for="question-5-answers-D">D) Nokia Lumia 920</label> </div> <input type="submit" value="Submit Quiz" /> </form> Then I have a php file named grade.php which will print the results of the quiz grade. PHP CODE: <?php // create variables linking the questions' answers from the form $answer1 = $_POST['question-1-answers']; $answer2 = $_POST['question-2-answers']; $answer3 = $_POST['question-3-answers']; $answer4 = $_POST['question-4-answers']; $answer5 = $_POST['question-5-answers']; $totalCorrect = 0; // Set up if-statements and determine the correct answers to be POSTed if($answer1 == "D") { $totalCorrect++; } if($answer2 == "A") { $totalCorrect++; } if($answer3 == "D") { $totalCorrect++; } if($answer4 == "A") { $totalCorrect++; } if($answer5 == "B") { $totalCorrect++; } //display the results echo "<div id='results'>$totalCorrect / 5 correct</div>"; ?>

    Read the article

  • AVPlayer seeking to a different point after app resume

    - by CGuess
    I have an AVPlayer, the video in it is ~2 seconds long. After the video plays, if the app goes to the background and reenters the foreground I need the video to still be shown exactly as it was when the app was exited. The AVPlayer sticks around just fine, however when I reenter the app from the background the video appears to be seeked to the middle of the video. However, if I just play the video, it starts from the beginning, so it doesn't seem like it actually seeked and is just showing a preview image. I've tried to auto-seek the video to the end on relaunch but nothing happens . Nothing I can figure out or find in the docs would describe this behavior. Any tips on having the video launch either at the beginning or end?

    Read the article

  • Array as struct database?

    - by user2985179
    I have a struct that reads data from the user: typedef struct { int seconds; } Time; typedef struct { Time time; double distance; } Training; Training input; scanf("%d %lf", input.time.seconds, input.distance); This scanf will be looped and the user can input different data every time, I want to store this data in an array for later use. I THINK I want something like arr[0].seconds and arr[0].distance. I tried to store the entered data in an array but it didn't really work at all... Training data[10]; data[10].seconds = input.time.seconds; data[10].distance = input.distance; The data will wipe when the program closes and that's how I like it to be. So I want it to be stored in an array, no files or databases!

    Read the article

  • Compile error with initializer_list when trying to use it to initialize member value of class

    - by ilektron
    I am trying to make a class initializable from an initialization_list in a class constructor's constructor's initialization list. It works for a std::map, but not for my custom class. I don't see any difference other than templates are used in std::map. #include <iostream> #include <initializer_list> #include <string> #include <sstream> #include <map> using std::string; class text_thing { private: string m_text; public: text_thing() { } text_thing(text_thing& other); text_thing(std::initializer_list< std::pair<const string, const string> >& il); text_thing& operator=(std::initializer_list< std::pair<const string, const string> >& il); operator string() { return m_text; } }; class static_base { private: std::map<string, string> m_test_map; text_thing m_thing; static_base(); public: static static_base& getInstance() { static static_base instance; return instance; } string getText() { return (string)m_thing; } }; typedef std::pair<const string, const string> spair; text_thing::text_thing(text_thing& other) { m_text = other.m_text; } text_thing::text_thing(std::initializer_list< std::pair<const string, const string> >& il) { std::stringstream text_gen; for (auto& apair : il) { text_gen << "{" << apair.first << ", " << apair.second << "}" << std::endl; } } text_thing& text_thing::operator=(std::initializer_list< std::pair<const string, const string> >& il) { std::stringstream text_gen; for (auto& apair : il) { text_gen << "{" << apair.first << ", " << apair.second << "}" << std::endl; } return *this; } static_base::static_base() : m_test_map{{"test", "1"}, {"test2", "2"}}, // Compiler fine with this m_thing{{"test", "1"}, {"test2", "2"}} // Compiler doesn't like this { } int main() { std::cout << "Starting the program" << std::endl; std::cout << "The text thing: " << std::endl << static_base::getInstance().getText(); } I get this compiler output g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"static_base.d" -MT"static_base.d" -o "static_base.o" "../static_base.cpp" Finished building: ../static_base.cpp Building file: ../test.cpp Invoking: GCC C++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"test.d" -MT"test.d" -o "test.o" "../test.cpp" ../test.cpp: In constructor ‘static_base::static_base()’: ../test.cpp:94:40: error: no matching function for call to ‘text_thing::text_thing(<brace-enclosed initializer list>)’ m_thing{{"test", "1"}, {"test2", "2"}} ^ ../test.cpp:94:40: note: candidates are: ../test.cpp:72:1: note: text_thing::text_thing(std::initializer_list<std::pair<const std::basic_string<char>, const std::basic_string<char> > >&) text_thing::text_thing(std::initializer_list< std::pair<const string, const string> >& il) ^ ../test.cpp:72:1: note: candidate expects 1 argument, 2 provided ../test.cpp:67:1: note: text_thing::text_thing(text_thing&) text_thing::text_thing(text_thing& other) ^ ../test.cpp:67:1: note: candidate expects 1 argument, 2 provided ../test.cpp:23:2: note: text_thing::text_thing() text_thing() ^ ../test.cpp:23:2: note: candidate expects 0 arguments, 2 provided make: *** [test.o] Error 1 Output of gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.1-2ubuntu1~13.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~13.04) It compiles fine with the std::map constructed this way, and if I modify the static_base to return the strings from the maps, all is fine and dandy. Please help me understand what is going on here.

    Read the article

  • undefined local variable or method `user', using CarrierWave for profile images

    - by Amar H-V
    I've been following Ryan Bates' Railscasts tutorial on CarrierWave, which you can find here Everything works fine, except for when I go to view my profile, it gives me this error: undefined local variable or method `user' I don't know why it is telling me this, as I am using Devise for my authentication, and that is the name of my model. Below are some of the files which may be useful: https://gist.github.com/amarh21/7439421 I am using Rails 4.0.1 and ruby 2.0.0

    Read the article

  • Inverse Factorial Function (Prolog)

    - by user2796815
    I have to write a Prolog program to computer the inverse of factorial function without using division. I was also given the note: "the inverse of a function is not necessarily a function". I have this is a normal factorial predicate.. fact(0,1). fact(N,F) :- N0, N1 is N-1, fact(N1,F1), F is N * F1. I've read on some other posts that you should be able to just switch around the arguments, but that doesn't seem to be the case with this version. Could anyone help me out with figuring out why?

    Read the article

  • Resources for dashboard app backend design

    - by Nix
    I am looking for examples of code/data/infrastructure design for a dashboard-style webapp. I am designing an interface for staff and faculty at a university to access departmental resources and be alerted of cyclical processes, events, deadlines, etc. Technologies I am working with: apache tomcat 6 and a mySQL database, JSP (including JSTL), bootstrap 3, and javascript/jquery. I have basic experience most of these technologies building smaller web apps but was hoping someone could direct me towards a book or other resource that discusses how to design the db architecture (and maybe how to template) for a dashboard, esp. for something like a notification systems. Any suggestions?

    Read the article

  • how to make a javascript number keypad popup

    - by user2434653
    i have a website with 3 pages. each page has a form with two input fields. i am trying to make a popup number-keypad that will populate what ever input field called it. below is that base code i keep coming back to. <html> <head><title>test</title></head> <body> <script> function num(id) { return document.getElementById(id); } </script> <form action="/unitPage" method="POST" style=" text-align:center;"> Prefix: <input id="num" name"prefix" type="text" onfocus="num('keypad').style.display='inline-block';"/> Number: <input id="num" name"number" type="text" pattern="[0-9]{6}" onfocus="num('keypad').style.display='inline-block';"/> </form> <div id="keypad" style="display:none; background:#AAA; vertical-align:top;"> <input type="button" value="7" onclick="num('num').value+=7;"/> <input type="button" value="8" onclick="num('num').value+=8;"/> <input type="button" value="9" onclick="num('num').value+=9;"/><br/> <input type="button" value="4" onclick="num('num').value+=4;"/> <input type="button" value="5" onclick="num('num').value+=5;"/> <input type="button" value="6" onclick="num('num').value+=6;"/><br/> <input type="button" value="1" onclick="num('num').value+=1;"/> <input type="button" value="2" onclick="num('num').value+=2;"/> <input type="button" value="3" onclick="num('num').value+=3;"/><br/> <input type="button" value="X" onclick="num('keypad').style.display='none'"/> <input type="button" value="0" onclick="num('num').value+=0;"/> <input type="button" value="&larr;" onclick="num('num').value=num('num').value.substr(0,num('num').value.length-1);"/> </div> </body> </html> is there a way of making one number key pad that i call from any page or do i need to make the above for each input? thanks

    Read the article

  • Validating String Characters as Numeric w/ Pascal (FastReport 4)

    - by user2525015
    I'm new to Pascal and FastReport. This question can probably be answered without knowledge of FastReport. Pascal is Delphi. FastReport4. I have a text box accepting an 8 character string as input. Each character should be numeric. I'm attempting to validate each character as numeric. I've tried using the val function... Procedure Val(S : String; var R: Real; Code : Integer); begin end; procedure thisinputOnChange(Sender: TfrxComponent); var S : String; error : Integer; R : Real; begin S := thisinput.lines.text; Val (S, R, error); If error > 0 then Button2.enabled := False; end; I got this code online. The explanation says that the function will return an error with a code greater than zero if the character cannot be converted to an integer. Is that explanation correct? Am I misinterpreting? Right now I am trying to set a button's enabled property to false if the validation fails. I might change that to a message. For now, I would like to get it to work by setting the button property. I'm not sure if I should be using the onChange event or another event. I'm also not sure if I need to send the input to the val function in a loop. Like I said, I'm just learning how to use this function. I am able to validate the length. This code works... procedure thisinputOnChange(Sender: TfrxComponent); begin if length(thisinput.lines.text) = 8 then Button2.enabled := True; end; Any suggestions? Should I use the val function or something else? Let me know if I need to provide more info. I might not be able to check back until later, though. Thanks for any help.

    Read the article

  • Merge array in a different way in PHP

    - by user2984974
    I have these two arrays: $array1 = array( '0' => 'apple', '1' => '' , '2' => 'cucumber' ); $array2 = array( '0' => '', '1' => 'bmw', '2' => 'chrysler' ); if I do this to merge these arrays: $result_arr = array_merge($array1, $array2); print_r( count ( array_filter($result_arr) ) ); the output would be 4. However, I need to get the number 3. So, when there are two things on the same position (same key) count it only once. Is it possible to merge/count elements in arrays like that?

    Read the article

  • how could it works if function is called before it is defined in python?

    - by user2131316
    I was wondering what does if __name__ == "__main__": really do in python, I have the following code in python3: def main(): test(); def test(): print("hello world " + __name__); if __name__ == "__main__": main(); we know that we have to declare a function before we use it, so function call inside of if part works fine, the main() is defined before it is called inside of if statement, but what about the test() function, it is defined after it is called and there is no errors: def main(): test(); def test(): print("hello world " + __name__); so how could it works if the test() function is defined after it is called?

    Read the article

  • Contact form with php-script does not work

    - by elajjas
    I'm new to the forum and I have been trying to find a thread that could be helpful but nothing have been working out so far. I recently uploaded my site via FTP, and it works fine. Except for one thing, my contact form. The contact form is crucial and it is almost the whole point of the website. I don't get any emails "from the form", either in my spam-folder or inbox. Please have a look at the website which is: http://www.adspot.se The contact form is situated on: http://www.adspot.se/contact.html The php script looks like this: <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; mail("[email protected]", $name, $message, "From:" . $email); } ?> I've already tried different types of php-scripts, but it still doesn't seem to work. UPDATE: Changed the form code to: <form method="POST" action="email.php"> <div class="row half"> <div class="6u"> <input name="name" placeholder="Name" type="text" class="text" /> </div> <div class="6u"> <input name="email" placeholder="Email" type="text" class="text" /> </div> </div> <div class="row half"> <div class="12u"> <textarea name="message" placeholder="Message"></textarea> </div> </div> <div class="row half"> <div class="12u"> <ul class="action"> <input type="submit" class="action"> </ul> </div> </div> </form> Now it redirects me to www.adspot.se/email.php but still no emails received...

    Read the article

  • Performance in backpropagation algorithm

    - by Taban
    I've written a matlab program for standard backpropagation algorithm, it is my homework and I should not use matlab toolbox, so I write the entire code by myself. This link helped me for backpropagation algorithm. I have a data set of 40 random number and initial weights randomly. As output, I want to see a diagram that shows the performance. I used mse and plot function to see performance for 20 epochs but the result is this: I heard that performance should go up through backpropagation, so I want to know is there any problem with my code or this result is normal because local minimums. This is my code: Hidden_node=inputdlg('Enter the number of Hidden nodes'); a=0.5;%initialize learning rate hiddenn=str2num(Hidden_node{1,1}); randn('seed',0); %creating data set s=2; N=10; m=[5 -5 5 5;-5 -5 5 -5]; S = s*eye(2); [l,c] = size(m); x = []; % Creating the training set for i = 1:c x = [x mvnrnd(m(:,i)',S,N)']; end % target value toutput=[ones(1,N) zeros(1,N) ones(1,N) zeros(1,N)]; for epoch=1:20; %number of epochs for kk=1:40; %number of patterns %initial weights of hidden layer for ii=1 : 2; for jj=1 :hiddenn; whidden{ii,jj}=rand(1); end end initial the wights of output layer for ii=1 : hiddenn; woutput{ii,1}=rand(1); end for ii=1:hiddenn; x1=x(1,kk); x2=x(2,kk); w1=whidden{1,ii}; w2=whidden{2,ii}; activation{1,ii}=(x1(1,1)*w1(1,1))+(x2(1,1)*w2(1,1)); end %calculate output of hidden nodes for ii=1:hiddenn; hidden_to_out{1,ii}=logsig(activation{1,ii}); end activation_O{1,1}=0; for jj=1:hiddenn; activation_O{1,1} = activation_O{1,1}+(hidden_to_out{1,jj}*woutput{jj,1}); end %calculate output out{1,1}=logsig(activation_O{1,1}); out_for_plot(1,kk)= out{1,ii}; %calculate error for output node delta_out{1,1}=(toutput(1,kk)-out{1,1}); %update weight of output node for ii=1:hiddenn; woutput{ii,jj}=woutput{ii,jj}+delta_out{1,jj}*hidden_to_out{1,ii}*dlogsig(activation_O{1,jj},logsig(activation_O{1,jj}))*a; end %calculate error of hidden nodes for ii=1:hiddenn; delta_hidden{1,ii}=woutput{ii,1}*delta_out{1,1}; end %update weight of hidden nodes for ii=1:hiddenn; for jj=1:2; whidden{jj,ii}= whidden{jj,ii}+(delta_hidden{1,ii}*dlogsig(activation{1,ii},logsig(activation{1,ii}))*x(jj,kk)*a); end end a=a/(1.1);%decrease learning rate end %calculate performance e=toutput(1,kk)-out_for_plot(1,1); perf(1,epoch)=mse(e); end plot(perf); Thanks a lot.

    Read the article

  • Improve Efficiency in Array comparison in Ruby

    - by user2985025
    Hi I am working on Ruby /cucumber and have an requirement to develop a comparison module/program to compare two files. Below are the requirements The project is a migration project . Data from one application is moved to another Need to compare the data from the existing application against the new ones. Solution : I have developed a comparison engine in Ruby for the above requirement. a) Get the data, de duplicated and sorted from both the DB's b) Put the data in a text file with "||" as delimiter c) Use the key columns (number) that provides a unique record in the db to compare the two files For ex File1 has 1,2,3,4,5,6 and file2 has 1,2,3,4,5,7 and the columns 1,2,3,4,5 are key columns. I use these key columns and compare 6 and 7 which results in a fail. Issue : The major issue we are facing here is if the mismatches are more than 70% for 100,000 records or more the comparison time is large. If the mismatches are less than 40% then comparison time is ok. Diff and Diff -LCS will not work in this case because we need key columns to arrive at accurate data comparison between two applications. Is there any other method to efficiently reduce the time if the mismatches are more thatn 70% for 100,000 records or more. Thanks

    Read the article

  • How do I create a "global variable" in Java such that all classes can access it?

    - by Chrystle Soh
    here's my problem: I have multiple classes that are part of the same package and they need access to a certain file path String filePath = "D:/Users/Mine/School/Java/CZ2002_Assignment/src/" Rather than declaring the same Filepath in every single class, is it possible to simply have a "global" type of variable of this FilePath so that all classes can access it and I only need to declare and update it once. Thanks

    Read the article

  • Navigation bar(s) disappear when the window gets too small

    - by Leron
    The title maybe is a little misleading but I'm not 100% sure how this effect is called. I'm pretty sure what I meant is that my navigation bar is disappearing instead of collapsing. However my set up is this - I am working on the Layout view of ASP.NET MVC 4 project. I'm using bootstrap 3x but also have included jQuery libs so my <head> part is like this: @Scripts.Render("~/Scripts/bootstrap.min.js") @Styles.Render("~/Content/bootstrap.css") @Styles.Render("~/Content/themes/base/jquery.ui.smoothness.css") @Scripts.Render("~/Scripts/jquery-2.0.3.min.js") @Scripts.Render("~/Scripts/jquery-ui-1.10.3.min.js") //just skipped the standard stuff In the body I want to have two navbars and one side menu which will be the same for all my pages but I've noticed that when I start to narrow the window at some point instead of getting an effect similar to this example (noticed how the elements get repositioned) I just got both my navbars gone, I can't see them. The markup for my first navbar is this : <div class="navbar navbar-static-top navbar-inverse navbar-collapse collapse" role="navigation"> <ul class="nav navbar-nav "> <li><a href="#">Info</a></li> <li><a href="#">Info</a></li> </ul> </div> and the second one is : <div class="navbar navbar-collapse collapse" role="navigation" id="main-navigation-bar"> <ul class="nav nav-pills nav-justified"> <li style="border: 1px solid grey"><a href="#">Link</a></li> <li><a href="#">Link</a></li> <li><a href="#">Link</a></li> </ul> In fact the only thing left in my _Layout body is this: <div class="container-fluid"> @RenderBody() </div> which is just for compiling purposes and renders this view : <p>1</p> <p>2</p> <p>3</p> <p>4</p> <p>5</p> So when I make the window small enough so that my navbars disappear the only thing left is 1..5 numbers from the rendered view. I tested with only one navbar (commented the other) - no matter which one is commented, when I narrow the window I loose the navbar. How can I keep them using bootstrap 3x?

    Read the article

  • jQuery hold form submit until "continue" button pressed

    - by Seán McCabe
    I am trying to submit a form, which I have had working, but have now modified it to include a modal jQuery UI box, so that it won't submit until the user presses "continue". I've had various problems with this, including getting the form to hold until that button is pressed, but I think I have found a solution to that, but implementing it, I am getting a SyntaxError which I can't find the source of. With the help of kevin B managed to find the answer was the form was submitting, but the returned JSON response wasn't quite formatted right. The response was that the form wasn't being submitted, so that problem is still occurring. So updated the code with the provided feedback, now need to find out why the form isnt submitting. I know its something to do with the 2nd function isnt recognising the submit button has been pressed, so need to know how to submit that form data without the form needing to be submitted again. Below is the new code: function submitData() { $("#submitProvData").submit(function(event) { event.preventDefault(); var gTotal, sTotal, dfd; var dfd = new $.Deferred(); $('html,body').animate({ scrollTop: 0 }, 'fast'); $("#submitProvData input").css("border", "1px solid #aaaaaa"); $("#submitProvData input[readonly='readonly']").css("border", "none"); sTotal = $('#summaryTotal').val(); gTotal = $('#gptotal').val(); if(gTotal !== 'sTotal'){ $("#newsupinvbox").append('<div id="newsupinvdiagbox" title="Warning - Totals do not match" class="hidden"><p>Press "Continue", to submit the invoice flagged for attention.</p> <br /><p class="italic">or</p><br /> <p>Press "Correct" to correct the discrepancy.</p></div>') //CREATE DIV //SET $("#newsupinvdiagbox").dialog({ resizable: false, autoOpen:false, modal: true, draggable: false, width:380, height:240, closeOnEscape: false, position: ['center',20], buttons: { 'Continue': function() { $(this).dialog('close'); reData(); }, // end continue button 'Correct': function() { $(this).dialog('close'); return false; } //end cancel button }//end buttons });//end dialog $('#newsupinvdiagbox').dialog('open'); } return false; }); } function reData() { console.log('submitted'); $("#submitProvData").submit(function(resubmit){ console.log('form submit'); var formData; formData = new FormData($(this)[0]); $.ajax({ type: "POST", url: "functions/invoicing_upload_provider.php", data: formData, async: false, success: function(result) { $.each($.parseJSON(result), function(item, value){ if(item == 'Success'){ $('#newsupinv_window_message_success_mes').html('The provider invoice was uploaded successfully.'); $('#newsupinv_window_message_success').fadeIn(300, function (){ reset(); }).delay(2500).fadeOut(700); } else if(item == 'Error'){ $('#newsupinv_window_message_error_mes').html(value); $('#newsupinv_window_message_error').fadeIn(300).delay(3000).fadeOut(700); } else if(item == 'Warning'){ $('#newsupinv_window_message_warning_mes').html(value); $('#newsupinv_window_message_warning').fadeIn(300, function (){ reset(); }).delay(2500).fadeOut(700); } }); }, error: function() { $('#newsupinv_window_message_error_mes').html("An error occured, the form was not submitted"); $('#newsupinv_window_message_error').fadeIn(300); $('#newsupinv_window_message_error').delay(3000).fadeOut(700); }, cache: false, contentType: false, processData: false }); }); }

    Read the article

  • Get data on jquery ajax success

    - by jbatson
    anyone know how i would get from opening <table> to </table> in this data that is returned from ajax with jquery. // BEGIN Subsys_JsHttpRequest_Js Subsys_JsHttpRequest_Js.dataReady( '3599', // this ID is passed from JavaScript frontend '<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n <tr>\n <td>\n <script type=\"text/javascript\" language=\"javascript\" src=\"includes/ajax_sc.js\"></script>\n <div id=\"divShoppingCard\">\n\n <div class=\"infoBoxHeading\"><a href=\"shopping_cart.php\">Shopping Cart</a></div>\n\n <div>\n <div class=\"boxText\">\n<script language=\"javascript\" type=\"text/javascript\">\nfunction couponpopupWindow(url) {\n window.open(url,\"popupWindow\",\"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=280,screenX=150,screenY=150,top=150,left=150\")\n}\n//--></script><table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"left\" valign=\"top\" class=\"infoBoxContents\"><span class=\"infoBoxContents\">1&nbsp;x&nbsp;</span></td><td valign=\"top\" class=\"infoBoxContents\"><a href=\"http://beta.vikingwholesale.com/catalog/eagle-vanguard-limited-edition-p-3769.html\"><span class=\"infoBoxContents\">192 Eagle Vanguard Limited Edition</span></a></td></tr><tr><td align=\"left\" valign=\"top\" class=\"infoBoxContents\"><span class=\"newItemInCart\">4&nbsp;x&nbsp;</span></td><td valign=\"top\" class=\"infoBoxContents\"><a href=\"http://beta.vikingwholesale.com/catalog/family-traditions-adrenaline-avid-black-p-3599.html\"><span class=\"newItemInCart\">085 Family Traditions Adrenaline - Avid, Black</span></a></td></tr><tr><td align=\"left\" valign=\"top\" class=\"infoBoxContents\"><span class=\"infoBoxContents\">1&nbsp;x&nbsp;</span></td><td valign=\"top\" class=\"infoBoxContents\"><a href=\"http://beta.vikingwholesale.com/catalog/painted-pony-paradigm-p-4022.html\"><span class=\"infoBoxContents\">336 Painted Pony Paradigm</span></a></td></tr></table></div>\n\n\n <div class=\"boxText\"><img src=\"images/pixel_black.gif\" width=\"100%\" height=\"1\" alt=\"\"/></div>\n\n\n <div class=\"boxText\">$940.00</div>\n\n\n</div>\n\n\n \n </div><!--end of divShoppingCard-->\n </td>\n </tr></table>', null ) // END Subsys_JsHttpRequest_Js

    Read the article

  • Using attribute text value in AngularJS directive

    - by C1pher
    Using a YouTube tutorial created by John Lindquist, I was able to create a directive using a template. See fiddle: http://jsfiddle.net/37PSs/ Now, I want to use the value of the attribute as a variable to a function call. Something like this: html: <hello-world name="World"></hello-world> javascript - directive: template: '<span>myFunction({{name}})</span>' javascript - myFunction(theirName): return ("Hello, " + String(theirName) + "!"); The closest I've been able to get is passing an [object Window] to my function.

    Read the article

  • How to use a getter with a nullable?

    - by Desmond Lost
    I am reading a bunch of queries from a database. I had an issue with the queries not closing, so I added a CommandTimeout. Now, the individual queries read from the config file each time they are run. How would I make the code cache the int from the config file only once using a static nullable and getter. I was thinking of doing something along the lines of: static int? var; get{ var = null; if (var.HasValue) ...(i dont know how to complete the rest) My actual code: private object ExecuteQuery(string dbConnStr, bool fixIt) { object result = false; using (SqlConnection connection = new SqlConnection(dbConnStr)) { connection.Open(); using (SqlCommand sqlCmd = new SqlCommand()) { AddSQLParms(sqlCmd); sqlCmd.CommandTimeout = 30; sqlCmd.CommandText = _cmdText; sqlCmd.Connection = connection; sqlCmd.CommandType = System.Data.CommandType.Text; sqlCmd.ExecuteNonQuery(); } connection.Close(); } return result; }}

    Read the article

  • Get _id from MongoDB using Scala

    - by user2438383
    For a given JSON how do I get the _id to use it as an id for inserting in another JSON? Tried to get the ID as shown below but does not return correct results. private def getModelRunId(): List[String] = { val resultsCursor: List[DBObject] = modelRunResultsCollection.find(MongoDBObject.empty, MongoDBObject(FIELD_ID -> 1)).toList println("resultsCursor >>>>>>>>>>>>>>>>>> " + resultsCursor) resultsCursor.map(x => (Json.parse(x.toString()) \ FIELD_ID).asOpt[String]).flatten } { "_id": ObjectId("5269723bd516ec3a69f3639e"), "modelRunId": ObjectId("5269723ad516ec3a69f3639d"), "results": [ { "ClaimId": "526971f5b5b8b9148404623a", "pricingResult": { "TxId": 0, "ClaimId": "Large_Batch_1", "Errors": [ ], "Disposition": [ { "GroupId": 1, "PriceAmt": 20, "Status": "Priced Successfully", "ReasonCode": 0, "Reason": "RmbModel(PAM_DC_1):ProgramNode(Validation CPG):ServiceGroupNode(Medical Services):RmbTerm(RT)", "PricingMethodologyId": 2, "Lines": [ { "Id": 1 } ] } ] } },

    Read the article

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