Search Results

Search found 332 results on 14 pages for 'baz'.

Page 3/14 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Clarification on ZVals

    - by Beachhouse
    I was reading this: http://www.dereleased.com/2011/04/27/the-importance-of-zvals-and-circular-references/ And there's an example that lost me a bit. $foo = &$bar; $bar = &$foo; $baz = 'baz'; $foo = &$baz; var_dump($foo, $bar); /* string(3) "baz" NULL */ If you’ve been following along, this should make perfect sense. $foo is created, and pointed at a ZVal location identified by $bar; when $bar is created, it points at the same place $foo was pointed. That location, of course, is null. When $foo is reassigned, the only thing that changes is to which ZVal $foo points; if we had assigned a different value to $foo first, then $bar would still retain that value. I learned to program in C. I understand that PHP is different and it uses ZVals instead of memory locations as references. But when you run this code: $foo = &$bar; $bar = &$foo; It seems to me that there would be two ZVals. In C there would be two memory locations (and the values would be of the opposite memory location). Can someone explain?

    Read the article

  • Web application

    - by Baz
    hi guys, its my first web application in real world and am very much confuse from the beginning am working on Merchandise suppliers application, which includes various type of products. for an instance Home products cloths men t-shirts add basket send information to my client, I don’t need to add PayPal , just need to send information to my client , So far I have done , analysis , site structure , page designing am confuse about database designing Can any one help me out or send me some example step by step how should I begin with it .

    Read the article

  • const pod and std::vector

    - by Baz
    To get this code to compile: std::vector<Foo> factory() { std::vector<Foo> data; return data; } I have to define my POD like this: struct Foo { const int i; const int j; Foo(const int _i, const int _j): i(_i), j(_j) {} Foo(Foo& foo): i(foo.i), j(foo.j){} Foo operator=(Foo& foo) { Foo f(foo.i, foo.j); return f; } }; Is this the correct approach for defining a pod where I'm not interested in changing the pod members after creation? Why am I forced to define a copy constructor and overload the assignment operator? Is this compatible for different platform implementations of std::vector? Is it wrong in your opinion to have const PODS like this? Should I just leave them as non-const?

    Read the article

  • Including typedef of child in parent class

    - by Baz
    I have a class which looks something like this. I'd prefer to have the typedef of ParentMember in the Parent class and rename it Member. How might this be possible? The only way I can see is to have std::vector as a public member instead of using inheritance. typedef std::pair<std::string, boost::any> ParentMember; class Parent: public std::vector<ParentMember> { public: template <typename T> std::vector<T>& getMember(std::string& s) { MemberFinder finder(s); std::vector<ParentMember>::iterator member = std::find_if(begin(), end(), finder); boost::any& container = member->second; return boost::any_cast<std::vector<T>&>(container); } private: class Finder { ... }; };

    Read the article

  • Input Iterator for a shared_ptr

    - by Baz
    I have an iterator which contains the following functions: ... T &operator*() { return *_i; } std::shared_ptr<T> operator->() { return _i; } private: std::shared_ptr<T> _i; ... How do I get a shared pointer to the internally stored _i? std::shared_ptr<Type> item = ??? Should I do: MyInterfaceIterator<Type> i; std::shared_ptr<Type> item = i.operator->(); Or should I rewrite operator*()?

    Read the article

  • nginx dynamic virtual hosts

    - by Anagio
    With nginx is there a method to setup mass dynamic virtual hosts similar to the way apache2 can be configured? I'm setting up an saas application each user will have their own subdomain and i'd like to use nginx over apache2. Thanks Code below should be how to configure map $http_host $subdir { hostnames; default "default"; .foo.bar.com "foo"; .baz.bar.com "baz"; } server { root /path/to/$subdir; }

    Read the article

  • WordPress: Problem with the shortcode regex

    - by peroyomas
    This is the regular expression used for "shortcodes" in WordPress (one for the whole tag, other for the attributes). return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/'; It parses stuff like [foo bar="baz"]content[/foo] or [foo /] In the WordPress trac they say it's a bit flawed, but my main problem is that it don't support shortcodes inside the attributes, like in [foo bar="[baz /]"]content[/foo] because the regex stops the main shortcode at the first appearance of a closing bracket, so in the example it renders [foo bar="[baz /] and "]content[/foo] shows as it is. Is there any way to change the regex so it bypass any ocurrence of [ with ] and its content when occurs between the opening tag or self-closing tag?

    Read the article

  • Avoiding symbol capture when using macros to generate functions (or other macros)

    - by Rob Lachlan
    I'm a bit confused as to exactly when symbol capture will occur with clojure macros. Suppose that I have a macro which defines a function from keywords. In this trivial example, (defmacro foo [keywd1 keywd2] `(defn ~(symbol (name keywd1)) [~(symbol (name keywd2))] (* 2 ~(symbol (name keywd2))))) I call (foo :bar :baz), and this gets expanded into (defn bar [baz] (* 2 baz)). So now the question -- can this lead to symbol capture? If so, under what circumstances? I know that it's preferred to use gensym (e.g. bar#) to prevent symbol capture, but in some cases (not many, but still) I'd like to have a pretty macro-expansion, without the auto-generated symbols. Bonus question: does the answer change if we are considering a macro that creates macros?

    Read the article

  • Why is the meaning of “ours” and “theirs” reversed with git-svn

    - by Marc Liyanage
    I use git-svn and I noticed that when I have to fix a merge conflict after performing a git svn rebase, the meaning of the --ours and --theirs options to e.g. git checkout is reversed. That is, if there's a conflict and I want to keep the version that came from the SVN server and throw away the changes I made locally, I have to use ours, when I would expect it to be theirs. Why is that? Example: mkdir test cd test svnadmin create svnrepo svn co file://$PWD/svnrepo svnwc cd svnwc echo foo > test.txt svn add test.txt svn ci -m 'svn commit 1' cd .. git svn clone file://$PWD/svnrepo gitwc cd svnwc echo bar > test.txt svn ci -m 'svn commit 2' cd .. cd gitwc echo baz > test.txt git commit -a -m 'git commit 1' git svn rebase git checkout --ours test.txt cat test.txt # shows "bar" but I expect "baz" git checkout --theirs test.txt cat test.txt # shows "baz" but I expect "bar"

    Read the article

  • Can I make clojure macro that will allow me to get a list of all functions created by the macro?

    - by Rob Lachlan
    I would like to have a macro which I'll call def-foo. Def-foo will create a function, and then will add this function to a set. So I could call (def-foo bar ...) (def-foo baz ...) And then there would be some set, e.g. all-foos, which I could call: all-foos => #{bar, baz} Essentially, I'm just trying to avoid repeating myself. I could of course define the functions in the normal way, (defn bar ...) and then write the set manually. A better alternative, and simpler than the macro idea, would be to do: (def foos #{(defn bar ...) (defn baz ...)} ) But I'm still curious as to whether there is a good way for the macro idea to work.

    Read the article

  • Drying repeated specs in RSpec

    - by snl
    In the test below, the Bar and Baz blocks contain identical specs. Leaving aside why such repetition was necessary in the first place, I'm wondering how one could dry this up. I tried turning the blocks into objects and calling them under Bar and Baz, but possibly because I did not get the scopes right, I have not been able to make it work. describe Foo do describe Bar do before(:each) do prepare end it "should do something" do true end it "should do something else" do true end end describe Baz do before(:each) do prepare_something_else end it "should do something" do true end it "should do something else" do true end end end

    Read the article

  • ANDing javascript objects together

    - by Jonas
    I ran across this chunk of code (modified) in our application, and am confused to how it works: function someObject() { this.someProperty = {}; this.foo = { bar: { baz: function() { return "Huh?" } } }; this.getValue = function() { return (this.someProperty && this.foo.bar && this.foo.bar.baz && this.foo.bar.baz()) || null; } } function test() { var o = new someObject(); var val = o.getValue(); alert(val); } when you call the test() function, the text "Huh?" is alerted. I'm not sure how the result of getValue is returning that, I would've thought doing A && B && C && D would have returned true, rather than the value of D.

    Read the article

  • URLs with query stripped of ampersands appearing in error logs

    - by Jeremy DeGroot
    I've noticed a curious phenomena popping up in my error logs recently. If, as the result of processing a form, I redirect my users to the URL http://www.example.com/index.php?foo=bar&bar=baz, I will see the following two URLs in my log http://www.example.com/index.php?foo=barbar=baz http://www.example.com/index.php?foo=bar&bar=baz The first one is obviously incorrect and will cause my application to redirect to a 404. It always appears first, usually a second before the second one. The 404 page is not doing the redirection, so it appears that the browser is trying both versions. At first, looking at my server logs made me believe it affected only Firefox 3.6.3, but I've found an example of Safari being afflicted as well. It happens fairly intermittently, though it can occur multiple times in a users' session. I've never been able to get it to happen to me. Any thoughts as to the nature of the problem or a solution?

    Read the article

  • What is the scope of require_once in PHP?

    - by TMG
    Simple question: Is the scope of require_once global? For example: <?PHP require_once('baz.php'); // do some stuff foo ($bar); function foo($bar) { require_once('baz.php'); // do different stuff } ?> When foo is called, does it re-parse baz.php? Or does it rely on the already required file from the main php file (analagous to calling require_once twice consecutively for the same include file)? I saw this thread before, but it didn't quite answer the question: http://stackoverflow.com/questions/1669707/should-require-once-some-file-php-appear-anywhere-but-the-top-of-the-file Thanks for your help!

    Read the article

  • C++ method chaining including class constructor

    - by jena
    Hello, I'm trying to implement method chaining in C++, which turns out to be quite easy if the constructor call of a class is a separate statement, e.g: Foo foo; foo.bar().baz(); But as soon as the constructor call becomes part of the method chain, the compiler complains about expecting ";" in place of "." immediately after the constructor call: Foo foo().bar().baz(); I'm wondering now if this is actually possible in C++. Here is my test class: class Foo { public: Foo() { } Foo& bar() { return *this; } Foo& baz() { return *this; } }; I also found an example for "fluent interfaces" in C++ (http://en.wikipedia.org/wiki/Fluent_interface#C.2B.2B) which seems to be exactly what I'm searching for. However, I get the same compiler error for that code. Thanks in advance for any hint. Best, Jean

    Read the article

  • C++: Cannot convert from foo& to foo*

    - by Rosarch
    I have a method: odp(foo& bar); I'm trying to call it: foo baz; odp(&baz); I get a compiler error: error C2664: "odp" cannot convert parameter 1 from 'foo *' to 'foo &' What am I doing wrong? Aren't I passing in a reference to baz? UPDATE: Perhaps I have a misconception about the relationship between pointers and references. I thought that they were the same, except references couldn't be null. Is that incorrect?

    Read the article

  • replace capturing group

    - by Don
    Hi, If I have a regex with a capturing group, e.g. foo(_+f). If I match this against a string and want to replace the first capturing group in all matches with baz so that foo___f blah foo________f is converted to: foobaz blah foobaz There doesn't appear to be any easy way to do this using the standard libraries. If I use Matcher.replaceAll() this will replace all matches of the entire pattern and convert the string to baz blah baz Obviously I can just iterate through the matches, store the start and end index of each capturing group, then go back and replace them, but is there an easier way? Thanks, Don

    Read the article

  • marshal Map<String, String> to .xml

    - by richardl
    If I have Map setup like: map.put("foo", "123"); map.put("bar", "456"); map.put("baz", "789"); then I want to do something like: for (String key : map.keySet().toArray(new String[0])) { // marshall out to .xml a tag with the name key and the // value map.get(key) } So what it will marshal out is something like: <map> <foo>123</foo> <bar>456</bar> <baz>789</baz> </map> Can I do this with some fancy JAXB annotations or is there something else that lends it self to dynamic element names? TIA

    Read the article

  • BASH: Checking for environment variables

    - by Hamza
    Hi folks, I am trying to check the value of an environment variable and depending on the value do certain things and it works fine as long as the variable is set. When it isn't though I get a whole bunch of errors (as BASH is trying to compare the string I specify with an undefined variable, I guess) I tried implementing an extra check to prevent it happening but no luck. The block of code I am using is: #!/bin/bash if [ -n $TESTVAR ] then if [ $TESTVAR == "x" ] then echo "foo" exit elif [ $TESTVAR == "y" ] then echo "bar" exit else echo "baz" exit fi else echo -e "TESTVAR not set\n" fi And this the output: $ export TESTVAR=x $ ./testenv.sh foo $ export TESTVAR=y $ ./testenv.sh bar $ export TESTVAR=q $ ./testenv.sh baz $ unset TESTVAR $ ./testenv.sh ./testenv.sh: line 5: [: ==: unary operator expected ./testenv.sh: line 9: [: ==: unary operator expected baz My question is, shouldn't 'unset TESTVAR' nullify it? It doesn't seem to be the case... Thanks.

    Read the article

  • Constant template parameter class manages to link externally

    - by the_drow
    I have a class foo with an enum template parameter and for some reason it links to two versions of the ctor in the cpp file. enum Enum { bar, baz }; template <Enum version = bar> class foo { public: foo(); }; // CPP File #include "foo.hpp" foo<bar>::foo() { cout << "bar"; } foo<baz>::foo() { cout << "baz"; } I'm using msvc 2008, is this the standard behavior? Are only type template parameters cannot be linked to cpp files?

    Read the article

  • C# - Why can't I enforce derived classes to have parameterless constructors?

    - by FrisbeeBen
    I am trying to do the following: public class foo<T> where T : bar, new { _t = new T(); private T _t; } public abstract class bar { public abstract void someMethod(); // Some implementation } public class baz : bar { public overide someMethod(){//Implementation} } And I am attempting to use it as follows: foo<baz> fooObject = new foo<baz>(); And I get an error explaining that 'T' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method. I fully understand why this must be, and also understand that I could pass a pre-initialized object of type 'T' in as a constructor argument to avoid having to 'new' it, but is there any way around this? any way to enforce classes that derive from 'bar' to supply parameterless constructors?

    Read the article

  • Can you have a web application project produce multiple DLLS?

    - by chris
    I have a VS 2008 web application project that is getting large. My structure looks like: - WebRoot - Common/ - Foo/ - Bar/ - Baz/ so I end up with a single Webroot.dll that contains the code for common, foo, bar, and baz. Is it possible to set it so that I end up with common/ in webroot.dll, and code in foo ends up in foo.dll, bar in bar.dll, etc? Update: A couple of suggestions to move some stuff into class libraries. We already have a dozen or so separate class library projects as part of the solution; Foo, Bar and Baz contain nothing but web forms and the associated code-behinds, so moving them into separate class library projects is not feasible.

    Read the article

  • delegating into private parts

    - by FredOverflow
    Sometimes, C++'s notion of privacy just baffles me :-) class Foo { struct Bar; Bar* p; public: Bar* operator->() const { return p; } }; struct Foo::Bar { void baz() { std::cout << "inside baz\n"; } }; int main() { Foo::Bar b; // error: 'struct Foo::Bar' is private within this context Foo f; f->baz(); // fine } Since Foo::Bar is private, I cannot declare b in main. Yet I can call methods from Foo::Bar just fine. Why the hell is this allowed? Was that an accident or by design?

    Read the article

  • GCC compiler -- bug or unspecified behavior?

    - by Jared P
    When I have conflicting definitions of the ivars of a class in objective-c (not redeclaring the class in the same file, but rather naming the same class with diff ivars, no warnings or better yet errors are issued by the compiler. However, both sets of ivars are useable by the appropriate methods in the respective files. For instance Foo.m: @interface foo { int a; } - (int)method; @end @implementation foo - (int)method { return a; } @end Bar.m: @interface foo { float baz; } @end @implementation foo (category) - (float)blah { return baz; } @end compiles without warnings or errors. Is this intentional? Is this an unchecked error? (for the record, a and baz are actually the same memory location.)

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >