function

Javascript Window.Onload Function Chaining

Just for the sake of experimentation, I've been trying to determine different ways to non-destructively chain window.onload functions in a web browser. This is the idea of what I have so far: var load = window.onload; var newFunction = function(){ alert("ha!"); } window.onload = function(){ load(); newFunction(); } The pro...

Get all the defined functions for an object

Is there an equivalent of get_defined_functions() which only shows the functions of a given object? Example usage and output: class A { function foo() { } function bar() { } } class B extends A { function foobar() { } } $b = new B(); print_r(get_object_functions($b)); // Array ( // 0 => "foo", // 1 => "bar", // 2 => "fo...

call a function when the program is finished with ctrl c

Hello, I am working in the Linux environment, and I have a C++ program, what I want is when I cancel the program with ctrl+c I would like that the program executes a function, to close some files and print some sutff, is there any way to do this?. Thank you. ...

Oracle function concurrency

I currently have an INSERT TRIGGER which in Oracle 10g runs a custom defined function that generates a funky alpha-numeric code that is used as part of the insert. I really need to make sure that the function (or even trigger) is thread safe so that if two users activate the trigger at once, the function used within the trigger does NOT...

Passing parameters to a JQuery function.

Hello, ive a problem using JQuery.. Im creating a HTML with a loop and it has a column for Action, that column is a HyperLink that when the user click the link call a JavaScript function and pass the parameters... example: <a href="#" OnClick="DoAction(1,'Jose');" > Click </a> <a href="#" OnClick="DoAction(2,'Juan');" > Click </a> <a ...

What's the point of strspn?

At work today we were trying to come up with any reason you would use strspn. I searched google code to see if it's ever been implemented in a useful way and came up blank. I just can't imagine a situation in which I would really need to know the length of the first segment of a string that contains only characters from another string. ...

How can I pass a reference to a function, with parameters?

I need to able to pass a reference to a function with a given set of parameters. Here is an example of passing a reference without parameters: var f = function () { //Some logic here... }; var fr = f; //Here I am passing a reference to function 'f', without parameters fr(); //the 'f' function is invoked, without parameters Now w...

Mathematical Derivation with C#?

How can I do some more advanced function. I see that I can do function with public double myFunction(double myParameter) but what if I do want to derive that function? ...

Lat/Lon + Distance + Heading --> Lat/Lon

Hello... So: I have the following function, adapted from a formula found online, which takes two lat/lon coordinates and finds the distance between them in miles (along a spherical Earth): public static double distance (double lat1, double lon1, double lat2, double lon2) { double theta = toRadians(lon1-lon2); lat1 = toRadians...

lightweight boost::bind

I'm so sick of the pass-callback-data-as-void*-struct anti-pattern. Boost bind solves it nicely, but is an unacceptable dependency. What's a lightweight alternative? How would I write it myself as simply as possible? ...

Ruby (Shoes) - Wait for function to return value

I have a function that presents the user a combo-box. def select_interface(interfaces) list_box :items => interfaces do |list| interface = list.text end ### ideally should wait until interface has a value then: ### return interface end The rest of the program depends on the selection from this combo-box. I would like to f...

Do you prefer functioning or including within one php file?

Hi, How do you manage your php codes? Do you prefer functioning within one php file or including larger blocks of "raw code"? Edit: In fact, my code is pretty nasty, as I don't use any namespaces and classes - only functions and including. I shall look the classes up ^^. ...

JavaScript implementation that allows access to [[Call]]

The ECMA standard defines a hidden, internal property [[Call]], which, if implemented, mean the object is callable / is a function. In Python, something similar takes place, except that you can override it yourself to create your own callable objects: >>> class B: ... def __call__(self, x,y): print x,y ... >>> inst = B() >>> inst(1...

Generic Data Access functions

What is the best way to code the following generic data access functions (ADO.NET, C# or VB, SQLServer or OLEDB) Execute SQL on a connection Open a DataReader Open a DataSet (any ideas on this one?) Such that I can call these functions from anywhere in my program. I'm not interested in Data Access patterns or Data Access layers unle...

How does Java pick which overloaded function to call?

This is a purely theoretical question. Given three simple classes: class Base { } class Sub extends Base { } class SubSub extends Sub { } And a function meant to operate on these classes: public static void doSomething(Base b) { System.out.println("BASE CALLED"); } public static void doSomething(Sub b) { System.out.println...

How does C++ pick which overloaded function to call?

Say I have three classes: class X{}; class Y{}; class Both : public X, public Y {}; I mean to say I have two classes, and then a third class which extends both (multiple-inheritance). Now say I have a function defined in another class: void doIt(X *arg) { } void doIt(Y *arg) { } and I call this function with an instance of both: ...

Problem looping data in a postgres function using %ROWTYPE

Hi all... I am trying to create a function in postgres that retrieves data from one table and inputs into another. I am using the %ROWTYPE type to store the temporary data from the select statement and then iterate through it with an insert statement but have been unsuccessful! The following is my code : CREATE OR REPLACE FUNCTION rm_...

Get signatures of exported functions in a DLL

Is it possible to get an exported (C style?) function's signature (parameter count/types, return type) from a DLL? I can view the list of function names, addresses, ordinals, etc. with DLL Export Viewer but I can't view the signatures. I only have the dll file and don't have neither .h nor .def files. UPDATE: Using a tool called API Mon...

Disjointed swap multiple image from jpg to swf

My original question was "Is there a javascript function to swap a still image(jpg) to a movie(swf)? If there is is there a disjointed swap image path?" Jack's answer worked but did not have a disjointed rollover. His function imgToSWF works great but it isn't what is needed. What I need is to have multiple thumbnail images(jpgs) that w...

Are there any programming languages with functions with variable arguments not at the end?

Python, C++, Scheme, and others all let you define functions that take a variable number of arguments at the end of the argument list... def function(a, b, *args): #etc... ...that can be called as followed: function(1, 2) function(1, 2, 5, 6, 7, 8) etc... Are there any languages that allow you to do variadic functions with the ...