How do you initialise a constant in a header file?
For example:
@interface MyClass : NSObject {
const int foo;
}
@implementation MyClass
-(id)init:{?????;}
If you have a bean with a getFoo method, how does whatever framework you're using know how to call the getFoo method when you ask for the value of foo? Is this done using the reflection API? Or is it somehow done using annotations? Obviously I know how you can derive the method given the name of the property, I just don't know how the method is invoked.
I have a difficult problem with a recursive function. Essentially I need to 'slow down' a for loop within a function that repeatedly calls itself(the function);
Is this possible, or do I need to somehow extract the recursive nature of the function?
function callRecursiveFuncAgain(ob:Object):void{
//do recursive stuff;
for (var i:int = 0; i < 4; i++) {
_nextObj=foo
callRecursiveFuncAgain(_nextObj);
}
}
I have a table like this
foo(id, parentId)
-- there is a FK constraint from parentId to id
and I need to delete an item with all his children and children of the children etc.
anybody knows how ?
Consider an object declared in a method:
public void foo() {
Object obj = new Object();
// A long run job that consumes tons of memory and
// triggers garbage collection
}
Is obj subject to garbage collection?
Is there a good "scala-esque" (I guess I mean functional) way of recursively listing files in a directory? What about matching a particular pattern?
For example recursively all files matching "a*.foo" in c:\temp.
Given the following function:
def foo(a, b, c):
pass
How would one obtain a list/tuple/dict/etc of the arguments passed in?
Specifically, I'm looking for Python's version of JavaScript's arguments keyword or PHP's func_get_args() method.
What I'm not looking for is a solution using *args or **kwargs; I need to specify the argument names in the function definition (to ensure they're being passed in) but within the function I want to work with them in a list- or dict-style structure.
Here's the quick version of the code as it stands right now:
function foo(attributeName, someJSObj, key, newValue)
{
someJSObj[key].attributeName = newValue;
}
Obviously this doesn't work, since it just creates a new element called attributeName. Is there an easy way to dereference the attributeName into the string that represents some existing attribute on someJSObj?
I've got quite a few SQL statements like such:
SELECT foo FROM things WHERE user_id IN (1,2,3..n)
Is there a known limit to the number of elements that will safely fit in an IN clause like that?
I am not very familiar with the Javascript syntax bellow. Can anyone shade light about the sense of this block? For what purpose?
(function foo() {
alert('bar');
})();
Thanks in advance.
Situation: I have this log4j logger:
private static final Logger logger = Logger.getLogger(ThisClassName.class);
And am trying to set it programatically through:
Logger.getLogger(ThisClassName.class).setLevel(Level.DEBUG);
Still, DEBUG level prints are swalloed (while INFO prints are printed successfully).
Even this bit has no effect: Logger.getRootLogger().setLevel(Level.DEBUG);
Calling logger.debug("foo") reaches Category.forcedLog() and ConsoleAppender.doAppend(), and then fails (quits) at:
if(!isAsSevereAsThreshold(event.getLevel()))
Any idea why this is happening?
I'm relatively new to C, and am curious what this syntax means in a function declaration:
int DEFAULT_CC foo(void)
where DEFAULT_CC is probably defined somewhere else as:
#define DEFAULT_CC "cc"
Is this a direction to use a certain compiler or something?
I have a scenario where I'm calculating something in the WHERE clause of my SQL, but I also want to get that calculation - since it's expensive. Is it possible to get the results of something done in the WHERE clause, like this:
SELECT `foo` FROM `table` WHERE (foo = LongCalculation())
Wishful thinking, or possible with MySQL?
I want to make a Wrapper class for ActiveMQ which will have only send and get functions. I want to wrap them in a static class. Users can use this client and send, get messages to the activemq instance.
I want this process to be transparent. There are two classes in this link
My only handicap is, i need to this in c++ and not sure where to start. I havent used c++ for ages and now not sure how I can create this wrapper class.
I m giving it a try as follows:
// .h file
#include <stdlib.h>
#include <iostream>
using namespace std;
class ActiveMQWrapper
{
public:
static void send(std::string message);
static std::string get();
};
// .cpp file
#include<string>
#include<iostream>
#include "ActiveMQWrapper.h"
void ActiveMQWrapper::send(std::string message){
std::cout<<message;
}
std::string ActiveMQWrapper::get(){
return "test";
}
// test file
#include <string>
#include <iostream>
#include "ActiveMQWrapper.h"
int main() {
std::string foo ="test";
ActiveMQWrapper::send(foo);
std::cout<<ActiveMQWrapper::get();
return 1;
}
When I added the following to .h file, hell breaks loose. Do you think I should seperate this impl to a factory and initialize and instance and return to the wrapper above? How do i deal with all the dependencies?
private:
Connection* connection;
Session* session;
Destination* destination;
MessageProducer* producer;
int numMessages;
bool useTopic;
bool sessionTransacted;
std::string brokerURI;
and the header files, i get several messages as errors, which complains about the path.
How can i get this correct? I eventually want to build a Factory, get an instance and send or get the messages to the queue.
is there a code sample i can look into to get this right? essential i want to use the functionality of only this producer and consumer.
Edit: I understand there is no such thing as static class in C++ . This is my reference.
what is the best way to make my php code working on one domain
and sure i will encode the whole code by ioncube
i want function like
function domain(){
}
if($this_domain <> domain()){
exit('no');
}
or
$allowed_hosts = array('foo.example.com', 'bar.example.com');
if (!isset($_SERVER['HTTP_HOST']) || !in_array($_SERVER['HTTP_HOST'], $allowed_hosts)) {
header($_SERVER['SERVER_PROTOCOL'].' 400 Bad Request');
exit;
}
now i want know the best way to do that
may be will user strpos
Is it possible to pass two lists to a sub in Perl , ex
sub Foo {
my(@list1,@list2) = @_;
}
I know I could make @_ two lists, with each sublist being the desired argument, I'm just wondering if there is a cleaner way
I'm looking for a regex to search my python program to find all lines where foo, but not bar, is passed into a method as a keyword argument. I'm playing around with lookahead and lookbehind assertions, but not having much luck.
Any help?
Thanks
Hi,
can a MySQL slave instance have different row values for the same ID when binlog_format is set to STATEMENT and we insert something like:
insert into foo values(CURRENT_TIMESTAMP)
As I understand it, the slave read the SQL statement and execute it thus, if the replication is lagging, could lead to differences for the same row. Right or wrong ?
How can I avoid this situation ?
Thank you.
I have a list which contains a number of things:
lista = ['a', 'b', 'foo', 'c', 'd', 'e', 'bar']
I'd like to get the first item in the list that fulfils a predicate, say len(item) > 2. Is there a neater way to do it than itertools' dropwhile and next?
first = next(itertools.dropwhile(lambda x: len(x) <= 2, lista))
I did use [item for item in lista if len(item)>2][0] at first, but that requires python to generate the entire list first.
consider a standard c# 'function'
public void foo()
{
//some code
}
In c or c++ this is called a 'function' - even if taking no parameters and returning no value. In another language maybe it would be a 'procedure'.
In object orientation speak it would be called a 'method' if a class member.
What would be the correct term to use in c#?
I'd like to know how to use XMLHttpRequest to load the content of a remote URL and have the HTML of the accessed site stored in a JS variable.
Say, if I wanted to load and alert() the HTML of http://foo.com/bar.php, how would I do that?
Is it possible to store a type name as a C++ variable? For example, like this:
type my_type = int; // or string, or Foo, or any other type
void* data = ...;
my_type* a = (my_type*) data;
I know that 99.9% of the time there's a better way to do what you want without resorting to casting void pointers, but I'm curious if C++ allows this sort of thing.