I'm currently developing a tutorial site for teaching the fundamentals of Web development (HTML, CSS, and JavaScript, for starters). I'd like a setup where I could give in-depth coverage of all sorts of topics and then provide a basic sandbox environment where the user could write code which solves the question asked at the end of each t...
I'm using a Python API that expects me to pass it a function. However, for various reasons, I want to pass it a method, because I want the function to behave different depending on the instance it belongs to. If I pass it a method, the API will not call it with the correct 'self' argument, so I'm wondering how to turn a method into a fu...
I have a multiple menu's on my page which all use the same mouseover and click events, so I decided to get it into a function. However vars seem to always be assigned to the last of the arguments for the hover(function, function) function.
$(document).ready( function() {
menuMouseOver = function() {
for(i=0, u=arguments.length; i<u;...
I'm using the sqlite C API.
"Everything" is run in the main function (variables, open, execute a query, close the database, etc.)
In addition, I would like to now create separate user defined functions where I do, for example, a sort on the database.
What is the best method to pass the db objects and variables from main to this new fu...
Is it possible to get a list of the user defined functions in javascript?
I'm currently using this but it returns functions which aren't user defined:
var functionNames = [];
for (var f in window) if (window.hasOwnProperty(f) && typeof window[f] === 'function')
{
functionNames.push(f);
}
...
Hi,
I am wondering whats the best practices regarding functions and objects. For example I want to perform an action called tidy. It will take my data as input and tidy it and return it.
Now I can do this in two ways. One using a simple function and the other using a class.
Function: $data = tidy($data);
Class:
$tidy = new Tidy();
$da...
I read that you should define your javascript functions in the <head> tag, but how does the location of the <script> (whether in the <head>, <body>, or any other tag) affect a javascript function.
Specifically, I would like to know how does it affect the scope of the function and where you can call it from?
...
I'm going back to the basics here but in Lua, you can define a table like so:
myTable = {}
myTable [1] = 12
Printing the table reference itself brings back a pointer to it. To access its elements you need to specify an index (i.e. exactly like you would an array)
print(myTable ) --prints pointer
print(myTable[1]) --prints 12
N...
Maybe Im to tired, but this seems to be a vary basic question. Suddenly my inheritance chain stopped working. Writing a small basic test application proved that it was me that was wrong (so I cant blame the compiler).
I have a base class, with the default behavior in a virtual function. A child class derives from that and changes the be...
Hello!
I am writing a Makefile with a lot of repetitive stuff, e.g.
debug_ifort_Linux:
if [ $(UNAME) = Linux ]; then \
$(MAKE) FC=ifort FFLAGS=$(difort) PETSC_FFLAGS="..." \
TARGET=$@ LEXT="ifort_$(UNAME)" -e syst; \
else ...
The website is almost entirely d/x/html, and is hosted on a linux/apache server.
While I'm not opposed to using a database, I've been told that I can implement a solution that parses through the html documents and returns my search results without mucking about too much with asp/php/cgi (which I am most certainly a novice in).
Is this ...
What's the reason of passing a value for a self reference in class functions in python? For instance:
class MyClass:
"""A simple example class"""
i = 12345
def f(**self**):
return 'hello world'
By doing this, aren't you doing the compiler's work?
...
I have a system where I send an Ajax command, which returns a script block with a function in it. After this data is correctly insert in the DIV, I want to be able to call this function to preform the required actions.
Is this possible?
...
Hi,
I have a url like http://www.example.com/blah/th.html
I need a javascript function to give me the 'th' value from that.
All my urls have the same format (2 letter filenames, with .html extension).
I want it to be a safe function, so if someone passes in an empty url it doesn't break.
I know how to check for length, but I should ...
On a regular basis, I validate my function arguments:
public static void Function(int i, string s)
{
Debug.Assert(i > 0);
Debug.Assert(s != null);
Debug.Assert(s.length > 0);
}
Of course the checks are "valid" in the context of the function.
Is this common industry practice? What is common practice concerning function argumen...
It seems like in most mainstream programming languages, returning multiple values from a function is an extremely awkward thing. The typical solutions are to make either a struct or a plain old data class and return that, or to pass at least some of the parameters by reference or pointer instead of returning them. Using references/poin...
Does Python have extension methods like C#? Is it possible to call a method like:
MyRandomMethod()
on existing types like int?
myInt.MyRandomMethod()
...
Given a function, I'm trying to find out the names of the nested functions in it (only one level deep).
A simple regex against toString() worked until I started using functions with comments in them. It turns out that some browsers store parts of the raw source while others reconstruct the source from what's compiled; The output of toSt...
I have a large work space which has many source files of C code. Although I can see the functions called from a function in MS VS2005 using the Object browser, and in MSVC 6.0 also, this only shows functions called from a particular function in a non-graphical kind of display. Additionally, it does not show the function called starting f...
I have a variable on the global scope that is named ${SYSTEM}, where SYSTEM is a defined constant. I've got a lot of classes with functions that need to have access to this variable and I'm finding it annoying declaring global ${SYSTEM}; every single time.
I tried declaring a class variable: public ${SYSTEM} = $GLOBALS[SYSTEM]; but this...