function

Getting dimensions from background-image using jQuery

Hi, I'm loading a background image into a div. Is it possible to get the dimensions from this image? I'm trying to make a function that will replace text with images on the fly, for use in the menu. $.fn.MenuImages = function() { return this.each(function(i) { var name = $(this).find('a').attr('title'); $(this).css("backgrou...

how to bind one function to other

I have a function A that accepts a predicate function as its argument. I have another function B and it takes a char and returns an int, and a function C that accepts int and returns a bool. My question is how to bind B and C to pass it to function A. Something like: A(bindfunc(B,C)) I know boost::bind works but i am looking for ...

Counting distinct values in excel - frequency function

Counting distinct values in excel - frequency function yes I have read http://stackoverflow.com/questions/1425289/counting-distinct-values-in-excel-frequency-function I am try to count a column with different numbers column contains (search) 1 3 7 9 5 1 3 9 4 result looking for; C1 C2 1 = 2 2 = 0 3 = 2 4 = 1 etc ...

Delphi Assembly Function Returning a Long String

I am trying to learn inline assembly programming in Delphi, and to this end I have found this article highly helpful. Now I wish to write an assembly function returning a long string, specifically an AnsiString (for simplicity). I have written function myfunc: AnsiString; asm // eax = @result mov edx, 3 mov ecx, 1252 call Syste...

function called in function throwing undefined function error

using the object-oriented approach, i'm trying to call a public function in a function in the same class, but it throws an error: Call to undefined function h() php: class Name { . .. . public function h($s) { echo htmlspecialchars($s, ENT_QUOTES); } public function formatQuotes($row) { return "<p id...

Should small simple structs be passed by const reference?

I have always been taught that non-primitive types should be passed by const reference rather than by value where possible, ie: void foo(std::string str);//bad void foo(const std::string &str);//good But I was thinking today that maybe actually some simple user defined types may actually be better passed by value eg: class Vector2 { ...

A (somewhat obscure) Javascript inheritance question

I have been experimenting with a design pattern in Javascript that would allow me to have what appears to be singleton functions that can be overridden by instance functions. Here's a brief example: Date.tomorrow = function () { return Date.today().add(1).days(); } (function(p) { p.tomorrow = function() { var date = this.clon...

Wordpress: Adding class selectors to the_tags(); output

How do I get the_tags() to output each tag so that it comes assigned with a unique class selector? So for example: the_tags() currently outputs something like this: <a href="http://myblog.com/tag/kittens" rel="tag">kittens</a> However, I'd like to output something like this: <a href="http://myblog.com/tag/kittens" rel="tag" class="ta...

How to handle deprecated function in PHP

Hi all, I'm new in this site. I want to ask about PHP programming. How do we can handle deprecated function in PHP. I want to redirect it to my new function. As we know, ereg function has been deprecated in PHP 5.3.0 and recommended to preg_match (posix to PCRE). But, when we wrote a lot of code with ereg function, do we have to change ...

Compound argument declaration

To make my code more concise, can I do something like int f(int const x, y, z), g(int const x, y, z); to declare functions f and g which each take three int const arguments? Edit: Perhaps here is a better example: int f(int const a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z); How would that not be m...

Is it possible to optimize this function?

Hi, after profiling a lot I found out that this method takes up most of the % of calculation time. I don't really see a way to optimize, since it is a horrible function. (it is...) Maybe someone can show me some nice idea or so? public static double perceivedLoudness(double L_G, double L_ETQ, double a0) { double t1 = 1d + 1 / 4d * Ma...

Bind function trouble

Hello, I'm using boost (signals + bind) and c++ for passing function reference. Here is the code: #define CONNECT(FunctionPointer) \ connect(bind(FunctionPointer, this, _1)); I use this like this: class SomeClass { void test1() {} void test2(int someArg) {} SomeClass() { CONNECT(&SomeClass::test1); CONNECT(&S...

How can I call (not define) a function with a variable number of arguments in C?

Is there any way to make this code shorter? long call_f(int argc, long *argv) { switch (argc) { case 0: return f(); break; case 1: return f(argv[0]); break; case 2: return f(argv[0], argv[1]); break; case 3: return f(argv[0], argv[1], argv[2]); break; case 4: re...

Excel: Find value in column(s)

I've got an Excel spreadsheet with multiple columns of different lengths, each filled with unsorted numbers. Each column has a header. Is there a way to determine which column(s) contain that number? For instance, I'd love to be able to do =WHICHCOLS( 123, A, Z ) and have Excel tell me columns [B, C, and K] contain cells with a value ...

difference between :: and -> in calling class's function in php

I have seen function called from php classes with :: or ->. eg: $classinstance::function or $classinstance->function whats the difference? ...

rand() faster mysql php function

Hi How do I select wallpapers randomly, but cache the last selected one for 10 seconds (for performance reasons)? the faster RAND() function use Cache in wallpapers or image i use this but i need to but cache in image timely change after 1 mins or 5 mins to chnage images in RAND() randoms wallpapers i use this : $sql_wallpaper = "S...

New Function: How to iterate through all form elements before returning true or false

Hi there, I have a new function that I will be calling when the submit button is pressed for the form. I'm trying to use this validation, not a plug-in, for experience. How would I iterate through all the forms, determine if they're all valid, before exiting out of the function. Though if they're all valid, return true and continue, othe...

PHP: How to calculate person age in months.

I have searched for this but did not find a perfect function in php. I want to get a php function that calculate person age only in months. For example: less then one month old. 5 months old. 340 months old. Thanks ...

php array bitwise

if I have an array of flags and I want to combine them with a bitwise conjunction ie: $foo = array(flag1, flag2); into $bar = flag1 | flag2; Does PHP have any good functions that will do this nicely for me already? ...

Jquery call function from a string

Hello, Is it possible to call a function by using the strings ?. i.e i have a variable var target = 'next';. Using this string i want to call the jquery method next() . Should i use target + '()' (this is bit foolish) to call next() ??? I know it can be done using conditional statements. Since it is a var got from users, it is a heav...