祁梦

文章 0 评论 0 浏览

祁梦 2023-01-12 07:29:47

A member operator only takes one argument:

struct gr_log
{
   string name;
   string category;
   string description;
   float cost;
   bool operator==(const gr_log& r)
   {
       return name == r.name;
   }
};

Alternatively, you could write a friend operator:

struct gr_log
{
   string name;
   string category;
   string description;
   float cost;
   friend bool operator==(const gr_log& l, const gr_log& r)
   {
       return l.name == r.name;
   }
};

Also, you'll need to perform a find using an instance of gr_log because you can't compare a gr_log with a string like you're trying to do:

it = find (grocery.begin(), grocery.end(), gr_log("Sugar"));

problem with find function in Vector of Structure in C++

祁梦 2023-01-12 07:26:14

Just put brackets around every column. That way you ensure that even reserved words are taken care of.

Find reserved keywords in TSQL

祁梦 2023-01-12 03:31:00

Are you talking about ACTION_UP?

Android: where is the onUnTouchEvent of Activity?

祁梦 2023-01-12 01:30:15

| means OR in regex, you should escape it. What's more, a single '\', you get '\|' means nothing in Java string. So you should also escape the '\' itself, which yields '\|'.

Good luck!

Split string with | separator in java

祁梦 2023-01-12 01:12:35

Just store the reversed path in a temporary array and then iterate that array backwards.

How to print the optimal path from beginning in dynamic programming technique

祁梦 2023-01-11 22:58:56

Perhaps because this:

$("#centerColumn" + "#rightColumn").wrap("<div id='test' />");

Should be this:

$("#centerColumn,#rightColumn").wrap("<div id='test' />");

.wrap not being wrapped

祁梦 2023-01-11 18:47:25

If the series of functions each call the next one you're correct, you'd need to have some sort of flag. In all likelihood, what would be best would be to modify your functions so that they return the reference to the object. Then you could chain like so:

var chain = {
  'fn_1': function () {
    // do something here.
    return this;
  },
  'fn_2': function () {
    // do something here.
    return this;
  },
  'fn_3': function () {
    // do something here.
    return this;
  }
};

// call the full chain:
chain.fn_1().fn_2().fn_3();

// call only the middle.
chain.fn_2();

How can I call any function in a chain of functions, without the chaining?

祁梦 2023-01-11 18:00:16

The proper way to thread them is not by subject, but rather by the Message-ID and References headers. The References header will contain a comma-delimited string of all the previously related Messgage-ID headers. By using these, the actual content of the subject line becomes less relevant since it can get modified and mangled. In other cases, you might get many separate threads with subjects like "Need help please" that should not be threaded together.

Threading emails by subject

祁梦 2023-01-11 17:43:35

I'm a bit confused by the question but I thought I'd try to answer it anyway.

I don't understand how that would work @ilikeorangutans. I assume that there are multiple blogposts for a single author? So how could there be a single blogpost_id on the account channel? You could have a join table which contains an author_id and a blogpost_id but that just adds complexity.

If you take a look at this discussion and this webpage, you can see that Hibernate's inverse mapping is about who controls the relationship and is responsible for updating the rows. In both cases, BlogPost would have an author_id and not the other way around.

ORMLite does support the concept of "foreign collections" where you can add a BlogPost to the database by adding it to the collection in the Author object. For more information see the foreign collection documentation.

Sorry if I'm missing something.

ORMLite foreign @DatabaseField with inverse mapping?

祁梦 2023-01-11 15:59:26

As others have pointed out, b just points to the same string as input.

As for a, we can use javap to disassemble your code:

public static void someMethod(java.lang.String);
  Code:
   0:   aload_0
   1:   ifnonnull   5
   4:   return
   5:   new #4; //class java/lang/StringBuilder
   8:   dup
   9:   invokespecial   #5; //Method java/lang/StringBuilder."<init>":()V
   12:  aload_0
   13:  invokevirtual   #6; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   16:  aload_0
   17:  invokevirtual   #6; //Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
   20:  invokevirtual   #7; //Method java/lang/StringBuilder.toString:()Ljava/lang/String;
   23:  astore_1
   24:  aload_0
   25:  astore_2
   26:  return

The compiler uses StringBuilder.append() to perform the concatenation, which (in Sun/OpenJDK, at least) just copies everything into a big char array - no intern()ing here. Same applies with your edit - the input string is appended 5 times in total.

I can imagine an alternate implementation of String(Builder|Buffer) could be written to maintain a chain of arrays, which would allow better reuse and efficiency in some cases.

Does Java optimize the creation of strings at runtime?

祁梦 2023-01-09 22:41:29

To complete Eric's answer (who left out popovers, navigation controllers, tabbarcontrollers, view controllers added as subviews to some other view controllers while traversing), here is my version of returning the currently visible view controller:

=====================================================================

- (UIViewController*)topViewController {
    return [self topViewControllerWithRootViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}

- (UIViewController*)topViewControllerWithRootViewController:(UIViewController*)viewController {
    if ([viewController isKindOfClass:[UITabBarController class]]) {
        UITabBarController* tabBarController = (UITabBarController*)viewController;
        return [self topViewControllerWithRootViewController:tabBarController.selectedViewController];
    } else if ([viewController isKindOfClass:[UINavigationController class]]) {
        UINavigationController* navContObj = (UINavigationController*)viewController;
        return [self topViewControllerWithRootViewController:navContObj.visibleViewController];
    } else if (viewController.presentedViewController && !viewController.presentedViewController.isBeingDismissed) {
        UIViewController* presentedViewController = viewController.presentedViewController;
        return [self topViewControllerWithRootViewController:presentedViewController];
    }
    else {
        for (UIView *view in [viewController.view subviews])
        {
            id subViewController = [view nextResponder];
            if ( subViewController && [subViewController isKindOfClass:[UIViewController class]])
            {
                if ([(UIViewController *)subViewController presentedViewController]  && ![subViewController presentedViewController].isBeingDismissed) {
                    return [self topViewControllerWithRootViewController:[(UIViewController *)subViewController presentedViewController]];
                }
            }
        }
        return viewController;
    }
}

=====================================================================

And now all you need to do to get top most view controller is call the above method as follows:

UIViewController *topMostViewControllerObj = [self topViewController];

How to find topmost view controller on iOS

祁梦 2023-01-09 09:40:42

Since you are interested in data modifications to a particular database, what you can do is utilize the binary log. A binary log, logs all data modifications in files, but for that you have to have binary logging enabled. Then you may use a utility mysqlbinlog.

Say for example you have binary logs named,

mysql-bin.000001

mysql-bin.000001

mysql-bin.000001

Then what you can do is

mysqlbinlog -u user_name -p --database=db_name /path/to/binlog/mysql-bin.* > dbqueries.sql

I need to find whats the last sql operation done in that database

祁梦 2023-01-09 08:41:46

I just came across this myself. It seems like doctrine:build-sql is buggy.

One of the crazier things I discovered while investigating this is that doctrine:insert-sql doesn't even use schema.sql. It dynamically generates and runs the SQL based on the model definitions.

Looks like this is a known bug and won't be fixed in Doctrine 1:

Doctrine: Models with column_aggregation inheritance appear twice in SQL

祁梦 2023-01-09 07:53:31

Borrowing from a recent blog post by chromatic, Why PSGI/Plack Matters (Testing), here's what it is:

It's a good idea borrowed from Python's WSGI and Ruby's Rack but made Perlish; it's a simple formalizing of a pattern of web application development, where the entry point into the application is a function reference and the exit point is a tuple of header information and a response body.

That's it. That's as simple as it can be, and that simplicity deceives a lot of people who want to learn it.

An important benefit is, ibid.,

Given a Plack application, you don't have to deploy to a web server—even locally—to test your application as if it were deployed … Plack and TWMP (and Plack::Test) use the well-defined Plack pattern to make something which was previously difficult into something amazingly easy. They're not the first and they won't be the last, but they do demonstrate the value of Plack.

PSGI: What is it and what's the fuss about?

祁梦 2023-01-08 23:16:15

This will undoubtedly vary between devices. Why not just try it and see?

Edit: OK so I guess you want to know actually how to do it. The method you will need is Image.getRGB() -- as per the docs:

Obtains ARGB pixel data from the
specified region of this image and
stores it in the provided array of
integers. Each pixel value is stored
in 0xAARRGGBB format, where the
high-order byte contains the alpha
channel and the remaining bytes
contain color components for red,
green and blue, respectively. The
alpha channel specifies the opacity of
the pixel, where a value of 0x00
represents a pixel that is fully
transparent and a value of 0xFF
represents a fully opaque pixel.

Modify the pixels you want then use the data to create a new image using Image.createRGBImage().

Edit: The spec says that all devices should allow alpha manipulation.

One way to tell whether they do or not is to create a mutable image, get its graphics object, write some ARGB data to it, then read it back, and see if the alpha data is still present; if not then you can bet alpha transparency is not supported.

The methods I've linked to should be all you need to do this, the actual method I leave as an exercise ;)

ARGB Color Format

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击“接受”或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。