git status shows file as modified, however when commiting it shows the file as been copied ie:
git status
modified: foo/bar/baz.xml
git commit
copied: bar/foo/baz.xml - foo/bar/baz.xml
Why is it showing this file as copied if it was not. The two files were identical before the change.
I'm looking in to Magento's filtering options (Ecommerce System and PHP Framekwork with an expansive ORM system). Specifically the addFieldToFilter method. In this method, you specify a SQLish filter by passing in a single element array, with the key indicating the type of filter. For example,
array('eq'=>'bar') //eq means equal
array('neq'=>'bar') //neq means not equal
would each give you a where clause that looks like
where field = 'bar';
where field != 'bar';
So, deep in the bowels of the source, I found a comparison type named
'moreq'
that maps to a = comparison operator
array('moreq'=>'27')
where field >= 27
The weird thing is, there's already a 'gteq' comparision type
array('gteq'=>'27')
where field >= 27
So, my question is, what does moreq stand for? Is is some special SQL concept that's supported in other databases that the Magento guys wants to map to MySQL, or is it just "more required" and an example what happens when you're doing rapid agile and trying to maintain backwards compatibility.
Hi there,
I am looking for an alternative to using an object/variable in global scope -- I would like to associate key/value pairs with specific DOM elements (eg, a DIV), so that I can use them as input for logic that processes other elements (eg, child elements of said DIV).
I tried something naive like: $('[foo=bar]').key='value' , and $('[foo=bar]')[key]='value', but it puked.
Doing something like: var foobar = $('[foo=bar]'); foobar.key = 'value' -- works, but the new property/value only affects the new object (ie, foobar, not $('[foo=bar]'))
Most likely there's something terribly basic I am overlooking. Any help is appreciated, thanks!
I'll try to be more descriptive here.
A Few Q's:
using:
var foo = new Foo() { Bar = new Bar() { Value = "Value" } };
var value = DataBinder.Eval(foo, "Bar.Value");
Or: This one
It is possible to retrieve an internal nested property using property path syntax. Is there a way to set/trigger a nested property (a regular property not DependencyProperty) easily with some kind of simple mechanisms as described here?
I want to acheive something like:
string newValue = "Hello World!";
DataBinder.EvalSet(foo, "Bar.Value", NewValue);
Is there any mechanism that support both property path (for nested objects) and XPATHs (if the objects are XPATH navigable of course) ?
again, that supports get and set options.
Thanks,
DD
info = {'phone_number': '123456', 'personal_detail': {'foo':foo, 'bar':bar}, 'is_active': 1, 'document_detail': {'baz':baz, 'saz':saz}, 'is_admin': 1, 'email': '[email protected]'}
return HttpResponse(simplejson.dumps({'success':'True', 'result':info}), mimetype='application/javascript')
if(data["success"] === "True") {
alert(data[**here I want to display personal_detail and document_details**]);
}
How can I do this?
Let's say I have a simple ASP.NET MVC site with two views. The views use the following routes: /Foo and /Foo/Bar.
Now let's say I want to use the URL to specify (just for the sake of example) the background color of the site. I want my routes to be, for instance, /Blue/Foo or /Green/Foo/Bar.
Also, if I call Html.ActionLink from a view, I want the Blue or Green value to propagate. So, e.g., if I call Html.ActionLink("Bar", "Foo") from /Blue/Foo, I want /Blue/Foo/Bar to come back.
How best can I do this?
(Forgive me if I'm missing an existing post. This is hard for me to articulate concisely, so I'm not quite sure what to search for.)
typedef struct Pair_s {
char *first;
char *second;
} Pair;
Pair pairs[] = {
{"foo", "bar"}, //this is fine
{"bar", "baz"}
};
typedef struct PairOfPairs_s {
Pair *first;
Pair *second;
} PairOfPairs;
PairOfPairs pops[] = {
{{"foo", "bar"}, {"bar", "baz"}}, //How can i create an equivalent of this NEATLY
{&pairs[0], &pairs[1]} //this is not considered neat (imagine trying to read a list of 30 of these)
};
How can I achieve the above style declaration semantics?
This is a followup question to my previous question.
#include <functional>
int foo(void) {return 2;}
class bar {
public:
int operator() (void) {return 3;};
int something(int a) {return a;};
};
template <class C> auto func(C&& c) -> decltype(c()) { return c(); }
template <class C> int doit(C&& c) { return c();}
template <class C> void func_wrapper(C&& c) { func( std::bind(doit<C>, std::forward<C>(c)) ); }
int main(int argc, char* argv[])
{
// call with a function pointer
func(foo);
func_wrapper(foo); // error
// call with a member function
bar b;
func(b);
func_wrapper(b);
// call with a bind expression
func(std::bind(&bar::something, b, 42));
func_wrapper(std::bind(&bar::something, b, 42)); // error
// call with a lambda expression
func( [](void)->int {return 42;} );
func_wrapper( [](void)->int {return 42;} );
return 0;
}
I'm getting a compile errors deep in the C++ headers:
functional:1137: error: invalid initialization of reference of type ‘int (&)()’ from expression of type ‘int (*)()’
functional:1137: error: conversion from ‘int’ to non-scalar type ‘std::_Bind(bar, int)’ requested
func_wrapper(foo) is supposed to execute func(doit(foo)). In the real code it packages the function for a thread to execute. func would the function executed by the other thread, doit sits in between to check for unhandled exceptions and to clean up. But the additional bind in func_wrapper messes things up...
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?
Hello,
I am trying to write a frequency program that will represent a bar diagram (in console code).
The problem is i have no idea how exactly to caculate this frequency or how do i exactly then give the bars different heights according to there frequency (trough calculation).
The frequency height is capped at 21. (meaning the bars go from 1 to 21, so the max bar height would be for example 21 stars(* as display sign for the bar itself).
A calculation i have so far (although not sure if correct) for frequency:
This array takes the random values generated:
for (int j = 0; j < T.Length; j++)
{
T[j] = (MaxHeight* T[j]) / Ber.GreatestElement(T);
Console.Write("{0,7}", T[j]);
}
This results in values between 0 and 21 -- Based on the values my bars should give a certain height compared to all the other frequency values. (for example 8000 could have 21 in height where 39 could have 1).
To represent this diagram i used 2 for loops to display height and width (keep in mind i only wish to use Using System; to keep it to the "basics").
for (int height= 1; height<= 21; height++)
{
for (int width= 0; width<= 10; width++)
{
if(...??)
{
Console.Write("{0,7}", bar); // string bar= ("*");
}
else
{
Console.Write("{0,7}", empty);
}
}
Console.WriteLine();
}
So so far i have a entire field filled with * and the random values generated along with their frequency value (although i have no idea if the freq value is properly calculated).
I assume i need a if (.....) in the second for but i cannot seem to get further then this.
Thanks in advance!
A note - the classes I have are EntityObject classes!
I have the following class:
public class Foo
{
public Bar Bar { get; set; }
}
public class Bar : IDataErrorInfo
{
public string Name { get; set; }
#region IDataErrorInfo Members
string IDataErrorInfo.Error
{
get { return null; }
}
string IDataErrorInfo.this[string columnName]
{
get
{
if (columnName == "Name")
{
return "Hello error!";
}
Console.WriteLine("Validate: " + columnName);
return null;
}
}
#endregion
}
XAML goes as follows:
<StackPanel Orientation="Horizontal" DataContext="{Binding Foo.Bar}">
<TextBox Text="{Binding Path=Name, ValidatesOnDataErrors=true}"/>
</StackPanel>
I put a breakpoint and a Console.Writeline on the validation there - I get no breaks. The validation is not executed. Can anybody just press me against the place where my error lies?
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?
I want to fetch the id of a one-to-one relationship without loading the entire object. I thought I could do this using lazy loading as follows:
class Foo {
@OneToOne(fetch = FetchType.LAZY, optional = false)
private Bar bar;
}
Foo f = session.get(Foo.class, fooId); // Hibernate fetches Foo
f.getBar(); // Hibernate fetches full Bar object
f.getBar().getId(); // No further fetch, returns id
I want f.getBar() to not trigger another fetch. I want hibernate to give me a proxy object that allows me to call .getId() without actually fetching the Bar object.
What am I doing wrong?
This is just an example, but given the following model:
class Foo(models.model):
bar = models.IntegerField()
def __str__(self):
return str(self.bar)
def __unicode__(self):
return str(self.bar)
And the following QuerySet object:
foobar = Foo.objects.filter(bar__lt=20).distinct()
(meaning, a set of unique Foo models with bar <= 20), how can I generate all possible subsets of foobar? Ideally, I'd like to further limit the subsets so that, for each subset x of foobar, the sum of all f.bar in x (where f is a model of type Foo) is between some maximum and minimum value.
So, for example, given the following instance of foobar:
>> print foobar
[<Foo: 5>, <Foo: 10>, <Foo: 15>]
And min=5, max=25, I'd like to build an object (preferably a QuerySet, but possibly a list) that looks like this:
[[<Foo: 5>], [<Foo: 10>], [<Foo: 15>], [<Foo: 5>, <Foo: 10>],
[<Foo: 5>, <Foo: 15>], [<Foo: 10>, <Foo: 15>]]
I've experimented with itertools but it doesn't seem particularly well-suited to my needs.
I think this could be accomplished with a complex QuerySet but I'm not sure how to start.
I'm a bit confused by the proper frame sizing of a table view to fit within my screen.
Here's my setup of view controllers within view controllers:
UITabBarController
UINavigationController as one of the tab bar viewcontrollers; title bar hidden
ViewController - a container view controller because I need the option to place some controls beneath the UITableView, sometimes (but not in the current scenario)
UITableViewController
Now, my question is what the proper frame dimensions of the UITableview should be. Here's what I've got in the ViewController viewDidLoad method. I used subtracted 49.0 (the size of the tab bar) from 480.0. However, this leaves a black bar at the bottom. 20.0 appears to do it (coincidentally?) the size of the status bar, but I don't understand why that would be. Wouldn't the true pixel dimensions of the tableview be 480-49?
// MessageTableViewController is my subclass of UITableViewController
MessagesTableViewController *vcMessagesTable = [[MessagesTableViewController alloc] init];
CGRect tableViewFrame = CGRectMake(0, 0, 320.0, 480.0 - 49.0);
[[vcMessagesTable view] setFrame:tableViewFrame];
self.tableViewController = vcMessagesTable;
[self addChildViewController:vcMessagesTable];
[[self view] addSubview:vcMessagesTable.view];
Here's how it looks:
I have a Perl module and I'd like to be able to pick out the parameters that my my module's user passed in the "use" call. Whichever ones I don't recognize I'd like to pass on. I tried to do this by overriding the "import" method but I'm not having much luck.
EDIT:
To clarify, as it is, I can use my module like this:
use MyModule qw/foo bar/;
which will import the foo and bar methods of MyModule. But I want to be able to say:
use MyModule qw/foo doSpecialStuff bar/;
and look for doSpecialStuff to check if I need to do some special stuff at the beginning of the program, then pass qw/foo bar/ to the Exporter's import
What is the syntax for the hash value for a Perl object member subroutine reference in a dispatch table?
use lib Alpha;
my $foo = new Alpha::Foo;
$foo->bar();
my %disp_table = ( bar => ??? );
I want ??? to be the code reference for $foo->bar().
In F#, given the following class:
type Foo() =
member this.Bar<'t> (arg0:string) = ignore()
Why does the following compile:
let f = new Foo()
f.Bar<Int32> "string"
While the following won't compile:
let f = new Foo()
"string" |> f.Bar<Int32> //The compiler returns the error: "Unexpected type application"
Hey guys,
I'd like to simulate a flag in an xslt script. The idea is for template foo to set a flag (or a counter variable, or anything), so that it can be accessed from template bar. Bar isn't called from foo, but from a common parent template (otherwise I would pass a parameter to it). The structure is like this:
<xsl:template match="bla">
<xsl:apply-templates select="foo"/> <!-- depending on the contents of foo... -->
<xsl:apply-templates select="bar"/> <!-- ... different things should happen in bar -->
</xsl:template>
Any tricks are much appreciated.
Is it possible to create a decorator which can be __init__'d with a set of arguments, then later have methods called with other arguments?
For instance:
from foo import MyDecorator
bar = MyDecorator(debug=True)
@bar.myfunc(a=100)
def spam():
pass
@bar.myotherfunc(x=False)
def eggs():
pass
If this is possible, can you provide a working example?
First off, the title is very generic because there are just tons of ways of how to possibly solve this. However, I'm looking for a clean and neat way.
Situation:
I have two equal object files foo.o and foo-pi.o, the latter of which is position-independent (compiled with -fPIC). Both depend on foo.h and bar.h.
Problem:
How do I, without code duplication, declare dependency of all foo*.o to bar.h?
Solutions so far:
$(shell bash -c 'echo -ne foo{-pi,}.o'}: bar.h
$(addsuffix .o, $(addprefix fo, o-pi o)): bar.h
The first solution is not portable on systems that don't support bash, the second is a dirty solution since I could not figure out how to use empty strings in addprefix.
Hello,
In some Python unit tests of a program I'm working on we use in-memory zipfiles for end to end tests. In SetUp() we create a simple zip file, but in some tests we want to overwrite some archives. For this we do "zip.writestr(archive_name, zip.read(archive_name) + new_content)". Something like
import zipfile
from StringIO import StringIO
def Foo():
zfile = StringIO()
zip = zipfile.ZipFile(zfile, 'a')
zip.writestr(
"foo",
"foo content")
zip.writestr(
"bar",
"bar content")
zip.writestr(
"foo",
zip.read("foo") +
"some more foo content")
print zip.read("bar")
Foo()
The problem is that this works fine in Python 2.4 and 2.5, but not 2.6. In Python 2.6 this fails on the print line with "BadZipfile: File name in directory "bar" and header "foo" differ."
It seems that it is reading the correct file bar, but that it thinks it should be reading foo instead.
I'm at a loss. What am I doing wrong? Is this not supported? I tried searching the web but could find no mention of similar problems. I read the zipfile documentation, but could not find anything (that I thought was) relevant, especially since I'm calling read() with the filename string.
Any ideas?
Thank you in advance!
I need a regex that will match blahfooblah but not blahfoobarblah
I want it to match only foo and everything around foo, as long as it isn't followed by bar.
I tried using this: foo.*(?<!bar) which is fairly close, but it matches blahfoobarblah. The negative look behind needs to match baranything and not just bar.
The specific language I'm using is Clojure which uses Java regexes under the hood.
Hypothetical situation that I'm struggling to get my head past.
HoldsFooBar.h:
#include "foo.h"
#include "bar.h"
class HoldsFooBar{
foo F;
bar B;
};
foo.h:
//includes?
class foo{
HoldsFooBar *H;
void Baz();
};
bar.h:
//includes?
class bar{
HoldsFooBar *H;
void Qux();
};
I'm trying to get F to get a hold of B. In all other languages I've worked with, I would be able to H->B.Qux();, but I'm totally lost in C++. At the includes lines in foo.h and bar.h, it seems like my options are to forward-declare class HoldsFooBar; but then I can only access H, and F and B cannot see each other. Likewise, I can #include "HoldsFooBar.h" but because of my include guards, something ends up not getting linked properly, so the program doesn't run.
Is what I'm trying to do even possible? Thank you very much! Any help would be appreciated!