Search Results

Search found 9082 results on 364 pages for 'c functions'.

Page 167/364 | < Previous Page | 163 164 165 166 167 168 169 170 171 172 173 174  | Next Page >

  • How do I run JavaScript in my ContentPlaceHolder?

    - by donde
    I had a load of javascript that ran well when everything was in one page. Now that I've separated it out, I'm not sure how to include the javascript, ssing the HEAD tag in in the master, and also, I had functions that ran when the body loaded but they are in the master too. By the way this is a .NET 2.0 app.

    Read the article

  • Trying to provide a global logging function

    - by Gekitsuu
    I typically write my scripts with a structure like s #!/usr/bin/python import stuff def do_things(): print "FOO" def main(): do_things() if __name__ == "__main__": main() The problem I have is I'd like to have a logging function that is defined globally and I"m not really sure how to do this. I tried a decorator function but if I define it in main I can't call it from other functions in the script. It seems like something that should be easy to do but not something I have experience with.

    Read the article

  • Is it safe to make GL calls with multiple threads?

    - by user146780
    I was wondering if it was safe to make GL calls with multiple threads. Basically I'm using a GLUtesselator and was wondering if I could divide the objects to draw into 4 and assign a thread to each one. I'm just wondering if this would cause trouble since the tesselator uses callback functions. Can 2 threads run the same callback at the same time as long as that callback does not access ant global variables? Are there also other ways I could optimize OpenGL drawing using multithreading? Thanks

    Read the article

  • How can I declare an object with properties that I will be passing around inside of my function using Typescript?

    - by Marilou
    I've been using the following: var modal = { content: '', form: '', href: '' } But now I have started to use Typescript is there a better way I can declare an object and how can I declare the types of my properties. The reason I am using this object is that it's inside of a function and inside that function I have other functions that set and use the values of the properties. Is this the best way for me to do this or is there another way I could better do this with typescript?

    Read the article

  • Execution issue with PyModule_AddIntConstant function

    - by karnol
    I m learning python c api functions and keen to learn python 3.1 stable version. Found an unresolved issue recently and tried PyModule_AddIntConstant(PyObject *module, const char *name, long value) Runtime error occurred for this function call. Is there something wrong with the function in python 3.1?

    Read the article

  • SQL server datetime column filter on certain date or range of dates

    - by MicMit
    There is an example for today here http://stackoverflow.com/questions/2583228/get-row-where-datetime-column-today-sql-server-noob I am primarily interested in 2008 only. For today it looked like SELECT (list of fields) FROM dbo.YourTable WHERE dateValue BETWEEN CAST(GETDATE() AS DATE) AND DATEADD(DAY, 1, CAST(GETDATE() AS DATE)) What literal value of date(s) or functions ( I need a format ) should I place there to make it work independent of local settings.

    Read the article

  • How much data can a javascript global variable hold??

    - by alex
    Hi, To enable a go back function with an ajax div i have create these simple functions and i was wondering how much data a .js global variable can hold?? var dataAfterSearch; //global variable which holds our search results function goBackAfterSearch() { /** * function which displays the previous state * **/ $.ajaxSetup ({ cache: false }); //alert("Previous Search" +dataAfterSearch); $('#result').html(dataAfterSearch); paginateIt(); } function setDataAfterSearch(data) { /** * function to set the global dataAfterSearch * **/ dataAfterSearch = data; } kind regards

    Read the article

  • HTML5 Canvas + select / drag-and-drop features in a JS lib?

    - by István
    Hi, I'd like to use HTML5 Canvas, but I'd like to use it in terms of shapes, texts and curves, able to attach traditional DOM events like onClick or drag-and-drop functions. Is there any Javascript library that is able to do that for me? I've seen that gwt-canvas is close to this approach, but haven't looked it in details. Thanks, Istvan

    Read the article

  • Why is Matlab Stateflow 7.7 not throwing errors on undefined variables?

    - by Pyrolistical
    Previously in Matlab Stateflow 7.1 all variables and functions had to be included before they can be referred to in the state diagram or else it would throw an error when you tried to parse the diagram. But now in 7.7 it doesn't catch those kinds of errors. Its still compiling the diagram because it catches other syntactic errors. Am I missing an option somewhere? Can this be turned on?

    Read the article

  • Numpy zero rank array indexing/broadcasting

    - by Lemming
    I'm trying to write a function that supports broadcasting and is fast at the same time. However, numpy's zero-rank arrays are causing trouble as usual. I couldn't find anything useful on google, or by searching here. So, I'm asking you. How should I implement broadcasting efficiently and handle zero-rank arrays at the same time? This whole post became larger than anticipated, sorry. Details: To clarify what I'm talking about I'll give a simple example: Say I want to implement a Heaviside step-function. I.e. a function that acts on the real axis, which is 0 on the negative side, 1 on the positive side, and from case to case either 0, 0.5, or 1 at the point 0. Implementation Masking The most efficient way I found so far is the following. It uses boolean arrays as masks to assign the correct values to the corresponding slots in the output vector. from numpy import * def step_mask(x, limit=+1): """Heaviside step-function. y = 0 if x < 0 y = 1 if x > 0 See below for x == 0. Arguments: x Evaluate the function at these points. limit Which limit at x == 0? limit > 0: y = 1 limit == 0: y = 0.5 limit < 0: y = 0 Return: The values corresponding to x. """ b = broadcast(x, limit) out = zeros(b.shape) out[x>0] = 1 mask = (limit > 0) & (x == 0) out[mask] = 1 mask = (limit == 0) & (x == 0) out[mask] = 0.5 mask = (limit < 0) & (x == 0) out[mask] = 0 return out List Comprehension The following-the-numpy-docs way is to use a list comprehension on the flat iterator of the broadcast object. However, list comprehensions become absolutely unreadable for such complicated functions. def step_comprehension(x, limit=+1): b = broadcast(x, limit) out = empty(b.shape) out.flat = [ ( 1 if x_ > 0 else ( 0 if x_ < 0 else ( 1 if l_ > 0 else ( 0.5 if l_ ==0 else ( 0 ))))) for x_, l_ in b ] return out For Loop And finally, the most naive way is a for loop. It's probably the most readable option. However, Python for-loops are anything but fast. And hence, a really bad idea in numerics. def step_for(x, limit=+1): b = broadcast(x, limit) out = empty(b.shape) for i, (x_, l_) in enumerate(b): if x_ > 0: out[i] = 1 elif x_ < 0: out[i] = 0 elif l_ > 0: out[i] = 1 elif l_ < 0: out[i] = 0 else: out[i] = 0.5 return out Test First of all a brief test to see if the output is correct. >>> x = array([-1, -0.1, 0, 0.1, 1]) >>> step_mask(x, +1) array([ 0., 0., 1., 1., 1.]) >>> step_mask(x, 0) array([ 0. , 0. , 0.5, 1. , 1. ]) >>> step_mask(x, -1) array([ 0., 0., 0., 1., 1.]) It is correct, and the other two functions give the same output. Performance How about efficiency? These are the timings: In [45]: xl = linspace(-2, 2, 500001) In [46]: %timeit step_mask(xl) 10 loops, best of 3: 19.5 ms per loop In [47]: %timeit step_comprehension(xl) 1 loops, best of 3: 1.17 s per loop In [48]: %timeit step_for(xl) 1 loops, best of 3: 1.15 s per loop The masked version performs best as expected. However, I'm surprised that the comprehension is on the same level as the for loop. Zero Rank Arrays But, 0-rank arrays pose a problem. Sometimes you want to use a function scalar input. And preferably not have to worry about wrapping all scalars in at least 1-D arrays. >>> step_mask(1) Traceback (most recent call last): File "<ipython-input-50-91c06aa4487b>", line 1, in <module> step_mask(1) File "script.py", line 22, in step_mask out[x>0] = 1 IndexError: 0-d arrays can't be indexed. >>> step_for(1) Traceback (most recent call last): File "<ipython-input-51-4e0de4fcb197>", line 1, in <module> step_for(1) File "script.py", line 55, in step_for out[i] = 1 IndexError: 0-d arrays can't be indexed. >>> step_comprehension(1) array(1.0) Only the list comprehension can handle 0-rank arrays. The other two versions would need special case handling for 0-rank arrays. Numpy gets a bit messy when you want to use the same code for arrays and scalars. However, I really like to have functions that work on as arbitrary input as possible. Who knows which parameters I'll want to iterate over at some point. Question: What is the best way to implement a function as the one above? Is there a way to avoid if scalar then like special cases? I'm not looking for a built-in Heaviside. It's just a simplified example. In my code the above pattern appears in many places to make parameter iteration as simple as possible without littering the client code with for loops or comprehensions. Furthermore, I'm aware of Cython, or weave & Co., or implementation directly in C. However, the performance of the masked version above is sufficient for the moment. And for the moment I would like to keep things as simple as possible.

    Read the article

  • Linking and Redirecting between multiple applications running under a single system folder

    - by Gurunandan
    I am running multiple applications with a single Codeigniter system/ folder using the recommended way on the Codeigniter wiki. Each application runs fine and I can link between apps using absolute URLs. Is there some way I can use or extend the URL helper class (functions like anchor(), redirect()... etc.) to generate links to controllers across applications. I would like to avoid absolute URLs Thanks!

    Read the article

  • hoq do i get ajax to call after previous success is complete

    - by Alessandro
    I am currently using this ajax queuing plugin http://www.onemoretake.com/2009/10/11/ajaxqueue-and-jquery-1-3/ and it works fine, except weh ajax call 1 finishes, ajax call 2 starts that is dependent on a value that the success functions generates when ajax 1 is complete. Is there a way to start of all ajax calls when the previous call is complete and success function has been run? thanks

    Read the article

  • In gzip libary, what's the difference between 'uncompress' and 'gzopen' ?

    - by Sol
    There are some functions to decompress in zlib library(zlib version 1.2.3) I want to decompress my source zip(.gz) file using 'uncompress' function. It is now working(error code -3) but gzopen is. It is still not working when I input payload pointer(passing gzip header) to 'uncompress' . So the question is "What's the valid arguments for uncompress function?" and If it needs different format, how can I make it? Google doesn't helpful this time :(

    Read the article

  • Creating design document from existing java code.

    - by BigBoss
    I have existing java code and need to create Design Document based on that. For starter even if I could get all functions with input / output parameters that will help in overall proces. Note: There is not commeted documentation on any procedures, function or classes. Last but not least. Let me know for any good tool which will reduce time required for this phase. As currently we write every flow and related stuffs.

    Read the article

  • Linq Having Sum(Quantity) = x?

    - by molgan
    Hello I have a function that returns IQueryable, and I would like to add "HAVING SUM(Quantity) = X" to it, but I get error if I try like this: _rep.GetBookings().ByBookingObjectID(bookingObjectID).Sum(x => x.Quantity == somevariablehere); I cant seem to find functions for it to find by sum /M

    Read the article

  • LInux C++: how do profile time wasted due to cache misses?

    - by anon
    I know that I can use gprof to benchmark my code. However, I have this problem -- I have a smart pointer that has an extra level of indirection (think of it as a proxy object). As a result, I have this extra layer that effects pretty much all functions, and screws with caching. Is there a way to measure the time my CPU wastes due to cache misses? Thanks!

    Read the article

  • Portable way to get file size in C/C++

    - by chmike
    I need to determin the byte size of a file. The coding language is C++ and the code should work with Linux, windows and any other operating system. This implies using standard C or C++ functions/classes. This trivial need has apparently no trivial solution.

    Read the article

< Previous Page | 163 164 165 166 167 168 169 170 171 172 173 174  | Next Page >