Search Results

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

Page 11/14 | < Previous Page | 7 8 9 10 11 12 13 14  | Next Page >

  • Rails Full Engine using a Full Engine

    - by SirLenz0rlot
    I've got this full rails engine Foo with functionality X. I want to make another engine, engine Bar, that is pretty much the same, but override funcitonality x with y. (it basically does the same, but a few controller actions and views are differently implemented). (I might split this later in several mountable engines, but for now, this will be the setup: project Baz, using engine Bar, which uses engine Foo) I would like to know if there are any pitfalls. It doesn't seem like a pattern that is often used? Anybody else using this 'some sort of engine inheritance'?

    Read the article

  • The use of GROUP BY in MySQL

    - by Gustav Bertram
    I'm fishing for a comprehensive and canonical answer for the typical "mysql group by?" question. Here is some sample data: TABLE A +------+------+----------+-----+ | id | foo | bar | baz | +------+------+----------+-----+ | 1 | 1 | hello | 42 | | 2 | 0 | apple | 96 | | 3 | 20 | boot | 11 | | 4 | 31 | unicorn | 99 | | 5 | 19 | pumpkin | 11 | | 6 | 88 | orange | 13 | +------+------+----------+-----+ TABLE B +------+------+ | id | moo | +------+------+ | 1 | 1 | | 2 | 99 | | 3 | 11 | +------+------+ Demonstrate and explain the correct use of the GROUP BY clause in MySQL. Touch upon the following points: The use of MIN, MAX, SUM, AVG The use of HAVING Grouping by date, and ranges of dates Grouping with an ORDER BY Grouping with a JOIN Grouping on multiple columns Bonus points for references to other great answers, the MySQL online manual, and online tutorials on GROUP BY.

    Read the article

  • rspec mocks: verify expectations in it "should" methods?

    - by Derick Bailey
    I'm trying to use rspec's mocking to setup expectations that I can verify in the it "should" methods... but I don't know how to do this... when i call the .should_receive methods on the mock, it verifies the expected call as soon as the before :all method exits. here's a small example: describe Foo, "when doing something" do before :all do Bar.should_recieve(:baz) foo = Foo.new foo.create_a_Bar_and_call_baz end it "should call the bar method" do # ??? what do i do here? end end How can i verify the expected call in the 'it "should"' method? do i need to use mocha or another mocking framework instead of rspec's? or ???

    Read the article

  • Help needed to convert code from C# to Python.

    - by Ali
    Can you please convert this code from C# to Python to be run on IronPython? I don’t have any experience with Python. using System; using Baz; namespace ConsoleApplication { class Program { static void Main() { Portal foo = new Portal("Foo"); Agent bar = new Agent("Bar"); foo.Connect("127.0.0.1", 1234); foo.Add(bar); bar.Ready += new Agent.ReadyHandler(bar_Ready); } static void bar_Ready(object sender, string msg) { Console.WriteLine(msg.body); } } }

    Read the article

  • Core Data: Multiple conditions inside relational aggregate operations

    - by Uzaak
    I have an SQLite table used by Core Data with the following elements: Name: John LastName: Foobar Age: 23 Name: Bob LastName: Baz Age: 37 Name: Peter LastName: Fooqux Age: 32 Name: John LastName: Bar Age: 29 Those are all in a to-many relationship from another object "Company". I need to query the database and retrieve all Company objects with employees called "John" but whose last name does NOT contain "Foo". I did go as far as to make the following predicate: [NSPredicate predicateWithFormat:@"ANY employee.name = 'John'"]; How do I get to filter only by companies whose Johns don't have "Foo" in their last names?

    Read the article

  • Django finding which field matched in a multiple OR query

    - by Greg Hinch
    I've got a couple models which are set up something like this: class Bar(models.Model): baz = models.CharField() class Foo(models.Model): bar1 = models.ForeignKey(Bar) bar2 = models.ForeignKey(Bar) bar3 = models.ForeignKey(Bar) And elsewhere in the code, I end up with an instance of Bar, and need to find the Foo it is attached to in some capacity. Right now I came up with doing a multiple OR query using Q, something like this: foo_inst = Foo.objects.get(Q(bar1=bar_inst) | Q(bar2=bar_inst) | Q(bar3=bar_inst)) What I need to figure out is, which of the 3 cases actually hit, at least the name of the member (bar1, bar2, or bar3). Is there a good way to do this? Is there a better way to structure the query to glean that information?

    Read the article

  • Easier way to move a project in Eclipse

    - by myplacedk
    My projects changes location, and I need to tell Eclipse this. Today I just delete the project and import it from the new location. But I have a lot of projects, they change location often and the paths a very complicated. I'd like a better way to manage this in Eclipse. For example: J:\iteration234_abc\foo\bar\baz\iffle\dizzle\Project Only the root-folder changes (iteration-number and the idenfier "abc"). After that there are lot of folders. Many folders has tons of subfolders with similar names, which makes finding the folder with GUI time-consuming and very boring. It would be so nice if I could just edit the path. As you may have guessed: The J-drive is a network drive, provided by the source control system. The way to tell source control that I'm working on another itertion, is to continue my work in a different folder. My actual Eclipse workspace normally doesn't contain any projects.

    Read the article

  • Is there a Java equivalent for Ruby on Rails "url_for"?

    - by Oren Ben-Kiki
    I have written something like this pretty easily in C# (string GetUrl(new { controller = "foo", action = "bar", baz = "fnord" }), based on the existing capabilities of the XmlRouteCollection class provided by the ASP.NET MVC framework (why it isn't there out of the box is beyond me; the additional required code was trivial). I am now faced with a JSP project, and I need the same ability: centralize the logic for generating all URLs in one place, based on a list of routing rules. Is there some code somewhere I could reuse/adapt to do this in Java? It seems like a common enough requirement, but google proved surprisingly unhelpful in finding something like this.

    Read the article

  • How do I temporarily change the require path in Ruby ($:)?

    - by John Feminella
    I'm doing some trickery with a bunch of Rake tasks for a complex project, gradually refactoring away some of the complexity in chunks at a time. This has exposed the bizarre web of dependencies left behind by the previous project maintainer. What I'd like to be able to do is to add a specific path in the project to require's list of paths to be searched, aka $:. However, I only want that path to be searched in the context of one particular method. Right now I'm doing something like this: def foo() # Look up old paths, add new special path. paths = $: $: << special_path # Do work ... bar() baz() quux() # Reset. $:.clear $: << paths end def bar() require '...' # If called from within foo(), will also search special_path. ... end This is clearly a monstrous hack. Is there a better way?

    Read the article

  • Can any function be a deleted-function?

    - by Caspin
    The working draft explicitly calls out that defaulted-functions must be special member functions (eg copy-constructor, default-constructor, etc). Which makes perfect sense. However, I don't see any such restriction on deleted-functions. Is that right? Or in other words are these three examples valid c++0? struct Foo { // 1 int bar( int ) = delete; }; // 2 int baz( int ) = delete; template< typename T > int boo( T t ); // 3 template<> int boo<int>(int t) = delete;

    Read the article

  • initializing properties with private sets in .Net

    - by Martin Neal
    public class Foo { public string Name { get; private set;} // <-- Because set is private, } void Main() { var bar = new Foo {Name = "baz"}; // <-- This doesn't compile /*The property or indexer 'UserQuery.Foo.Name' cannot be used in this context because the set accessor is inaccessible*/ using (DataContext dc = new DataContext(Connection)) { // yet the following line works. **How**? IEnumerable<Foo> qux = dc.ExecuteQuery<Foo>( "SELECT Name FROM Customer"); } foreach (q in qux) Console.WriteLine(q); } I have just been using the private modifier because it works and kept me from being stupid with my code, but now that I need to create a new Foo, I've just removed the private modifier from my property. I'm just really curious, why does the ExecuteQuery into an IEnumerable of Foo's work?

    Read the article

  • How to deal with name/value pairs of function arguments in MATLAB

    - by Richie Cotton
    I have a function that takes optional arguments as name/value pairs. function example(varargin) % Lots of set up stuff vargs = varargin; nargs = length(vargs); names = vargs(1:2:nargs); values = vargs(2:2:nargs); validnames = {'foo', 'bar', 'baz'}; for name = names validatestring(name{:}, validnames); end % Do something ... foo = strmatch('foo', names); disp(values(foo)) end example('foo', 1:10, 'bar', 'qwerty') It seems that there is a lot of effort involved in extracting the appropriate values (and it still isn't particularly robust again badly specified inputs). Is there a better way of handling these name/value pairs? Are there any helper functions that come with MATLAB to assist?

    Read the article

  • Implementing Transparent Persistence

    - by Jules
    Transparent persistence allows you to use regular objects instead of a database. The objects are automatically read from and written to disk. Examples of such systems are Gemstone and Rucksack (for common lisp). Simplified version of what they do: if you access foo.bar and bar is not in memory, it gets loaded from disk. If you do foo.bar = baz then the foo object gets updated on disk. Most systems also have some form of transactions, and they may have support for sharing objects across programs and even across a network. My question is what are the different techniques for implementing these kind of systems and what are the trade offs between these implementation approaches?

    Read the article

  • Parse XML with XPath & namespaces in Java

    - by ripper234
    Can you help me adjust this code so it manages to parse the XML? If I drop the XML namespace it works: String webXmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<foo xmlns=\"http://foo.bar/boo\"><bar>baz</bar></foo>"; DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); DocumentBuilder builder = domFactory.newDocumentBuilder(); org.w3c.dom.Document doc = builder.parse(new StringInputStream(webXmlContent)); NamespaceContextImpl namespaceContext = new NamespaceContextImpl(); namespaceContext.startPrefixMapping("foo", "http://www.w3.org/2001/XMLSchema-instance"); XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(namespaceContext); XPathExpression expr = xpath.compile("/foo/bar"); Object result = expr.evaluate(doc, XPathConstants.NODESET); NodeList nodes = (NodeList) result; System.out.println("Got " + nodes.getLength() + " nodes");

    Read the article

  • rewrite image URLs

    - by Don
    Hi, I'm writing a Maven plugin that merges CSS files together. So all the CSS files that match /foo/bar/*.css might get merged to /foo/merged.css. A concern is that in a file such as /foo/bar/baz.css there might be a property such as: background: url("images/pic.jpg") So when the file is merged into /foo/merged.css this will need to be changed to background: url("bar/images/pic.jpg") The recalculated URL obviously depends on 3 factors: original URL original CSS file location merged CSS file location Assuming that the original and merged CSS files are both on the same filesystem, is there a general formula (or Java library) that can be used to calculate the new url given these 3 inputs? Thanks, Don

    Read the article

  • "Socket operation on non-socket" error due to strange sytax

    - by Robert S. Barnes
    I ran across the error Socket operation on non-socket in some of my networking code when calling connect and spent a lot of time trying to figure out what was causing it. I finally figured out that the following line of code was causing the problem: if ((sockfd = socket( ai->ai_family, ai->ai_socktype, ai->ai_protocol) < 0)) { See the problem? Here's what the line should look like: if ((sockfd = socket( ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) { What I don't understand is why the first, incorrect line doesn't produce a warning. To put it another way, shouldn't the general form: if ( foo = bar() < baz ) do_somthing(); look odd to the compiler, especially running with g++ -Wall -Wextra? If not, shouldn't it at least show up as "bad style" to cppcheck, which I'm also running as part of my compile?

    Read the article

  • CSS3 selector to find the 2nd div of the same class

    - by mpeters
    I need a CSS selector that can find the 2nd div of 2 that has the same class. I've looked at nth-child() but it's not what I want since I can't see a way to further clarify what class I want. These 2 divs will be siblings in the document if that helps. My HTML looks something like this: <div class="foo">...</div> <div class="bar">...</div> <div class="baz">...</div> <div class="bar">...</div> And I want the 2nd div.bar (or the last div.bar would work too).

    Read the article

  • Sed substitution not doing what I want and think it should do

    - by nategoose
    I have am trying to use sed to get some info that is encoded within the path of a file which is passed as a parameter to my script (Bourne sh, if it matters). From this example path, I'd like the result to be 8 PATH=/foo/bar/baz/1-1.8/sing/song I first got the regex close by using sed as grep: echo $PATH | sed -n -e "/^.*\/1-1\.\([0-9][0-9]*\).*/p" This properly recognized the string, so I edited it to make a substitution out of it: echo $PATH | sed -n -e "s/^.*\/1-1\.\([0-9][0-9]*\).*/\1/" But this doesn't produce any output. I know I'm just not seeing something simple, but would really appreciate any ideas about what I'm doing wrong or about other ways to debug sed regular expressions.

    Read the article

  • Java replace all capturing groups

    - by Don
    Hi, If I have a regex with a capturing group, e.g. foo(g.*f). If I match this against a string and want to replace the first capturing group in all matches with baz so that foog___f blah foog________f is converted to: foobaz blah foobaz There doesn't appear to be any easy way to do this using the standard libraries, because the Matcher.replaceAll() method will only replace all matches of the entire pattern, am I missing something? 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

  • Python - Create a list with initial capacity

    - by Claudiu
    Code like this often happens: l = [] while foo: #baz l.append(bar) #qux This is really slow if you're about to append thousands of elements to your list, as the list will have to constantly be re-initialized to grow. (I understand that lists aren't just wrappers around some array-type-thing, but something more complicated. I think this still applies, though; let me know if not). In Java, you can create an ArrayList with an initial capacity. If you have some idea how big your list will be, this will be a lot more efficient. I understand that code like this can often be re-factored into a list comprehension. If the for/while loop is very complicated, though, this is unfeasible. Is there any equivalent for us python programmers?

    Read the article

  • With vim, how can I use autocmd's for files in subdirectories of a specific path?

    - by René Nyffenegger
    I am trying to figure out how I can define an autocmd that influences all files under a specific path. The autocmd I have tried is something like autocmd BufNewFile,BufRead /specificPath/** imap <buffer> .... Now, I'd expect this autocmd to be used if I edited, say, /foo/bar/specificPath/baz/something/bla.txt, but not if I edited /foo/bar/here/and/there/moreBla.txt If I start vim being in a directory 'above' specificPath, this works as I want it. But it doesn't if I am below that directory. Obviously, the autocmd's pattern is matched against the relative file name, not the absolute one.

    Read the article

  • Count number of messages per user

    - by Pr0no
    Consider the following tables: users messages ----------------- ----------------------- user_id messages msg_id user_id content ----------------- ----------------------- 1 0 1 1 foo 2 0 2 1 bar 3 0 3 1 foobar 4 3 baz 5 3 bar I want to count the number of messages per user and insert the outcome into users.messages, like this: users ----------------- user_id messages ----------------- 1 3 2 0 3 2 I could use PHP to perform this operation, pseudo: foreach ($user_id in users) { $count = select count(msg_id) from messages where user_id = $user_id update users set messages = $count } But this is probably very inefficient as compared to one query executed in MySQL directly: UPDATE users SET messages = ( SELECT COUNT(msg_id) FROM messages ) But I'm sure this is not a proper query. Therefore, any help would be appreciated :-)

    Read the article

  • Filtering with joined tables

    - by viraptor
    I'm trying to get some query performance improved, but the generated query does not look the way I expect it to. The results are retrieved using: query = session.query(SomeModel). options(joinedload_all('foo.bar')). options(joinedload_all('foo.baz')). options(joinedload('quux.other')) What I want to do is filter on the table joined via 'first', but this way doesn't work: query = query.filter(FooModel.address == '1.2.3.4') It results in a clause like this attached to the query: WHERE foos.address = '1.2.3.4' Which doesn't do the filtering in a proper way, since the generated joins attach tables foos_1 and foos_2. If I try that query manually but change the filtering clause to: WHERE foos_1.address = '1.2.3.4' AND foos_2.address = '1.2.3.4' It works fine. The question is of course - how can I achieve this with sqlalchemy itself?

    Read the article

  • C++ difference of keywords 'typename' and 'class' in templates

    - by Mat
    For templates I have seen both declarations: template < typename T > And: template < class T > What's the difference? And what exactly do those keywords mean in the following example (taken from the German Wikipedia article about templates)? template < template < typename, typename > class Container, typename Type > class Example { Container< Type, std::allocator < Type > > baz; };

    Read the article

  • Rolling back a git tree, fully or partially (single file) how to?

    - by Tzury Bar Yochay
    On a given server, I have a set of daemons each of which has its own configuration file. I would like to use git to manage the configuration files editing during time and always have the option to rollback to the "factory defaults" in regards to all files or a specific one. For instance, given the following structure: $ ls -l total 0 -rw-r--r-- 1 tzury tzury 0 2011-01-05 06:36 bar.conf -rw-r--r-- 1 tzury tzury 0 2011-01-05 06:36 baz.conf -rw-r--r-- 1 tzury tzury 0 2011-01-05 06:36 foo.conf Assuming all those .conf files are stored in a git repository, I want to be able to restore all files into their original shape (that would be the first git commit). Yet, I would also like to be able to rollback a specific file to the factory defaults, while others remain up to date.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14  | Next Page >