w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Initiating Soundcloud for practice page
Looks like you're missing the full url for the SoundCloud JavaScript SDK (missing http:): <html> <head> <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script src="http://connect.soundcloud.com/sdk.js"></script> <script src= "script.js"></script> </head> <body> <div id="player"></div> </body> </html> You should be able to run this locally within your browser as SoundCloud supports Cross Origin Resource Sharing headers, removing the restriction on XSS: Of CORS We Do

Categories : Javascript

Is it okay to hard-code complex math logic inside my code?
As the above comment states, this is far from complex. You can however store the Magic numbers in constants/app.config values, so as to make it easier for the next developer to maitain your code. When storing such constants, make sure to explain to the next developer (read yourself in 1 month) what your thoughts were, and what they need to keep in mind. Also ewxplain what the actual calculation is for and what it is doing.

Categories : C#

PyCUDA Complex Matrix Multiplication - C code vs Python code
This is most probably a precision issue. I fixed it by replacing the host transfer and empty matrix creation code with the following... # transfer host (CPU) memory to device (GPU) memory a_gpu = gpuarray.to_gpu(a_cpu.astype(np.complex64)) b_gpu = gpuarray.to_gpu(b_cpu.astype(np.complex64)) # create empty gpuarry for the result (C = A * B) c_gpu = gpuarray.empty((MATRIX_SIZE, MATRIX_SIZE), np.complex64) But I do find a problem in using PyCUDA to multiply large complex valued matrices. For instance, taking MATRIX_SIZE = 5040 and TILE_SIZE = 16 (which may not be a good choice from the standpoint of hardware), CUDA-C does manage to multiply the matrices, but PyCUDA crashes. Why should this happen?

Categories : Python

What is the order of execution between python code and javascript code in html
Python code runs on the server; Javascript code runs on the client. Therefore, Javascript code can only run after the Python code finishes. However, this has nothing to do with your problem. HTML tags do not create local variable scopes; all of your rows share the same key variable. By the time you click the link, key will always have the last value (since all of the JS has already executed). You should build an href attribute in server-side code instead.

Categories : Javascript

Arbitrary code execution using existing code only
It is really unclear to me why you're asking this question. First of all, this function... void mov_value_to_eax() { asm volatile("movl %0, %%eax"::"m"(function_parameter):"%eax"); // will move the value of the variable function_parameter to register eax } ...uses GCC inline assembly, but the function itself is not inline, meaning that there will be prologue & epilogue code wrapping it, which will probably affect your intended result. You may instead want to use GCC inline assembly functions (as opposed to functions that contain GCC inline assembly), which may get you closer to what you want, but there are still problems with that..... OK, so supposing you write a GCC inline assembly function for every possible x86 opcode (at least the ones that the GCC assembler knows ab

Categories : C

initiating a fortran exe
C:\TxtInOut\rev591_64rel doesnt look like a Windows executable file (e.g. .exe or .lnk) - its missing the file extension. For both of these aforementioned extensions, add the extensions and check the ErrorStream to see what errors are being shown by the Process p: Process p = new ProcessBuilder("C:\TxtInOut\rev591_64rel.lnk").start(); try (BufferedReader errorStream = new BufferedReader(new InputStreamReader(p.getErrorStream()))) { String line; while ((line = errorStream.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); }

Categories : Java

R code execution error
I think the problem is in the non-ASCII characters in the file and directory names. Move the CSV to the directory C:/Users/Joana/Documents/ and rename it to test.csv. Then try to open it again: I bet it will work. I have no idea how to solve that -- it works fine on my Unix system, whereas you are on Windows. See also this stackexchange question.

Categories : R

"this" in code does not match with "this" during execution
Its how the javascript works, 'this' is tied to the caller. if you want the 'this' to be parent try this: <i class="icon-edit" data-bind="click: $parent.GetEditForm.bind($parent,$data)"></i> bind will bind 'this' to first parameter which is $parent in your case and then pass $data (foo) as the first parameter.

Categories : Knockout Js

Code execution with async
You've just discovered why you should never write async void. If you write an async void method, you have no way of knowing when the asynchronous part finishes. This includes Main(); your program is exiting as soon as it hits the first await. async methods are mostly useless in console programs; if you really want to try them, you'll need to call .Wait() on the Tasks returned to Main().

Categories : C#

Instruction execution of a C++ code
Ok, let's do an analysis step by step. The first instruction cin >> n counts as one operation: 1. Then the loop for(i=1;i<=n;i++) for (j = 1; j <= n; j ++) A[i][j] = 0; Let's go from inside out. The j loop performs n array assignments (A[i][j] = 0), (n + 1) j <= n comparisons and n j ++ assignments. It also performs once the assignment j = 1. So in total this gives: n + (n +1) + n + 1 = 3n + 2. Then the outer i loop performs (n + 1) i <= n comparisons, n i ++ assignments and executes n times the j loop. It also performs one i = 1 assignment. This results in: n + (n + 1) + n * (3n + 2) + 1 = 3n^2 + 4n + 2. Finally the last for loop performs n array assignments, (n + 1) i <= n comparisons and n i ++ assignments. It also performs one assignment i = 1

Categories : Algorithm

What is the execution sequence for the code below?
s2[ i ] will be assigned to s1[ i ] and then value of s1[ i ] will be compared against ZERO. Please refer here for more info.

Categories : C

Will using an "else" speed the up the execution of code?
Probably. It depends on whether the compiler can detect that your conditions are mutually exclusive and optimize based on that. In the simple integer case, it probably can; in more complicated cases, it can't. But it's not just about the compiler. It's also about the reader. Using else if documents to the reader that the cases are mutually exclusive, and that's a good thing. Another option is to return from the function at the end of each if block.

Categories : Java

EXC_BAD_ACCESS when initiating AVAudioPlayer
Are you trying to access iPod library? I think it is not possible to use AVAudioPlayer with iPod library, unless you find a way to copy songs to your app directory. Take a look here or here Use AVPlayer instead...

Categories : Iphone

Restrict VO execution On Page Load
You can add a query with a parameter in the business definition. In this paramater you can choose to show or not to show data for example select * from dual where 1 = :parameter During the page load you can set parameter to 0 so that the query will result in a blank set. Then inside the page you can put a command button or link to execute the query sending the parameter valued in 1 so that the query result comes complete.

Categories : Oracle

Analysis of execution frequency code
Your combinatorics is perfectly fine, you have n distinct elements, and you need the number of possibilities to chose 3 elements, order does not matter, no repeats. This is indeed C(N,3). (Disclaimer, I was a combinatorics TA during the last months)

Categories : Java

jquery msgBox execution in code behind(c#)
While using this plugin it is necessary to include 3 files: <script src="Scripts/jquery-2.0.0.js" type="text/javascript"></script> <script src="Scripts/jquery.msgBox.js" type="text/javascript"></script> <link href="Styles/msgBoxLight.css" rel="stylesheet" type="text/css"> I used this code on client-side: <script type="text/javascript"> function warningMessage() { $.msgBox({ title: "Hatalı Giriş", content: "Kullanıcı numarası ya da şifre hatalı...", type: "error", buttons: [{ value: "Okay"}] }); } </script> On server-side: Page.ClientScript.RegisterStartupScript(this.GetType(), null, "warningMessage();", true); IT WORKS WELL FOR ME

Categories : C#

How JIT schedule the execution of byte code?
Check this answer I gave here on StackOverflow a long time ago for an explanation on why that DCL fails, and how to fix it. The problem is not sync/async. The problem is something called reordering. The JVM spec defines something called a happens-before relationship. Inside a single thread, if statement S1 appears before statement S2, then S1 happens-before S2, that is, whatever modifications S1 made to the memory are visible to S2. Note that it does not say that the statement S1 must be executed before S2. It just says that things should look as if S1 was executed before S2. For example, consider this code: int x = 0; int y = 0; int z = 0; x++; y++; z++; z += x + y; System.out.println(z); Here, it doesn't matter the order in which the JVM executes the three increment statements. Th

Categories : Java

Oracle PL/SQL dynamic code execution
OK, found the solution myself: I just have to correct the execute line by: EXECUTE IMMEDIATE dynCall USING c,si,mn,OUT res; The web documentation is missing such examples (I didn't find anything).

Categories : Oracle

perl code execution order
I made an attempt to look at your code, but it's rather painfully verbose, and does not fit on my computer screen, so I wanted to show you what you could do instead to parse that particular input. First off, though, here's a trap for the unwary: open MDDETAIL, "-|", "$MDADMCMD --detail $device" || die "can't run: $!"; If you look in perldoc perlop you will notice in the precedence table that || has higher precedence than , (comma). What this means is that the statement above really means this: open MDDETAIL, "-|", ("$MDADMCMD --detail $device" || die "can't run: $!"); Or, in other words, the third argument for open becomes either a string, or a die statement. Since this string is not empty, it will always be true (it is a constant, after all), and since || short curcuits, the

Categories : Linux

Simulink: code generation for a complex model
Assuming that you are not using aaa independently of bbb (on your physical board) then you shouldn't be generating code for aaa independently from bbb. Generating code for bbb (only) will detect that it needs to generate code for aaa and automatically create all the files you need (including the functionality of both bbb and aaa).

Categories : Matlab

How to get initiating jnlp file name/dir in java?
I need to delete this jnlp file while app is closing. That choice is not available to the developer. It is a choice of the user, their JRE and system settings. What application feature are you trying to implement from this?

Categories : Java

Initiating the Play Services GamesClient
Your MainMenu class that you are passing in to the GamesClient.Builder constructor as "this" needs to: Be a Context Implement GooglePlayServicesClient.ConnectionCallbacks Implement GooglePlayServicesClient.OnConnectionFailedListener I'm guessing that the class currently fails one or more of those requirements. For more information on the GamesClient.Builder, check out the documentation.

Categories : Java

execution of some code inside javascript function
If you are indeed getting the right HTML into execcode, you can use eval(execcode); You can check this by just doing a simple console.log(execcode) or alert(execcode) to verify that it's loaded correctly. However, I can guarantee you that this is almost certainly a very, very bad idea. it'd be trivial for someone to just edit your DOM and insert whatever malicious javascript they want.

Categories : Javascript

java.lang.NullPointerException after code execution
You should check the Connection object for null before calling methods on it. Connection conn = DriverManager.getConnection("jdbc:odbc:ATBS", "CENTOS", "Shaman123"); if(conn != null) { Statement statement = conn.createStatement(); String command = "INSERT INTO letadlo (ID, model, sedadel) VALUES ('"+ID+"', '"+model+"', '"+sedadel+"')"; PreparedStatement ps = conn.prepareStatement(command); ps.execute(); conn.close(); //Ideally it should be closed inside finally. } Ideally Connection and PrepareStatement should be closed inside finally block.

Categories : Jsp

Mouse movement accelerates code execution?
Eric Palace gave me the start My personal theory was always that it had something to do with the window focus and which program is given more CPU time, but that's just pure speculation. That makes sense to me. But wait, don't you only paint on a timer? Wouldn't that prevent additional CPU time from modifying movement speed? Yes you do. Sortof. glutTimerFunc(1.6666f, TimerFunction, 1); The doc's for glutTimerFunc say that the first parameter is an unsigned int, representing the timer in milliseconds. So you're telling glut "call this function every 1 millsecond." (Approx 1000FPS) And since it takes longer than one millisecond to execute, you're effectively telling it "run this function over and over as fast as you possibly can". Which it does. And so additional CPU time is

Categories : C++

My code is taking too long at time of execution
first of all i didn't understand if the query to the DB is taking too long or the rest of the function or both. if you don't know, you should start by testing it. you can use a simple DateTime.Now and see how many ticks did each part took. if you want to test it with an even better way, you can use StopWatch as as V4Vendetta said. you can find an example here and basically the syntext will be like: // Create new stopwatch Stopwatch stopwatch = new Stopwatch(); // Begin timing stopwatch.Start(); // YOUR CODE HERE // Stop timing stopwatch.Stop(); // Write result Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed); for the DB access is the one that take too long i can advise you not to call too many sql queries. i see that in a for loop you are calling: "select slno from

Categories : C#

waiting between each execution in my selenium webdriver code?
You could inherit from Actions class and override click() method including sleep inside its body. public class MyActions extends Actions { public MyActions(WebDriver driver) { super(driver); } @Override public Actions click() { try { Thread.sleep(1000); } catch (InterruptedException e) { //do something } return super.click(); } } and then simply use new class in your tests. Actions actions = new MyActions(driver); Please have in mind that putting sleep calls in test code is not a good practice. Consider using functionality provided by WebDriverWait class.

Categories : Selenium

Does code execution wait for Ajax response?
That's why AJAX is asynchronous. The compiler does not wait for the AJAX call to complete, before it compiles the rest of the page. If you want the calledSecond() to be called second, you have to put it into a callback function.

Categories : Javascript

remote code execution in ruby with constantize
Turning a string into a constant isn't dangerous in itself, but how that constant is used is potentially dangerous (i.e. the method that is then called). If you really need to do this, then it's probably best to provide a list of classes that are allowed. E.g. klass = params[:class].classify if %w(Class1 Class2 Class3).include? klass klass.constantize.do_something_with_id(params[:id]) else raise 'Forbidden' end However it's done, it helps you to sleep at night to know that the input is considerably limited. Update Another way of controlling the creation, which is more explicit but also more verbose, is to use a case statement: def create_klass(option) case option when "option1" Class1 when "option2" Class2 when "option3" Class3 else raise "Unknown optio

Categories : Ruby On Rails

Code execution after this.close call on winform
You could do this by handling the Form.FormClosed event. Run the code you need from here and it should work properly.

Categories : C#

Unprecise and random code execution time
Differences are to low. Try to repeat every action at least 10 000 times, then you should see any comparable results. You dont need to use echo, assigning to another var will work the same. Why your results are so random? Because result times are so small that any other server processes may affect your results. Try this version: <?php function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } $times = 10000; $name = 'rahul' ; $time_start = microtime_float(); // Make loop for($i = 0; $i < $times; $i++) { $testvar = "My name is $name"; // First style } $time_end = microtime_float(); $time = $time_end - $time_start; echo " // $time seconds "; //and same for other styles ?> In addition,

Categories : PHP

Very slow execution of Matlab code under ubuntu
I had a similar problem at windows, but I believe the solution is same on Ubuntu LTS. So, if you increase the Java Heap Memory of Matlab, the Matlab will consume more memory from your system but it will be faster. To do that go to: File->preferences->General->Java Heap Memory and increase to the maximum. The default value is 128, that is too little.

Categories : Matlab

How to set a priority for the execution of the program in source code?
What's probably happening is you're on a multi-core/multi-thread machine and you're running on only one thread, the rest of the CPU power is just sitting idle. So you'll want to multi-thread your code. Look at boost thread.

Categories : C++

Displaying messages after every step of code execution
I think the others have missed the point of the question. You want each line of each to appear in "real time" as the script is processing rather than on execution completion. PHP by default doesn't output the buffer until the script execution has been completed or the buffer is full. You can manually flush the buffer to screen when you want using this function. function fcflush() { static $output_handler = null; if ($output_handler === null) { $output_handler = @ini_get('output_handler'); } if ($output_handler == 'ob_gzhandler') { // forcing a flush with this is very bad return; } flush(); if (function_exists('ob_flush') AND function_exists('ob_get_length') AND ob_get_length() !== false) { @ob_flush(); } else if (function_e

Categories : PHP

do I have to check login session when initiating PHP class?
Quick answers No. Your domain objects themselves should not be dependent on a logged in session; however, they may need a User instance to perform certain duties, such as only showing the products that a particular user is able to see. Because of #1, this is now trivial. Code review First let's consider your login page code: $user = new User($user, $password); if ($user->hasCorrectLogin()) { In this code, it would seem that User interacts with the database and has knowledge how to validate credentials. That seems a bit too much responsibility for a single class. It could perform password validation by keeping the hashed password inside the object, but you would only need to validate a password once, so there's really no need to keep that field around. Another reason not to have

Categories : PHP

Initiating a call though 3rd party VoIP app on an iPad
To see if your device can call the number using the phone app, check the tel: URL scheme: canMakePhoneCalls = ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:+44-1234-567890"]]); To see if your device has Skype, check the callto: URL scheme: canMakeSkypePhoneCalls = ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"callto:+44-1234-567890"]]);

Categories : IOS

Android WebView: how to load page after javascript execution
The HttpGet class is for an HTTP request, so the URL must start with http://. If you are using MathJax as the TeX viewer, then refering to this Stack Overflow question, you could add messageStyle: "none" to your MathJax configuration. This way can disable MathJax's loading notifications in any environments.

Categories : Javascript

How to refresh page after java method finishes execution
There is no need to refresh the page after the java method finishes. When you perform an http GET request on a servlet you would generally expect the http response to contain the page content So what you need to do is render the velocity template and attach it to the response

Categories : Java

complex active state navigation on single page website
You mean scrollspy? Check here http://jsfiddle.net/mekwall/up4nu/ // Cache selectors var lastId, topMenu = $("#top-menu"), topMenuHeight = topMenu.outerHeight()+15, // All list items menuItems = topMenu.find("a"), // Anchors corresponding to menu items scrollItems = menuItems.map(function(){ var item = $($(this).attr("href")); if (item.length) { return item; } }); // Bind click handler to menu items // so we can get a fancy scroll animation menuItems.click(function(e){ var href = $(this).attr("href"), offsetTop = href === "#" ? 0 : $(href).offset().top-topMenuHeight+1; $('html, body').stop().animate({ scrollTop: offsetTop }, 300); e.preventDefault(); }); // Bind to scroll $(window).scroll(function(){ // Get container scroll

Categories : Javascript

Delay code execution within a function in Javascript / Java
JavaScript doesn't allow blocking threads, so the only option you can use is setTimeOut() function. Or you can implement mechanism when the first component notifies the second when it loads and at this moment the second component reloads itself.

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.