function

Autocompletion based on filenames in a directory

Hi there, I want to have a function in my zsh for faster accessing my todo-files. It should look inside the folder ~/tasks where i put my todo-lists and stuff. Now i want to type task p and when I hit tab, it should use the files in that directory for autocompletition. Can anyone point me some direction? Or share some snippet to work wi...

Making a function for selecting from MySQL, how is mine?

This is my first time. I will appreciate any thoughts, tips, and what not. How can I improve this? Ultimately, I don't want so many selects in my script. I don't know what should a MySQL type of function consist of. Any inputs on what I should include would be great also, such as mysql_query(). function mysqlSelectCodes($table, $wh...

How to determine magnitude of trigonometric function? C++

> if (((test>=0) && (test<=90)) || ((test>270) && (test<=360))){n_y=1;} > else {n_y=-1;} I need the magnitude of trigonometric function in order to determine the sign of the trigonometric function for an angle falling into a particular quadrant. My plan is to replace the code above with something equivalent. Here is what I w...

Pass a function as parameter in jQuery?

Hello, I would like to pass to a jQuery function a regular function, instead of the usual anonymous function, but I'm not sure how such a thing could be done. Instead of this: function setVersion(feature) { $.post("some.php", { abc:"abc" }, function(data){ // do something here }, "json"); } I would like to...

Adding a method to a function object at runtime

I read a question earlier asking if there was a times method in Python, that would allow a function to be called n times in a row. Everyone suggested for _ in range(n): foo() but I wanted to try and code a different solution using a function decorator. Here's what I have: def times(self, n, *args, **kwargs): for _ in range(n): ...

Copy Constructors and calling functions

Hello, I'm trying to call an accessor function in a copy constructor but it's not working. Here's an example of my problem: A.h class A { public: //Constructor A(int d); //Copy Constructor A(const A &rhs); //accessor for data int getData(); //mutator for data void setData(int d); private: int d...

C++ Function arguments validation (pointer vs. reference arguments)

Possible Duplicate: When pass-by-pointer is preferred to pass-by-reference in C++? Hello everyone, What do you consider a better programming practice: passing objects as pointers or references to functions. What do you do for input validation? Thanks. ...

Nested function inside literal Object...

Hello guys, if in a literal object i try to reference a function using "this" inside a nested property/function, this don't work. Why? A nested property have it's own scope? For example, i want to call f1 from inside d.f2: var object = { a: "Var a", b: "Var b", c: "Var c", f1: function() { alert("This is f1"); }, ...

Treat a void function as a value

I'm writing some terrible, terrible code, and I need a way to put a free() in the middle of a statement. The actual code is: int main(){ return printf("%s", isPalindrome(fgets(malloc(1000), 1000, stdin))?"Yes!\n":"No!\n") >= 0; // leak 1000 bytes of memory } I was using alloca(), but I can't be sure that will actually work on ...

JS: how to call a public method that is defined like this: this.name = function(){return 2;}

var CoreGroups = new function(){ this.name = function(){return 'name test'}; var functionName = function(){ // here I want to call the name() function a = this.name(); // doesnt work: this.name is not a function b = name(); // doesn't work too: name is not defined } } Any idea on how...

PL/PGSQL function, having trouble accessing a returned result set from psycopg2...

I have this pl/pgsql function: CREATE OR REPLACE FUNCTION get_result(id integer) RETURNS SETOF my_table AS $ DECLARE result_set my_table%ROWTYPE; BEGIN IF id=0 THEN SELECT INTO result_set my_table_id, my_table_value FROM my_table; ELSE SELECT INTO result_set my_table_id, my_table_v...

jquery callback function

i use recaptcha Recaptcha.create("xxx", "recaptcha", { theme: 'clean', tabindex: 0, callback: $("#id").focus }); i want to use callback to focus some field, but it doesn't work, only callback: f works function f() { $("#FIO").focus(); } what is the problem? ...

Calling and writing jquery/javascript functions

I think I have not got the syntax correct for writing a javascript function and calling it to assign its return value to a variable. My function is: getObjName(objId){ var objName =""; $.ajax( { type : "GET", url : "Object", dataType: 'json', data : "objId="+objId, success : function(data) { objName = data; ...

postgres - ERROR: syntax error at or near "COST"

EDIT Taking COST 100 out made the command go through, however, I'm still unable to run my query because it yields this error: ERROR: function group_concat(character) does not exist HINT: No function matches the given name and argument types. You may need to add explicit type casts. The query I'm running is this: select tpid, group_...

How to get list of declared functions with their data from php file?

I need to get list of functions with their contents (not only the function name) from php file. I tried to use regex but it has lots of limitations. it doesn't parse all types of functions. for example it fails if the function has if and for loop statements. in details: I have around 100 include files. each file has number of declared f...

How to determine the best case and worst case of an program(algorithm)?

Suppose I have this program, I want to compare 2 input lists. Assume array A and array B. How do I determine the best case and worst case of the function? Here is my code in [php]: foreach($array_1 as $k){ if(!in_array($k, $array_2)){ array_push($array_2, $k); } } What is the best case and worst case of the for loo...

calling function in radiobutton group

with your help, i am now able to call the function for each radio button. however, i get a error message Reference to non-existent field 'ics_si' ics_si is my function, which has the following code, i do not know where i am making a mistake i have created the edit box for user to input the values for bore and stroke. and vdisp is cal...

Return via an abstract protected function?

I'm looking at the auth class in Kohana 3 as well as a login script. When the login page calls the login function of the auth class, it is returned via a protected abstract function _login. Why would you do that out of curiosity? I can't seem to understand what would really be the difference since you'd be returning the same data eith...

How to find the formula of best case and worst case of my algorithm?

I was given a task. Write an algorithm so that, the input of 2 lists of data, will have at least one in common. So, this is my algorithm: (I write the code in php) $arrayA = array('5', '6', '1', '2', '7'); $arrayB = array('9', '2', '1', '8', '3'); $arrayC = array(); foreach($arrayA as $val){ if(in_array($val, $arrayB)){ ar...

Sorting the order of growth of the functions?

Please order the function belows by growth rate from fastest to slowest: n^10 2^n nlog(n) 10^6 And my answer is: 2^n n^10 nlog(n) 10^6 Is my answer correct? ...