Search Results

Search found 17501 results on 701 pages for 'stored functions'.

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

  • Javascript cloned object looses its prototype functions

    - by Jake M
    I am attempting to clone an object in Javascript. I have made my own 'class' that has prototype functions. My Problem: When I clone an object, the clone cant access/call any prototype functions. I get an error when I go to access a prototype function of the clone: clone.render is not a function Can you tell me how I can clone an object and keep its prototype functions This simple JSFiddle demonstrates the error I get: http://jsfiddle.net/VHEFb/1/ function cloneObject(obj) { // Handle the 3 simple types, and null or undefined if (null == obj || "object" != typeof obj) return obj; // Handle Date if (obj instanceof Date) { var copy = new Date(); copy.setTime(obj.getTime()); return copy; } // Handle Array if (obj instanceof Array) { var copy = []; for (var i = 0, len = obj.length; i < len; ++i) { copy[i] = cloneObject(obj[i]); } return copy; } // Handle Object if (obj instanceof Object) { var copy = {}; for (var attr in obj) { if (obj.hasOwnProperty(attr)) copy[attr] = cloneObject(obj[attr]); } return copy; } throw new Error("Unable to copy obj! Its type isn't supported."); } function MyObject(name) { this.name = name; // I have arrays stored in this object also so a simple cloneNode(true) call wont copy those // thus the need for the function cloneObject(); } MyObject.prototype.render = function() { alert("Render executing: "+this.name); } var base = new MyObject("base"); var clone = cloneObject(base); clone.name = "clone"; base.render(); clone.render(); // Error here: "clone.render is not a function"

    Read the article

  • Very simple python functions takes spends long time in function and not subfunctions

    - by John Salvatier
    I have spent many hours trying to figure what is going on here. The function 'grad_logp' in the code below is called many times in my program, and cProfile and runsnakerun the visualize the results reveals that the function grad_logp spends about .00004s 'locally' every call not in any functions it calls and the function 'n' spends about .00006s locally every call. Together these two times make up about 30% of program time that I care about. It doesn't seem like this is function overhead as other python functions spend far less time 'locally' and merging 'grad_logp' and 'n' does not make my program faster, but the operations that these two functions do seem rather trivial. Does anyone have any suggestions on what might be happening? Have I done something obviously inefficient? Am I misunderstanding how cProfile works? def grad_logp(self, variable, calculation_set ): p = params(self.p,self.parents) return self.n(variable, self.p) def n (self, variable, p ): gradient = self.gg(variable, p) return np.reshape(gradient, np.shape(variable.value)) def gg(self, variable, p): if variable is self: gradient = self._grad_logps['x']( x = self.value, **p) else: gradient = __builtin__.sum([self._pgradient(variable, parameter, value, p) for parameter, value in self.parents.iteritems()]) return gradient

    Read the article

  • List of Big-O for PHP functions?

    - by Kendall Hopkins
    After using PHP for a while now, I've noticed that not all PHP built in functions as fast as expected. Consider the below two possible implementations of a function that finds if a number is prime using a cached array of primes. //very slow for large $prime_array $prime_array = array( 2, 3, 5, 7, 11, 13, .... 104729, ... ); $result_array = array(); foreach( $array_of_number => $number ) { $result_array[$number] = in_array( $number, $large_prime_array ); } //still decent performance for large $prime_array $prime_array => array( 2 => NULL, 3 => NULL, 5 => NULL, 7 => NULL, 11 => NULL, 13 => NULL, .... 104729 => NULL, ... ); foreach( $array_of_number => $number ) { $result_array[$number] = array_key_exists( $number, $large_prime_array ); } This is because in_array is implemented with a linear search O(n) which will linearly slow down as $prime_array grows. Where the array_key_exists function is implemented with a hash lookup O(1) which will not slow down unless the hash table gets extremely populated (in which case it's only O(logn)). So far I've had to discover the big-O's via trial and error, and occasionally looking at the source code. Now for the question... I was wondering if there was a list of the theoretical (or practical) big O times for all* the PHP built in functions. *or at least the interesting ones For example find it very hard to predict what the big O of functions listed because the possible implementation depends on unknown core data structures of PHP: array_merge, array_merge_recursive, array_reverse, array_intersect, array_combine, str_replace (with array inputs), etc.

    Read the article

  • Database Programming in C#, returning output from Stored Proc

    - by jpavlov
    I am working at gaining an understanding at how to interface stored procedures with applications. My example is simple, but it doesn't display my columns and rows in the command prompt, instead it display System.Data.SqlClient.SqlDataReader. How do I display the rows from my stored procudure? ----Stored Proc-- ALTER PROCEDURE dbo.SelectID AS SELECT * FROM tb_User; ----- Below is the code: using System; using System.Data.SqlClient; using System.IO; namespace ExecuteStoredProc { class Program { static void Main(string[] args) { SqlConnection cnnUserMan; SqlCommand cmmUser; //SqlDataReader drdUser; //Instantiate and open the connection cnnUserMan = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=c:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\UserDB.mdf; Integrated Security=True;Connect Timeout=30;User Instance=True"); cnnUserMan.Open(); //Instantiate and initialize command cmmUser = new SqlCommand("SelectID", cnnUserMan); cmmUser.CommandType = System.Data.CommandType.StoredProcedure; //drdUser = cmmUser.ExecuteReader(); Console.WriteLine(cmmUser.ExecuteReader()); Console.ReadLine(); } } } Thanks.

    Read the article

  • Application that depends heavily on stored procedures

    - by PieterG
    We currently have an application that depends largely on stored procedures. There is a heavy use of temp tables. It's an extremely large application. Facing this situation, I would like to use Entity Framework or Linq2Sql for a rewrite. I might consider using Fluent Hibernate or Subsonic, as i've used them quite extensively in the past. I've had problems with Linq2Sql generating the return types for the stored procedures because of the usage of the temp tables, and I think it's cumbersome to go and change all the stored procedures from temp tables to in-memory tables. Considering the 2 choices that I want to make, which one of the 2 is the best route to go and why? If my choices are extremely idiotic, please provide alternatives. Edit: The reason for the question and the change is that the data access layer is non-existent and was built 10 years ago. We currently still run into a lot of issues with it. I don't want to divulge too much, but if you saw it, your eyes would start bleeding :)

    Read the article

  • How do I write recursive anonymous functions?

    - by James T Kirk
    In my continued effort to learn scala, I'm working through 'Scala by example' by Odersky and on the chapter on first class functions, the section on anonymous function avoids a situation of recursive anonymous function. I have a solution that seems to work. I'm curious if there is a better answer out there. From the pdf: Code to showcase higher order functions def sum(f: Int => Int, a: Int, b: Int): Int = if (a > b) 0 else f(a) + sum(f, a + 1, b) def id(x: Int): Int = x def square(x: Int): Int = x * x def powerOfTwo(x: Int): Int = if (x == 0) 1 else 2 * powerOfTwo(x-1) def sumInts(a: Int, b: Int): Int = sum(id, a, b) def sumSquares(a: Int, b: Int): Int = sum(square, a, b) def sumPowersOfTwo(a: Int, b: Int): Int = sum(powerOfTwo, a, b) scala> sumPowersOfTwo(2,3) res0: Int = 12 from the pdf: Code to showcase anonymous functions def sum(f: Int => Int, a: Int, b: Int): Int = if (a > b) 0 else f(a) + sum(f, a + 1, b) def sumInts(a: Int, b: Int): Int = sum((x: Int) => x, a, b) def sumSquares(a: Int, b: Int): Int = sum((x: Int) => x * x, a, b) // no sumPowersOfTwo My code: def sumPowersOfTwo(a: Int, b: Int): Int = sum((x: Int) => { def f(y:Int):Int = if (y==0) 1 else 2 * f(y-1); f(x) }, a, b) scala> sumPowersOfTwo(2,3) res0: Int = 12

    Read the article

  • C: writing the following code into functions

    - by donok
    Dear respected programmers. Please could you help me (again) on how to put the following code into functions for my program. I have read on-line and understand how functions work but when I do it myself it all goes pear shaped/wrong(I am such a noob). Please could you help with how to for example to write the code below into functions.(like opening the input file). My attempt: void outputFile(int argc, char **argv) { /* Check that the output file doesnt exist */ if (stat(argv[argc-1], &inode) != -1) { printf("Warning: The file %s already exists. Not going to overwrite\n", argv[argc-1]); return -1; } /*Opening ouput files*/ file_desc_out = open(argv[i],O_CREAT | O_WRONLY | O_EXCL , S_IRUSR|S_IWUSR); if(file_desc_out == -1) { printf("Error: %s cannot be opened. \n",argv[i]); //insted of argv[2] have pointer i. return -1; } } Any help on how I would now reference to this in my program is appreciated thank you. I tried: ouputfile(but I cant figure out what goes here and why either).

    Read the article

  • Extracting exported functions out of a shared lib (ubuntu)

    - by Pingu
    the title already describes my problem. I found this post, but it didn't completely answers my question. With the help of it i got this output from nm... $nm -C -g -D ./libLoggingHandler.so 000000cc A _DYNAMIC ... 000042e0 T write_str(char*, char const*, int*) 00005a78 T RingBuffer::WriteUnlock() ... 00005918 T TraceLines::GetItemSize() ... U SharedMemory::attach(int, void const*, int) ... 00003810 T TraceProfile::FindLineNr(int, int) ... 00002d40 T LoggingHandler::getLogLevel() ... U SharedResource::getSharedResourceKey(char const*, int) ... which are the exported functions? I already found a hint in this post, that the "T" indicates that its getting exported. But if i check the nm manual here, it just says T - The symbol is in the text (code) section. My questions is: Does this output give me the information which functions are exported functions (or variables)? If not, how do i get it? Greetings, Pingu

    Read the article

  • What does "Select Distinct Null As xxxxx" mean?

    - by Soylent Green
    Background: I am mapping Sybase stored procedure return values to java objects using Spring. For example I map a Sybase datatype of varchar as a String type in Java, and a Sybase datatype of int as an int type in Java, etc. I have come across the following code in one of the stored procedures: SELECT DISTINCT A.Col1 AS val1, A.Col2 AS val2, NULL AS someVal, A.col3 AS val3, ... A.col9 AS val9 FROM #SomeTable A ORDER BY Col2, Col3 I have 2 related questions: What does Null mean in this scenario? I am confused as to what is happening here. I am able to determine the data type of Col1, Col2, etc. of course by looking at the table definition of Table A defined earlier in the stored procedure. Thus I know what datatype I can define in my Java object for val1, val2, etc.. But what about "someVal"? What datatype mapping am I supposed to perform for this Null value? I am fairly inexperienced in SQL. Perhaps the answer is much simpler than I realize.

    Read the article

  • How do you chain functions dynamically in jQuery?

    - by clarke78
    I want to loop through an object that contains functions which will execute one after another. My most ideal approach would be to have these chain somehow (ie. func2 waits for func1 and func3 waits for func2) but this needs to happen dynamically and the functions will all have different durations. I'm using jQuery so I thought that perhaps "queue()" may help but I haven't worked with it much. A main concern is to not add any scope/callbacks to the functions within the object. I'd rather somehow enclose them within a parent function to execute within the loop in order to create the callback/chaining. Here's an example of what I've got now, but dumbed down. Thanks for any help! var obj = [ {'name':'func1','callback':function(){ alert(1); }}, {'name':'func2','callback':function(){ alert(2); }}, {'name':'func3','callback':function(){ alert(3); }} ]; $.each(obj, function(x, el) { el.callback(); });

    Read the article

  • Calling multiple functions simultaneously with jquery.

    - by clarke78
    I want to loop through an object that contains functions which will execute one after another. My most ideal approach would be to have these chain somehow (ie. func2 waits for func1 and func3 waits for func2) but this needs to happen dynamically and the functions will all have different durations. I'm using jQuery so I thought that perhaps "queue()" may help but I haven't worked with it much. A main concern is to not add any scope/callbacks to the functions within the object. I'd rather somehow enclose them within a parent function to execute within the loop in order to create the callback/chaining. Here's an example of what I've got now, but dumbed down. Thanks for any help! var obj = [ {'name':'func1','callback':function(){ alert(1); }}, {'name':'func2','callback':function(){ alert(2); }}, {'name':'func3','callback':function(){ alert(3); }} ]; $.each(obj, function(x, el) { el.callback(); });

    Read the article

  • Retreive value stored in array with jquery index

    - by Dustin
    I am trying to retreive the stored value (div id) of an index stored in var "current" when it's div is clicked, so I can use it in a function to iterate through to the next index later. I want to store this stored value in a var so I can use it in a div show/hide function. my html is quite simple: <div class="gallerypreview" id="1"></div> <div class="gallerypreview" id="2"></div> <div class="gallerypreview" id="3"></div> my javascript is something like this: var images = new Array(); $(document).ready( function(){ $('.gallerypreview').each(function() { images.push($(this).attr("id")); }); $('.gallerypreview').click(function() { var current = $('.gallerypreview').index(this); }); }); how would I go about retrieving the div id from this clicked div? nothing I have tried has worked. I can get the index # fine, but I cannot find the value of the index using any functions that utilize the index # yet.

    Read the article

  • Which are the cons of using only non-member functions and POD?

    - by Miro
    I'm creating my own game engine. I've read these articles and this question about DOD and it was written to not use member functions and classes. I also heard some criticism to this idea. I can write it using member functions or non-member functions it would be similar. So what are the benefits/cons of that approach or when the project grows, does any of these approaches give clearer and better manageable code? With POD & non-member functions I don't have to make struct members public I can still use object id outside of engine like OpenGL does with all it's stuff, so It's not about encapsulation. POD - plain old data DOD - data oriented design

    Read the article

  • What are cons of usage only non-member functions and POD?

    - by Miro
    I'm creating my own game engine. I've read these articles and this question about DOD and there was written to not use member functions and classes. I also heard some criticism to this idea. I can write it using member functions or non-member functions it would be similar. So what are benefits/cons of that approach or when project grows, does any of these approaches give clearer and better manageable code? With POD & non-member functions I don't have to make struct members public I can still use object id outside of engine like OpenGL does with all it's stuff, so It's not about encapsulation. POD - plain old data DOD - data oriented design

    Read the article

  • ASP.NET 4.0 and the Entity Framework 4 - Part 3 - Execute Stored Procedures Using the Entity Framewo

    In this article, Vince demonstrates the usage of the Entity Framework 4 to execute stored procedures to create, read, update, and delete records in the database created in Part 1. After a short introduction, he examines the creation of the stored procedures and Web Forms, addition of the Stored Procedures to the Entity Model including adding, updating, and deleting records. He also shows how to retrieve a single record from the database.

    Read the article

  • SQL Server 2008 System Functions to Monitor the Instance, Database, Files, etc.

    SQL Server provides several system meta data functions which allow users to obtain property values of different SQL Server objects and securables. Although you can also use the SQL Server catalog views or Dynamic Management Views to obtain much of this information, in some circumstances the system meta data functions simplify the process. In this tip I am going to demonstrate some of the available system meta data functions and their usage in different scenarios.

    Read the article

  • Functions registered with ExternalInterface.addCallback not available in Javascript

    - by Selene
    I'm working on a Flash game that needs to call some Javascript on the page and get data back from it. Calling Javascript from Flash works. Calling the Flash functions from Javascript (often) doesn't. I'm using the Gaia framework. What happens: The swf is loaded in with SWFObject There's a button in the Flash file. On click, it uses ExternalInterface.call() to call a Javascript function. This works. The Javascript function calls a Flash function that was exposed with ExternalInterface.addCallback(). Sometimes, the Javascript produces the following error: TypeError: myFlash.testCallback is not a function. When the error happens, it affects all functions registered with addCallback(). Gaia and some of its included libraries use addCallback(), and calling those functions from Javascript also produces the TypeError. Waiting a long time before pressing the button in Flash doesn't solve the error. Having Flash re-try addCallback() periodically doesn't solve the error When the error occurs, ExternalInterface.available = true and ExternalInterface.objectID contains the correct name for the Flash embed object. When the error occurs, document.getElementById('myflashcontent') correctly returns the Flash embed object. From my Page class: public class MyPage extends AbstractPage { // declarations of stage instances and class variables // other functions override public function transitionIn():void { send_button.addEventListener(MouseEvent.MOUSE_UP, callJS); exposeCallbacks(); super.transitionIn(); } private function exposeCallbacks():void { trace("exposeCallbacks()"); if (ExternalInterface.available) { trace("ExternalInterface.objectID: " + ExternalInterface.objectID); try { ExternalInterface.addCallback("testCallback", simpleTestCallback); trace("called ExternalInterface.addCallback"); } catch (error:SecurityError) { trace("A SecurityError occurred: " + error.message + "\n"); } catch (error:Error) { trace("An Error occurred: " + error.message + "\n"); } } else { trace("exposeCallbacks() - ExternalInterface not available"); } } private function simpleTestCallback(str:String):void { trace("simpleTestCallback(str=\"" + str + "\")"); } private function callJS(e:Event):void { if (ExternalInterface.available) { ExternalInterface.call("sendTest", "name", "url"); } else { trace("callJS() - ExternalInterface not available"); } } } My Javascript: function sendTest(text, url) { var myFlash = document.getElementById("myflashcontent"); var callbackStatus = ""; callbackStatus += '\nmyFlash[testCallback]: ' + myFlash['testCallback']; //console.log(callbackStatus); var errors = false; try { myFlash.testCallback("test string"); } catch (err) { alert("Error: " + err.toString()); error = true; } if (!error) { alert("Success"); } } var params = { quality: "high", scale: "noscale", wmode: "transparent", allowscriptaccess: "always", bgcolor: "#000000" }; var flashVars = { siteXML: "xml/site.xml" }; var attributes = { id: "myflashcontent", name: "myflashcontent" }; // load the flash movie. swfobject.embedSWF("http://myurl.com/main.swf?v2", "myflashcontent", "728", "676", "10.0.0", serverRoot + "expressInstall.swf", flashVars, params, attributes, function(returnObj) { console.log('Returned ' + returnObj.success); if (returnObj.success) { returnObj.ref.focus(); } });

    Read the article

  • Store XML,update record in XML,retrive a specific record in XML stored on BB device

    - by user469999
    I am writing a blackberry application where i want to store the data returned by a web service in my BB device.Earlier i was going to use SQLite for storing the data in mobile but as i googled and also did programming using SQLite and found that some BB devices dont support SQLite library and fail to create the database.Then i decided to keep the data returned by webservice in a XML format on my BB device. I just want to know is there any method or way in blackberry through which i can parse the data stored in xml,update it,or directly access a particular record stored in the xml instead of traversing the whole xml n times and finding the matched record. Please guide me as i am new to storing data in BB device.Is the approach which i am thinking to store data in XML right or shall i use something else Thanks in advance Yogesh Chaudhari

    Read the article

  • MSSQL EXPRESS 2008 Stored Procedure execution time spikes periodically

    - by user156241
    I have a big stored procedure on a MSSQL 2008 Express SP2 database that gets run about every 200 ms. Normal execution time is about 50ms. What I am seeing is large inconsistencies in this run time. It will execute for while, say 50-100 times at 40-60ms which is expected, then seemingly at random the same stored procedure will take way longer, say 900ms or 1.5 seconds to run. Sometimes more than one call of the same procedure in a row will take longer too. It appears that something is causing sql server to slow down dramatically every minute or so, but I can't figure out what. There is no timing pattern between the occurences. I have the same setup on two different computers, one of which is a clean XP Pro load with no virus checking and nothing installed except SQL server. Also, The recovery options for all the databases are set to "Simple".

    Read the article

  • Interesting SQL Sorting Issue

    - by rofly
    It's crunch time, deadline for my most recent contract is coming in two days and almost everything is complete and working fine (knock on wood) except for one issue. In one of my stored procedures, I'm needing to return a result set as follows. group_id | name A101 | Craig A102 | Craig Z101 | Craig Z102 | Craig A101 | Jim A102 | Jim Z101 | Jim Z102 | Jim B101 | Andy B102 | Andy Z101 | Andy Z102 | Andy The names need to be sorted by the first character of the group id and also include the Z101/Z102 entries. By sorting strictly by the group id, I get a result set as follows: A101 | Craig A102 | Craig A101 | Jim A102 | Jim B101 | Andy B102 | Andy Z101 | Andy Z102 | Andy Z101 | Jim Z102 | Jim I really can't think of a solution that doesn't involve me making a cursor and bloating the stored procedure up more than it already is. I'm sure a great mind out there has an elegant solution and I'm eager to see what the community can come up with. Thanks a ton in advance.

    Read the article

  • SqlCommand - preventing stored proc call in other databases

    - by Moe Sisko
    When using SqlCommand to call a stored proc via RPC, it looks like it is possible to call a stored proc in a database other than the current database. e.g. : string storedProcName = "SomeOtherDatabase.dbo.SomeStoredProc"; SqlCommand cmd = new SqlCommand(storedProcName); cmd.CommandType = CommandType.StoredProcedure; I'd like to make my DAL code more restrictive, by disallowing potential calls to another database. One way might be to check if there are two periods (dots) in storedProcName above, and if so, throw an exception. Any other ideas/approaches ? Thanks.

    Read the article

  • Convert old NuSoap code into PHP core soap functions

    - by Enrique
    Hi I've been testing nuSoap with codeIgniter (PHP Framework) but seems nuSoap isn't prepared to work with latest php 5.3, even if I download a patched nusoap version for php 5.3 I have the following code: require_once(APPPATH.'libraries/NuSOAP/lib/nusoap'.EXT); //includes nusoap $n_params = array('CityName' => 'San Juan', 'CountryName' => 'Argentina'); $client = new nusoap_client('http://www.webservicex.net/globalweather.asmx?WSDL'); $client->setHTTPProxy("10.2.0.1",6588,"",""); $result = $client->call('GetWeather', $n_params); Can any1 help me to convert these functions into php soap functions? Including proxy function? Thanks a lot

    Read the article

  • Language Design: Combining Gotos and Functions

    - by sub
    I'm designing and currently rethinking a low-level interpreted programming language with similarities to assembler. I very soon came across the functions/loops/gotos decision problem and thought that while loops like while and for would be too high-level and unfitting, gotos would be too low level, unmaintainable and generally evil again. Functions like you know them from most languages that have return values and arguments aren't fitting in the language's concept either. So I tried to figure out something between a function and a goto which is capable of Recursion Efficient loops After some thinking I came up with the idea of subroutines: They have a beginning and an end like a function They have a name but no arguments like a goto You can go into one with jump and go out of it again before its end with return (doesn't give back any result, only stops the subroutine) Handled just like normal code - Global scope like goto So I wanted to know: Is the idea above good? What are the (dis)advantages? Would there be a better combination of function and goto or even a completely new idea?

    Read the article

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