问:
Merge bug fixes patches from release branch to master branch
I have one master branch where i am pushing my latest development.

Now at some point, I do release and create new branch called release1 from master branch.

Now i am doing new development on master branch

Meantime other team also perform some bug fixes on release1 branch.

Now time come for release2. Here i need to include bug fixes done on release1 to the updated master branch and then fork release2 branch.

New release2 branch should have all bug fixes done on release1 branch  + latest development occurs after release1 on master branch.

What are the different possible workflow here.And based on that how to play with git merge and git rebase and git cherry-pick command here?

答:
Solution which I prefer is as below.

master -> release1

master will have its own further development,

suppose some bug in release1 branch then one should create hotfix branch from release1 branch and after fixing bug in hotfix branch, just merge it into release1 branch and rebase hotfix with master branch to maintain history, once rebased with master branch merge hotfix in master branch so bug fixing will be in both master and release1 branch

now suppose it's time to have release2, you just need to create release2 branch from master branch because all the bugs are already fixed in master branch as well as all the new developments are in master branch.

```<code>Master
 commit1
 commit2 -> release1
 commit3
 commit4

git checkout release1
git checkout -b hotfix

Hotfix
 commit2
 bugfix1
</code>```

Merge hotfix with release1 will become

```<code>git checkout release1
git merge hotfix

Release1
 Commit1
 commit2
 butfix1
</code>```

Rebase hotfix with master it will rewrite your history

```<code>git checkout hotfix
git rebase master

Hotfix
 commit1
 commit2
 commit3
 commit4
 bugfix1
</code>```

after that merge hotfix branch to master branch

```<code>git checkout master
git merge hotfix

Master
 commit1
 commit2
 commit3
 commit4
 bugfix1

git branch -d hotfix
git push -d origin hotfix
</code>```

don't forgot to delete hotfix because we are already done with that branch there is no more requirement of that branch once merged. you can also change names of hotfix branch to the jira ticket id or bug id if logged somewhere.

now creating release2 from master which is already have bug fixed in it.

Body:
Solution which I prefer is as below.

master -> release1

master will have its own further development,

suppose some bug in release1 branch then one should create hotfix branch from release1 branch and after fixing bug in hotfix branch, just merge it into release1 branch and rebase hotfix with master branch to maintain history, once rebased with master branch merge hotfix in master branch so bug fixing will be in both master and release1 branch

now suppose it's time to have release2, you just need to create release2 branch from master branch because all the bugs are already fixed in master branch as well as all the new developments are in master branch.

Master
 commit1
 commit2 -> release1
 commit3
 commit4

git checkout release1
git checkout -b hotfix

Hotfix
 commit2
 bugfix1

Merge hotfix with release1 will become

git checkout release1
git merge hotfix

Release1
 Commit1
 commit2
 butfix1

Rebase hotfix with master it will rewrite your history

git checkout hotfix
git rebase master

Hotfix
 commit1
 commit2
 commit3
 commit4
 bugfix1

after that merge hotfix branch to master branch

git checkout master
git merge hotfix

Master
 commit1
 commit2
 commit3
 commit4
 bugfix1

git branch -d hotfix
git push -d origin hotfix

don't forgot to delete hotfix because we are already done with that branch there is no more requirement of that branch once merged. you can also change names of hotfix branch to the jira ticket id or bug id if logged somewhere.

now creating release2 from master which is already have bug fixed in it.


来源: stackexchange

问:
How to get started with developing Internet Explorer extensions?
Does anyone here have experience with/in developing IE extensions that can share their knowledge? This would include code samples, or links to good ones, or documentation on the process, or anything.

I really want to do this, but I'm hitting a giant wall with lousy documentation, lousy code/example code/lack thereof. Any help/resources you could offer would be greatly appreciated.

Specifically, I would like to start with how to get access to/manipulate the DOM from within a IE extension.

EDIT, even more details:

Ideally, I would like to plant a toolbar button that, when clicked, popped a menu up that contains links to external sites. I would also like to access the DOM and plant JavaScript on the page depending on some conditions.

What is the best way to persist information in an IE extension? In Firefox/Chrome/Most modern browsers, you use window.localStorage, but obviously with IE8/IE7, that's not an option. Maybe a SQLite DB or such? It is okay to assume that .NET 4.0 will be installed on a user's computer?

I don't want to use Spice IE as I want to build one that is compatible with IE9 as well. I've added the C++ tag to this question as well, because if it's better to build one in C++, I can do that.

答:
The question is from 2013, now it's 2020, but it may be helpful for future visitors.

I tried to implement @Miguel Angelo's answer, it didn't worked at the beginning.

There still some settings that you be defined.

on internet explorer (I'm using IE-11) go to Tools-->Internet Options-->Advanced:

Also see this SO question and this example from github

ContentLicense: CC BY-SA 3.0

ContentLicense: CC BY-SA 4.0


问:
Spring Data - eager fetch on @OneToOne
I have two entities:

@Entity
@Table(name = "Something")
public class SomethingEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SOMETHING_SEQ")
    @SequenceGenerator(sequenceName = "SOMETHING_SEQ", allocationSize = 1, name = "SOMETHING_SEQ")
    @Column(name = "SOMETHING_ID", precision = 18, scale = 0, nullable = false)
    private Long somethingId;

    @Column(name = "SIMPLE_FIELD", length = 3, nullable = true)
    private String simpleField;

    @OneToOne(cascade = CascadeType.ALL, mappedBy = "somethingId")
    private OtherEntity other;
}

@Entity
@Table(name = "OTHER")
public class OtherEntity implements Serializable {
    @Id
    @OneToOne
    @JoinColumn(name = "SOMETHING_ID")
    private SomethingEntity somethingId;

    @Column(name = "OTHER_SIMPLE_FIELD", precision = 18, scale = 2, nullable = false)
    private Double otherSimpleField;
}
```

<p>I want Spring-Data to fetch <code>otherEntity</code> eagerly. I know it doesn't work by default, so my repository method is:</p>

```@EntityGraph(attributePaths = {"other"})
List<SomethingEntity> findAll(Predicate predicate);
```

It doesn't work and my guess is, it's because of @OneToOne. I also tried JOIN FETCH, simple select by simpleField (predicate in my example is QueryDSL), nothing works.

The most surprising thing is that the initial SQL is actually correct - it contains correct joins and selects correct fields. Then Spring-Data is loading each @OneToOne relation by id anyway, causing 100 queries instead of 1.

答:
I dont understand your use of @EntityGraph, try to use it in entity like this:

```<code>@NamedEntityGraphs({
    @NamedEntityGraph(name = "graph.SomethingEntity.OtherEntity", attributeNodes = @NamedAttributeNode("other"))
})
public class SomethingEntity implements Serializable {
[...]
</code>```

And use the entity graph in your repository method like this:

```<code>EntityGraph graph = this.em.getEntityGraph("graph.SomethingEntity.OtherEntity");
Map hints = new HashMap();
hints.put("javax.persistence.fetchgraph", graph);//Important fetchgraph no other type
return entityManager.find(SomethingEntity.class,ID_OF_SOMETHING_ENTITY,  hints);
</code>```

Another option is create a CriteriaQuery in yout repository method like this:

```<code>CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<SomethingEntity> cq = cb.createQuery(SomethingEntity.class);

//Need to define variable root to apply fetch
Root<SomethingEntity> rootSE = cq.from(SomethingEntity.class);

/* Use metamodel (in eclipse, property project / JPA / Canonical metamodel
 * and select src folder in source to allow autogenerated metamodels)
 */
rootSE.fetch(SomethingEntity_.other);

// Set your predicates
cq.where(cb.equals(rootSE.get(SomethingEntity_.somethingId),ID_OF_SOMETHING_ENTITY));

cq.select(rootSE);

entityManager.createQuery(cq).getSingleResult();
</code>```

Title: Spring Data - eager fetch on @OneToOne

Body:
I have two entities:

@Entity
@Table(name = "Something")
public class SomethingEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SOMETHING_SEQ")
    @SequenceGenerator(sequenceName = "SOMETHING_SEQ", allocationSize = 1, name = "SOMETHING_SEQ")
    @Column(name = "SOMETHING_ID", precision = 18, scale = 0, nullable = false)
    private Long somethingId;

    @Column(name = "SIMPLE_FIELD", length = 3, nullable = true)
    private String simpleField;

    @OneToOne(cascade = CascadeType.ALL, mappedBy = "somethingId")
    private OtherEntity other;
}

@Entity
@Table(name = "OTHER")
public class OtherEntity implements Serializable {
    @Id
    @OneToOne
    @JoinColumn(name = "SOMETHING_ID")
    private SomethingEntity somethingId;

    @Column(name = "OTHER_SIMPLE_FIELD", precision = 18, scale = 2, nullable = false)
    private Double otherSimpleField;
}

I want Spring-Data to fetch otherEntity eagerly. I know it doesn't work by default, so my repository method is:

@EntityGraph(attributePaths = {"other"})
List<SomethingEntity> findAll(Predicate predicate);

It doesn't work and my guess is, it's because of @OneToOne. I also tried JOIN FETCH, simple select by simpleField (predicate in my example is QueryDSL), nothing works.

The most surprising thing is that the initial SQL is actually correct - it contains correct joins and selects correct fields. Then Spring-Data is loading each @OneToOne relation by id anyway, causing 100 queries instead of 1.

Body:
I dont understand your use of @EntityGraph, try to use it in entity like this:

@NamedEntityGraphs({
    @NamedEntityGraph(name = "graph.SomethingEntity.OtherEntity", attributeNodes = @NamedAttributeNode("other"))
})
public class SomethingEntity implements Serializable {
[...]

And use the entity graph in your repository method like this:

EntityGraph graph = this.em.getEntityGraph("graph.SomethingEntity.OtherEntity");
Map hints = new HashMap();
hints.put("javax.persistence.fetchgraph", graph);//Important fetchgraph no other type
return entityManager.find(SomethingEntity.class,ID_OF_SOMETHING_ENTITY,  hints);

Another option is create a CriteriaQuery in yout repository method like this:

CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<SomethingEntity> cq = cb.createQuery(SomethingEntity.class);

//Need to define variable root to apply fetch
Root<SomethingEntity> rootSE = cq.from(SomethingEntity.class);

/* Use metamodel (in eclipse, property project / JPA / Canonical metamodel
 * and select src folder in source to allow autogenerated metamodels)
 */
rootSE.fetch(SomethingEntity_.other);

// Set your predicates
cq.where(cb.equals(rootSE.get(SomethingEntity_.somethingId),ID_OF_SOMETHING_ENTITY));

cq.select(rootSE);

entityManager.createQuery(cq).getSingleResult();


问:
Send a product's custom feature in order confirmation email
I want to send the "units per box" custom feature in my confirmation mails in prestashop.

Here's an example if what I want to do

```<code>$myprod = new Product($product['id_product']);
$features = $myprod->getFrontFeatures(1));

foreach(from=$features item=feature)
{
  if ($feature.name == "Units per box")
  {
     $UnitsPerBox = $feature.value|escape:'htmlall':'UTF-8';
  }
}
</code>```

However I need to do this within a php file (PaymentModule.php) rather than a tpl file, so that code won't work.
If anybody could point me in the right direction of how to achieve this with php it'd be greatly appreciated.

EDIT:

I used the example code provided which seems to get inside the array but doesn't return any values

When I run some test code like this

```<code>$myprod = new Product($product['id_product']);
$features = $myprod->getFrontFeatures(1);
$UnitsPerBox .= '100';
foreach ($features as $feature)
{
  $UnitsPerBox .= '200';
  if ($feature->name == 'Units Per Box')
  {
    $UnitsPerBox .= htmlentities($feature->value, 'ENT_QUOTES', 'UTF-8');
    $UnitsPerBox .= $feature->name;
  }
  else
  {
    $UnitsPerBox .= $feature->name;
    $UnitsPerBox .= htmlentities($feature->name, 'ENT_QUOTES', 'UTF-8');
    $UnitsPerBox .= htmlentities($feature->value, 'ENT_QUOTES', 'UTF-8');
  }
}
</code>```

I get this output: "100200200200200200"

Any help would be great, thanks.

Thanks,
Andrew

EDIT: Solution

Got it working in the end, thanks for the help

```<code>$myprod = new Product($product['id_product']);
$features = $myprod->getFrontFeatures(1);
foreach ($features as $feature)
{
foreach ($feature as $key => $value)
{
    if($value == "Units per box")
    {
        $UnitsPerBox = $feature['value'];
    }
}
</code>```

}

答:
This looks like Smarty template code.  In that case, the function you're looking for is htmlentities():

```<code>foreach($features as $feature)
{
  if ($feature->name == "Units per box")
  {
     $UnitsPerBox = htmlentities($feature->value, ENT_QUOTES, 'UTF-8');
  }
}
</code>```

Body:
I want to send the "units per box" custom feature in my confirmation mails in prestashop.

Here's an example if what I want to do

$myprod = new Product($product['id_product']);
$features = $myprod->getFrontFeatures(1));

foreach(from=$features item=feature)
{
  if ($feature.name == "Units per box")
  {
     $UnitsPerBox = $feature.value|escape:'htmlall':'UTF-8';
  }
}

However I need to do this within a php file (PaymentModule.php) rather than a tpl file, so that code won't work.
If anybody could point me in the right direction of how to achieve this with php it'd be greatly appreciated.

EDIT:

I used the example code provided which seems to get inside the array but doesn't return any values

When I run some test code like this

$myprod = new Product($product['id_product']);
$features = $myprod->getFrontFeatures(1);
$UnitsPerBox .= '100';
foreach ($features as $feature)
{
  $UnitsPerBox .= '200';
  if ($feature->name == 'Units Per Box')
  {
    $UnitsPerBox .= htmlentities($feature->value, 'ENT_QUOTES', 'UTF-8');
    $UnitsPerBox .= $feature->name;
  }
  else
  {
    $UnitsPerBox .= $feature->name;
    $UnitsPerBox .= htmlentities($feature->name, 'ENT_QUOTES', 'UTF-8');
    $UnitsPerBox .= htmlentities($feature->value, 'ENT_QUOTES', 'UTF-8');
  }
}

I get this output: "100200200200200200"

Any help would be great, thanks.

Thanks,
Andrew

EDIT: Solution

Got it working in the end, thanks for the help

$myprod = new Product($product['id_product']);
$features = $myprod->getFrontFeatures(1);
foreach ($features as $feature)
{
foreach ($feature as $key => $value)
{
    if($value == "Units per box")
    {
        $UnitsPerBox = $feature['value'];
    }
}

}

Body:
This looks like Smarty template code.  In that case, the function you're looking for is htmlentities():

foreach($features as $feature)
{
  if ($feature->name == "Units per box")
  {
     $UnitsPerBox = htmlentities($feature->value, ENT_QUOTES, 'UTF-8');
  }
}


问:
Is there a way to trigger an immediate push replication for specific artifacts and not the whole folder in JFrog Artifactory?
I referred to the REST API documentation here. It works for folders. However, it is not working for individual artifacts. </p>

答:
There is not REST API method for triggering replication for a specific artifacts.

You can use the event-based push replication instead or on top of the scheduled replication - artifact replication will occur in nearly in real-time since each create, copy, move or delete of an artifact is immediately propagated to the far end.

If you wish to limit the artifacts being replicated to a given path you can:

Configure a "Path Prefix" - Only artifacts that located in path that matches the subpath within the remote repository will be replicated

Create a custom user plugin with a replication execution point - plugin can have logic to decide whether to replicate or skip based on the artifacts path


问:
Java Map compute() Example on Java 1.6
I have to work on Java 1.6. I have difficulty converting the following code running on Java 1.8.

```<code>Map<String, Double> maksimum = new HashMap<>();
List<Record> records;
for (Record record : records) {
    record.getFeatures().forEach((key, value) -> {
        maksimum.compute(key, (k1, max) -> max == null || value > max ? value : max);
    });
}
</code>```

what I have transformed is as follows. I wonder where I'm doing wrong.

```<code>for(Record rec : records) {
    for (Map.Entry<String, Double> entry : rec.getFeatures().entrySet()) {
        if (entry.getKey()==null || maksimum.containsKey(entry.getKey())) {
            maksimum.replace(entry.getKey(), maksimum.get(entry.getValue()));
        }
    }
}
</code>```

答:
If I understand correctly your initial code in Java 8, you want to store the maximum value for every key in your Map. Here is the code that should do that in Java 6:

```<code>Map<String, Double> maksimum = new HashMap<String, Double>();

for (Record record : records) {
    for (Map.Entry<String, Double> recordEntry : record.getFeatures().entrySet()) {
        String key = recordEntry.getKey();
        Double value = recordEntry.getValue();

        Double initialValue = maksimum.get(key);
        if (initialValue == null) {
            maksimum.put(key, value);
        } else {
            maksimum.put(key, Math.max(value, initialValue));
        }
    }
}
</code>```

Note that the replace function that you've used in your example was introduced in Java 8. Docs: https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#replace-K-V-

Title: Java Map compute() Example on Java 1.6

Body:
I have to work on Java 1.6. I have difficulty converting the following code running on Java 1.8.

Map<String, Double> maksimum = new HashMap<>();
List<Record> records;
for (Record record : records) {
    record.getFeatures().forEach((key, value) -> {
        maksimum.compute(key, (k1, max) -> max == null || value > max ? value : max);
    });
}

what I have transformed is as follows. I wonder where I'm doing wrong.

for(Record rec : records) {
    for (Map.Entry<String, Double> entry : rec.getFeatures().entrySet()) {
        if (entry.getKey()==null || maksimum.containsKey(entry.getKey())) {
            maksimum.replace(entry.getKey(), maksimum.get(entry.getValue()));
        }
    }
}

Body:
If I understand correctly your initial code in Java 8, you want to store the maximum value for every key in your Map. Here is the code that should do that in Java 6:

Map<String, Double> maksimum = new HashMap<String, Double>();

for (Record record : records) {
    for (Map.Entry<String, Double> recordEntry : record.getFeatures().entrySet()) {
        String key = recordEntry.getKey();
        Double value = recordEntry.getValue();

        Double initialValue = maksimum.get(key);
        if (initialValue == null) {
            maksimum.put(key, value);
        } else {
            maksimum.put(key, Math.max(value, initialValue));
        }
    }
}

Note that the replace function that you've used in your example was introduced in Java 8. Docs: https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#replace-K-V-


问:
How to return values created by trigger for JOOQ record store?
since several weeks we use JOOQ as our main persistence framework instead of all those Spring Data JPA/Hibernate stuff. I'm really impressed !!!

For simple CRUD operations we use record.store() and this record is an UpdatableRecordImpl due to the underlying table contains an ID (column id with PostgreSQL type serial) Furthermore JOOQ is configured with withReturnAllOnUpdatableRecord(true) and our table contains a trigger to generate the value for the column nummer:

```<code>CREATE OR REPLACE FUNCTION "public"."after_insert_angebot" () RETURNS trigger
VOLATILE
AS $body$
DECLARE
BEGIN
UPDATE kalkulation_angebot SET nummer = date_part('year', CURRENT_DATE) || '-' || LPAD(NEW.id::text, 3, '0') WHERE id = NEW.id;
RETURN NEW;
END;
$body$ LANGUAGE plpgsql

CREATE TRIGGER "after_insert_angebot"
  AFTER INSERT ON kalkulation_angebot
  FOR EACH ROW
EXECUTE PROCEDURE after_insert_angebot()
</code>```

I expect, that after record.store() and due to withReturnAllOnUpdatableRecord(true) the record contains values for the id (generated by the column type) and nummer (generated by the trigger). But only the id is filled. I have to manually set the nummer by an extra query:

```<code>// jooq fetched the new values and the id is available
Integer angebotId = record.getId();

// ... but nummer is missing and has to set manually
angebot.setNummer(jooq.select(KALKULATION_ANGEBOT.NUMMER)
        .from(KALKULATION_ANGEBOT)
        .where(KALKULATION_ANGEBOT.ID.eq(record.getId()))
        .fetchSingleInto(String.class));
</code>```

I assume, the error is within the trigger function ? How the trigger should be, in order to fulfill the promise of the documentation:

The identity value is not the only value that is generated by default. Specifically, there may be triggers that are used for [...] Users who wish to also automatically fetch these values after all store(), insert(), or update() calls may do so by specifying the returnAllOnUpdatableRecord setting

Thanks in advance

Dominik

答:
Setting withReturnAllOnUpdatableRecord(true) produces an INSERT .. RETURNING or UPDATE .. RETURNING statement in jOOQ. Since you've defined an AFTER INSERT trigger, this does not help returning the values as you might have expected. Try it in vanilla PostgreSQL:

CREATE TABLE kalkulation_angebot (
  id serial,
  nummer text
);

-- Your own TRIGGER below:
CREATE OR REPLACE FUNCTION "public"."after_insert_angebot" () RETURNS trigger
VOLATILE
AS $body$
BEGIN
  UPDATE kalkulation_angebot
  SET nummer = date_part('year', CURRENT_DATE) || '-' || LPAD(NEW.id::text, 3, '0')
  WHERE id = NEW.id;
  RETURN NEW;
END;
$body$ LANGUAGE plpgsql;

CREATE TRIGGER "after_insert_angebot"
  AFTER INSERT ON kalkulation_angebot
  FOR EACH ROW EXECUTE PROCEDURE after_insert_angebot();

INSERT INTO kalkulation_angebot DEFAULT VALUES RETURNING *;
```

<p>The output being:</p>

<pre class="lang-none prettyprint-override"><code>|id         |nummer  |
|-----------|--------|
|1          |        |
</code>```

How about you replace your trigger to what I would believe to be much more meaningful anyway:

CREATE OR REPLACE FUNCTION "public"."before_insert_angebot" () RETURNS trigger
VOLATILE
AS $body$
BEGIN
  NEW.nummer = date_part('year', CURRENT_DATE) || '-' || LPAD(NEW.id::text, 3, '0');
  RETURN NEW;
END;
$body$ LANGUAGE plpgsql;

CREATE TRIGGER "before_insert_angebot"
  BEFORE INSERT ON kalkulation_angebot
  FOR EACH ROW EXECUTE PROCEDURE before_insert_angebot();

INSERT INTO kalkulation_angebot DEFAULT VALUES RETURNING *;
```

<p>The output is now:</p>

<pre class="lang-none prettyprint-override"><code>|id         |nummer  |
|-----------|--------|
|1          |2020-001|
</code>```

Body:
since several weeks we use JOOQ as our main persistence framework instead of all those Spring Data JPA/Hibernate stuff. I'm really impressed !!!

For simple CRUD operations we use record.store() and this record is an UpdatableRecordImpl due to the underlying table contains an ID (column id with PostgreSQL type serial) Furthermore JOOQ is configured with withReturnAllOnUpdatableRecord(true) and our table contains a trigger to generate the value for the column nummer:

CREATE OR REPLACE FUNCTION "public"."after_insert_angebot" () RETURNS trigger
VOLATILE
AS $body$
DECLARE
BEGIN
UPDATE kalkulation_angebot SET nummer = date_part('year', CURRENT_DATE) || '-' || LPAD(NEW.id::text, 3, '0') WHERE id = NEW.id;
RETURN NEW;
END;
$body$ LANGUAGE plpgsql

CREATE TRIGGER "after_insert_angebot"
  AFTER INSERT ON kalkulation_angebot
  FOR EACH ROW
EXECUTE PROCEDURE after_insert_angebot()

I expect, that after record.store() and due to withReturnAllOnUpdatableRecord(true) the record contains values for the id (generated by the column type) and nummer (generated by the trigger). But only the id is filled. I have to manually set the nummer by an extra query:

// jooq fetched the new values and the id is available
Integer angebotId = record.getId();

// ... but nummer is missing and has to set manually
angebot.setNummer(jooq.select(KALKULATION_ANGEBOT.NUMMER)
        .from(KALKULATION_ANGEBOT)
        .where(KALKULATION_ANGEBOT.ID.eq(record.getId()))
        .fetchSingleInto(String.class));

I assume, the error is within the trigger function ? How the trigger should be, in order to fulfill the promise of the documentation:

The identity value is not the only value that is generated by default. Specifically, there may be triggers that are used for [...] Users who wish to also automatically fetch these values after all store(), insert(), or update() calls may do so by specifying the returnAllOnUpdatableRecord setting

Thanks in advance

Dominik

Body:
Setting withReturnAllOnUpdatableRecord(true) produces an INSERT .. RETURNING or UPDATE .. RETURNING statement in jOOQ. Since you've defined an AFTER INSERT trigger, this does not help returning the values as you might have expected. Try it in vanilla PostgreSQL:

CREATE TABLE kalkulation_angebot (
  id serial,
  nummer text
);

-- Your own TRIGGER below:
CREATE OR REPLACE FUNCTION "public"."after_insert_angebot" () RETURNS trigger
VOLATILE
AS $body$
BEGIN
  UPDATE kalkulation_angebot
  SET nummer = date_part('year', CURRENT_DATE) || '-' || LPAD(NEW.id::text, 3, '0')
  WHERE id = NEW.id;
  RETURN NEW;
END;
$body$ LANGUAGE plpgsql;

CREATE TRIGGER "after_insert_angebot"
  AFTER INSERT ON kalkulation_angebot
  FOR EACH ROW EXECUTE PROCEDURE after_insert_angebot();

INSERT INTO kalkulation_angebot DEFAULT VALUES RETURNING *;

The output being:

|id         |nummer  |
|-----------|--------|
|1          |        |

How about you replace your trigger to what I would believe to be much more meaningful anyway:

CREATE OR REPLACE FUNCTION "public"."before_insert_angebot" () RETURNS trigger
VOLATILE
AS $body$
BEGIN
  NEW.nummer = date_part('year', CURRENT_DATE) || '-' || LPAD(NEW.id::text, 3, '0');
  RETURN NEW;
END;
$body$ LANGUAGE plpgsql;

CREATE TRIGGER "before_insert_angebot"
  BEFORE INSERT ON kalkulation_angebot
  FOR EACH ROW EXECUTE PROCEDURE before_insert_angebot();

INSERT INTO kalkulation_angebot DEFAULT VALUES RETURNING *;

The output is now:

|id         |nummer  |
|-----------|--------|
|1          |2020-001|


问:
getting java.lang.NullPointerException in android
I am using firebase crashlytics beta version for ndk crashes. I am following all the steps given here. But I am facing an issue and can not upload symbol file. Whenever I am going to run the task ./gradlew uploadCrashlyticsSymbolFileDebug --stacktrace it says java.lang.NullPointerException. But why and where it is null?

here is the full stacktrace of this task

```<code>> Task :app:generateCrashlyticsSymbolFileDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateCrashlyticsSymbolFileDebug'.
> java.lang.NullPointerException (no error message)

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateCrashlyticsSymbolFileDebug'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:151)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:148)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:141)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
        at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.NullPointerException
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.processDebugInfoEntry(DwarfDataParser.java:297)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.processChildDebugInfoEntries(DwarfDataParser.java:269)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.processCompilationUnit(DwarfDataParser.java:194)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.readCompilationUnit(DwarfDataParser.java:173)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.readCompilationUnit(DwarfDataParser.java:139)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.parse(DwarfDataParser.java:63)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.elf.ElfDataParser.parseElf(ElfDataParser.java:132)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.elf.ElfDataParser.parse(ElfDataParser.java:101)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.elf.ElfDataParser.parse(ElfDataParser.java:39)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.csym.ElfCSymFactory.createCSymFromFile(ElfCSymFactory.java:92)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.csym.NdkCSymGenerator.generateCodeMappings(NdkCSymGenerator.java:101)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.csym.NdkCSymGenerator.generateCodeMappings(NdkCSymGenerator.java:90)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.csym.NdkCSymGenerator.generateFromDirectories(NdkCSymGenerator.java:44)
        at com.google.firebase.crashlytics.buildtools.Buildtools.generateNativeSymbolFile(Buildtools.java:157)
        at com.google.firebase.crashlytics.buildtools.Buildtools$generateNativeSymbolFile$3.call(Unknown Source)
        at com.google.firebase.crashlytics.buildtools.gradle.tasks.GenerateSymbolFileTask.generateSymbols(GenerateSymbolFileTask.groovy:45)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:48)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:702)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:669)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:404)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:393)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:376)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:213)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$1(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:120)
        ... 35 more
</code>```

I have followed all the steps from firebase ndk crashlytics. but no luck

here is my app-level build.gradle file

```<code>apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.ndk.demo"
        minSdkVersion 18
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        externalNativeBuild {
            cmake {
                //version "3.10.2"
                cppFlags "-std=c++11 -frtti -fexceptions"
                abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
            }
        }
    }

    sourceSets.main {
        jniLibs.srcDirs = ['libs']
        jni.srcDirs = []
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    splits {
        abi {
            enable true
            reset()
            include "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
            exclude "armeabi"
            universalApk true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
//                mappingFileUploadEnabled true
            }
        }

        debug {
            minifyEnabled false
            debuggable true
            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
//                mappingFileUploadEnabled true
            }
        }
    }

    dexOptions {
        preDexLibraries false
        javaMaxHeapSize "4g"
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }

    dataBinding {
        enabled = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        doNotStrip "*/armeabi/*.so"
    }
}

/*afterEvaluate {
    if (gradle.startParameter.taskNames.contains(":app:assembleDebug")) {
        assembleDebug.finalizedBy("uploadCrashlyticsSymbolFileDebug")
    } else if (gradle.startParameter.taskNames.contains(":app:assembleRelease")) {
        assembleRelease.finalizedBy("uploadCrashlyticsSymbolFileRelease")
    }
}*/

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.multidex:multidex:2.0.1'

    //new crashlytics
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.firebase:firebase-core:17.2.2'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'
    implementation 'com.google.firebase:firebase-crashlytics-ndk:17.0.0-beta01'
}
apply plugin: 'com.google.gms.google-services'
apply from: "../artifacts.gradle"
</code>```

Someone please help me to solve out this error.

Thanks in advance.

答:
You shouldn't do assemble, install and run together. Especially if you have parallel builds enabled, that would be a problem. install and installDevice are different. install is coming from Android plugin and installs on all devices. installDevice is from our plugin and installs on a given device. First one by default, can be overridden with -PdeviceId=

Can you try following things:

Can you share your gradle and Android plugin version with us?
Try with just ./gradlew runDebug. This will assemble and install for you.
You can also do startDebug after a regular Android installDebug task. This will just start rather than install and start which is useful if you need to run install task yourself.
If you have parallel enabled, can you try with --no-parallel command line argument?

Body:
I am using firebase crashlytics beta version for ndk crashes. I am following all the steps given here. But I am facing an issue and can not upload symbol file. Whenever I am going to run the task ./gradlew uploadCrashlyticsSymbolFileDebug --stacktrace it says java.lang.NullPointerException. But why and where it is null?

here is the full stacktrace of this task

> Task :app:generateCrashlyticsSymbolFileDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateCrashlyticsSymbolFileDebug'.
> java.lang.NullPointerException (no error message)

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateCrashlyticsSymbolFileDebug'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:151)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:148)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:141)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
        at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
        at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.NullPointerException
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.processDebugInfoEntry(DwarfDataParser.java:297)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.processChildDebugInfoEntries(DwarfDataParser.java:269)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.processCompilationUnit(DwarfDataParser.java:194)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.readCompilationUnit(DwarfDataParser.java:173)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.readCompilationUnit(DwarfDataParser.java:139)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.dwarf.DwarfDataParser.parse(DwarfDataParser.java:63)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.elf.ElfDataParser.parseElf(ElfDataParser.java:132)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.elf.ElfDataParser.parse(ElfDataParser.java:101)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.elf.ElfDataParser.parse(ElfDataParser.java:39)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.csym.ElfCSymFactory.createCSymFromFile(ElfCSymFactory.java:92)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.csym.NdkCSymGenerator.generateCodeMappings(NdkCSymGenerator.java:101)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.csym.NdkCSymGenerator.generateCodeMappings(NdkCSymGenerator.java:90)
        at com.google.firebase.crashlytics.buildtools.ndk.internal.csym.NdkCSymGenerator.generateFromDirectories(NdkCSymGenerator.java:44)
        at com.google.firebase.crashlytics.buildtools.Buildtools.generateNativeSymbolFile(Buildtools.java:157)
        at com.google.firebase.crashlytics.buildtools.Buildtools$generateNativeSymbolFile$3.call(Unknown Source)
        at com.google.firebase.crashlytics.buildtools.gradle.tasks.GenerateSymbolFileTask.generateSymbols(GenerateSymbolFileTask.groovy:45)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:48)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:702)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:669)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:404)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:393)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:376)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:213)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$1(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
        at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:120)
        ... 35 more

I have followed all the steps from firebase ndk crashlytics. but no luck

here is my app-level build.gradle file

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "com.ndk.demo"
        minSdkVersion 18
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        externalNativeBuild {
            cmake {
                //version "3.10.2"
                cppFlags "-std=c++11 -frtti -fexceptions"
                abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
            }
        }
    }

    sourceSets.main {
        jniLibs.srcDirs = ['libs']
        jni.srcDirs = []
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    splits {
        abi {
            enable true
            reset()
            include "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
            exclude "armeabi"
            universalApk true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
//                mappingFileUploadEnabled true
            }
        }

        debug {
            minifyEnabled false
            debuggable true
            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
//                mappingFileUploadEnabled true
            }
        }
    }

    dexOptions {
        preDexLibraries false
        javaMaxHeapSize "4g"
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }

    dataBinding {
        enabled = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        doNotStrip "*/armeabi/*.so"
    }
}

/*afterEvaluate {
    if (gradle.startParameter.taskNames.contains(":app:assembleDebug")) {
        assembleDebug.finalizedBy("uploadCrashlyticsSymbolFileDebug")
    } else if (gradle.startParameter.taskNames.contains(":app:assembleRelease")) {
        assembleRelease.finalizedBy("uploadCrashlyticsSymbolFileRelease")
    }
}*/

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.multidex:multidex:2.0.1'

    //new crashlytics
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.firebase:firebase-core:17.2.2'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'
    implementation 'com.google.firebase:firebase-crashlytics-ndk:17.0.0-beta01'
}
apply plugin: 'com.google.gms.google-services'
apply from: "../artifacts.gradle"

Someone please help me to solve out this error.

Thanks in advance.


问:
Can't replace a specific string that contains \/ in MySQL
In my database table there is a column that contains a value like this:

```<code>{"type":"XXX\\ZZZ\\Model\\Rule\\Condition\\Product\\Combine","attribute":null,"operator":null,"value":"1","is_value_processed":null,"aggregator":"all","conditions":[{"type":"XXX\\ZZZ\\Model\\Rule\\Condition\\Product","attribute":"category_ids","operator":"{}","value":"7","is_value_processed":false},{"type":"XXX\\ZZZ\\Model\\Rule\\Condition\\Product","attribute":"category_ids","operator":"!()","value":"73, 223, 1078, 1053, 1054, 1055, 1056, 1080, 1081, 1082, 1093, 1059, 1060, 1057, 1085, 1106, 1105, 1107, 1103","is_value_processed":false},{"type":"vendor_module\/rule_condition_product_onsales_onsales","attribute":false,"operator":"is_not_on_sales","value":false,"is_value_processed":false}]}
</code>```

I want to replace the specific string which is vendor_module\/rule_condition_product_onsales_onsales into Vendor\\Module\\Rule\\Condition\\Product\\Onsales\\Onsales by doing it like this:

```<code>UPDATE table
          SET column = REPLACE(column, 'vendor_module\/rule_condition_product_onsales_onsales', 'Vendor\\Module\\Rule\\Condition\\Product\\Onsales\\Onsales')
          WHERE column LIKE '%vendor_module\/rule_condition_product_onsales_onsales%';
</code>```

but i always get a response 0 row updated

答: The string '%vendor_module\/rule_condition_product_onsales_onsales%' in LIKE clause contains backslash "\". You have to change the \ in LIKE to \\\\. For example %vendor_module\\/rule_condition_product_onsales_onsales%'

Body:
In my database table there is a column that contains a value like this:

{"type":"XXX\\ZZZ\\Model\\Rule\\Condition\\Product\\Combine","attribute":null,"operator":null,"value":"1","is_value_processed":null,"aggregator":"all","conditions":[{"type":"XXX\\ZZZ\\Model\\Rule\\Condition\\Product","attribute":"category_ids","operator":"{}","value":"7","is_value_processed":false},{"type":"XXX\\ZZZ\\Model\\Rule\\Condition\\Product","attribute":"category_ids","operator":"!()","value":"73, 223, 1078, 1053, 1054, 1055, 1056, 1080, 1081, 1082, 1093, 1059, 1060, 1057, 1085, 1106, 1105, 1107, 1103","is_value_processed":false},{"type":"vendor_module\/rule_condition_product_onsales_onsales","attribute":false,"operator":"is_not_on_sales","value":false,"is_value_processed":false}]}

I want to replace the specific string which is vendor_module\/rule_condition_product_onsales_onsales into Vendor\\Module\\Rule\\Condition\\Product\\Onsales\\Onsales by doing it like this:

UPDATE table
          SET column = REPLACE(column, 'vendor_module\/rule_condition_product_onsales_onsales', 'Vendor\\Module\\Rule\\Condition\\Product\\Onsales\\Onsales')
          WHERE column LIKE '%vendor_module\/rule_condition_product_onsales_onsales%';

but i always get a response 0 row updated


问:
How to save Image from ctx.drawImage() to local storage
Hi I want to store my Image which I capture from webcam.
My plan is save the picture to local storage then post it to backend after all form fields are filled in.

here is my methods (I m using Vue Js) to take the picture from webcam

```<code> takePictureSelf() {
            let ratio = (window.innerHeight < window.innerWidth) ? 16 / 9 : 9 / 16;
            const picture = document.querySelector("canvas");
            picture.width = (window.innerWidth < 1280) ? window.innerWidth : 1280;
            picture.width = window.innerWidth / ratio;
            const ctx = picture.getContext("2d");
            ctx.imageSmoothingEnabled =  true ;
            ctx.imageSmoothingQuality = "high";
            const gambar = document.querySelector("video");
            ctx.drawImage(gambar,0,0,picture.width, picture.height)
        }
</code>```

答:
I sketched some code to get image data from the canvas.  You just have to save the data to the localStorage and send it to the server.

document.getElementById("myImg").onload = function() {
  const img = document.getElementById("myImg");
  const canvas = document.getElementById("myCanvas");
  const pre = document.getElementById('myPre');
  const ctx = canvas.getContext("2d");

  canvas.width = img.width;
  canvas.height = img.height;

  ctx.drawImage(img, 0, 0);

  const imageFileData = canvas.toDataURL('image/jpeg', 1);

  // for demo
  pre.innerHTML = imageFileData;
};```
<pre class="snippet-code-css lang-css prettyprint-override"><code>canvas {
  display: none;
}

pre {
  white-space: pre-wrap;
  word-break: break-all;
}</code>```

<canvas id="myCanvas"></canvas>

image loading...```</code>```

Body:
Hi I want to store my Image which I capture from webcam.
My plan is save the picture to local storage then post it to backend after all form fields are filled in.

here is my methods (I m using Vue Js) to take the picture from webcam

 takePictureSelf() {
            let ratio = (window.innerHeight < window.innerWidth) ? 16 / 9 : 9 / 16;
            const picture = document.querySelector("canvas");
            picture.width = (window.innerWidth < 1280) ? window.innerWidth : 1280;
            picture.width = window.innerWidth / ratio;
            const ctx = picture.getContext("2d");
            ctx.imageSmoothingEnabled =  true ;
            ctx.imageSmoothingQuality = "high";
            const gambar = document.querySelector("video");
            ctx.drawImage(gambar,0,0,picture.width, picture.height)
        }

Body:
I sketched some code to get image data from the canvas.  You just have to save the data to the localStorage and send it to the server.

document.getElementById("myImg").onload = function() {
  const img = document.getElementById("myImg");
  const canvas = document.getElementById("myCanvas");
  const pre = document.getElementById('myPre');
  const ctx = canvas.getContext("2d");

  canvas.width = img.width;
  canvas.height = img.height;

  ctx.drawImage(img, 0, 0);

  const imageFileData = canvas.toDataURL('image/jpeg', 1);

  // for demo
  pre.innerHTML = imageFileData;
};

canvas {
  display: none;
}

pre {
  white-space: pre-wrap;
  word-break: break-all;
}

<img id="myImg" crossorigin="anonymous" src="https://loremflickr.com/50/50" />
<canvas id="myCanvas"></canvas>
<pre id="myPre">image loading...</pre>


问:
How to Fetch a file placed in a container that can be logged-in from azure vm via "dsh"?
My requirement is below:

1) Login to Linux jump server from Windows local host
2) From Linux Server SSH to Azure VM machine
3) From Azure VM node - dsh - to a linux card
4) Get the file from this linux card back all the way to Windows local host

Is this possible ?

I've tried paramiko/subprocess etc to perform SSH till Azure VM
but then I have to do dsh to a linux card n fetch file from there.
How to do that, any leads ?

答:
It seems you jump twice with SSH and get into the destination Linux machine, then you want to copy the file here to your original Windows machine. For this purpose, I only have two possible ways.

One is that copy the file directly to your Windows machine. But in this way, your Windows machine needs to be accessible from the Internet with port 22 and the destination Linux machine also needs to be able to access the Internet.

The other one is that you need to copy the file multiple times to each machine you SSH to. Finally, copy the file from the Linux jump server to your Windows machine.


问:
How to change words after match containing slash
Inside my file "input.txt" I have the following path written:

```<code>"/home/inputfiles/water_gen/5202_water.gen"
</code>```

I want to change "5202" by specific numbers (probably using a for loop) and save them as different files.

I thought the easiest way was to use sed to find "water_gen/" as a match and then change the rest.

But is there an easier approach? I've been having problems because of the slash.

答:
If this part 5202 is known than change it directly

```<code>sed -i 's/5202/153/' input.txt
</code>```

If not use regexp

```<code>sed -i 's/[0-9]\+/153/' input.txt
</code>```

Body:
Inside my file "input.txt" I have the following path written:

"/home/inputfiles/water_gen/5202_water.gen"

I want to change "5202" by specific numbers (probably using a for loop) and save them as different files.

I thought the easiest way was to use sed to find "water_gen/" as a match and then change the rest.

But is there an easier approach? I've been having problems because of the slash.

Body:
If this part 5202 is known than change it directly

sed -i 's/5202/153/' input.txt

If not use regexp

sed -i 's/[0-9]\+/153/' input.txt


问:
Locking a table within a transaction
I would like to be able to lock an entire table to prevent any INSERTs or UPDATEs in it between the "beginTransaction" and the ending "commit" or "rollback".

I know that beginning a transaction results in an implicit UNLOCK TABLES and that a LOCK table results in a implicit COMMIT... so is there any way to do what I want?

答:
If you're using PHP, so when there is a transaction going on, you can set a SESSION variable to tell the script not to do anything with the database, i.e. $_SESSION['on_going_transaction'] = true.

When the transaction is completed, just destroy the SESSION variable so that another transaction can occur. This is much easier.

Title: Locking a table within a transaction


问:
Resources to simulate automatic storage and retrieval system using anylogic
Currently I am modelling a high bay shelf in anylogic(personal learning edition) using Material handling library and process modelling library. Using jibcrane or overhead crane I am unable to store or retrieve pallets in all the racks. The pallet rack has 4 levels. Is there any other resource I can use instead of jibcrane or overhead crane to pick and drop the pallets in or from the racks?</p>

答:
you can actually store and retrieve pallets from racks using a crane using some tricks, even though it doesn't make sense in the real world

Nevertheless, in terms of resources, anything from a forklift to a person agents can retrieve and store in racks.. In the rackstore and rackpick properties you have a resource section that is quite easy to use.

If the problem is the 4 levels, there are forklifts that can lift pallets really high, and anylogic takes into consideration the level in order to calculate the storage time.

But anyways, your problem is not very clear.. do you want to actually use cranes to store? Or did I answer the question you had at least partially??


问:
Can't find process listed by `jobs` command
I am using jobs command to control the number of compute-intensive processes. I want to not run more than max_cnt processes at a time, and stop only when all the processes have stopped.

I use below bash script to accomplish this. However, this code always lists one process as running even after everything has executed and stopped.

Moreover, I can't find that process listed in htop's list of processes. What should I do or where should I look for that process that is listed by the result of echo $(jobs -p) command and how should I fix this issue of not exiting even when everything stops.

```<code>#!/usr/bash

SLEEP=5
max_cnt=8

# generate a random number less than eq $1
function random {
    rand=$RANDOM
    while [ "$rand" -gt $1 ]
    do
        rand=$RANDOM
    done
}

function job {
    # resource intensive job simulated by random sleeping
    echo param1="$1",param2="$2"
    random 20
    echo Sleeping for $rand
    sleep $rand
}

for param1 in 1e-6 1e-5 1e-4 1e-3 1e-2
do
    for param2 in "ones" "random"
    do
        echo starting job with $param1 $param2
        job $param1 $param2 &
        while [ "$(jobs -p|wc -l)" -ge "$max_cnt" ]
        do
            echo "current running jobs.. $(jobs -p|wc -l) ... sleeping"
            sleep $SLEEP
        done
    done
done

while [ "$(jobs -p|wc -l)" -ge 1 ]
do
    echo "current running jobs.. $(jobs -p|wc -l) ... sleeping"
    sleep $SLEEP
    echo $(jobs -p)
done
</code>```

答:
As mentioned in the comments, you may want to consider using GNU Parallel, it makes life easier when managing parallel jobs. Your code could look like this:

```<code>#!/usr/bin/env bash

function job {
    # resource intensive job simulated by random sleeping
    echo param1="$1",param2="$2"
    ((s=(RANDOM%5)+1))
    echo Sleeping for $s
    sleep $s
}
# export function to subshells
export -f job

parallel -j8 job {1} {2} ::: 1e-6 1e-5 1e-4 1e-3 1e-2 ::: "ones" "random"
</code>```

Sample Output

```<code>param1=1e-6,param2=ones
Sleeping for 1
param1=1e-5,param2=ones
Sleeping for 1
param1=1e-2,param2=ones
Sleeping for 1
param1=1e-4,param2=ones
Sleeping for 2
param1=1e-4,param2=random
Sleeping for 2
param1=1e-6,param2=random
Sleeping for 4
param1=1e-2,param2=random
Sleeping for 3
param1=1e-3,param2=random
Sleeping for 4
param1=1e-5,param2=random
Sleeping for 5
param1=1e-3,param2=ones
Sleeping for 5
</code>```

There are many other switches and parameters:

parallel --dry-run ... will show you what it would do, without actually doing anything

parallel --eta ... which gives you an "Estimated Time of Arrival"

parallel --bar ... which gives you a progress bar

parallel -k ... which keeps output in order

parallel -j 8  ... which runs 8 jobs at a time rather than the default of 1 job per CPU core

parallel --pipepart ... which will split the contents of a massive file across subprocesses

Note also that GNU Parallel can distribute work across other machines in your network, and it has fail and retry handling, output tagging and so on...

Body:
I am using jobs command to control the number of compute-intensive processes. I want to not run more than max_cnt processes at a time, and stop only when all the processes have stopped.

I use below bash script to accomplish this. However, this code always lists one process as running even after everything has executed and stopped.

Moreover, I can't find that process listed in htop's list of processes. What should I do or where should I look for that process that is listed by the result of echo $(jobs -p) command and how should I fix this issue of not exiting even when everything stops.

#!/usr/bash

SLEEP=5
max_cnt=8

# generate a random number less than eq $1
function random {
    rand=$RANDOM
    while [ "$rand" -gt $1 ]
    do
        rand=$RANDOM
    done
}

function job {
    # resource intensive job simulated by random sleeping
    echo param1="$1",param2="$2"
    random 20
    echo Sleeping for $rand
    sleep $rand
}

for param1 in 1e-6 1e-5 1e-4 1e-3 1e-2
do
    for param2 in "ones" "random"
    do
        echo starting job with $param1 $param2
        job $param1 $param2 &
        while [ "$(jobs -p|wc -l)" -ge "$max_cnt" ]
        do
            echo "current running jobs.. $(jobs -p|wc -l) ... sleeping"
            sleep $SLEEP
        done
    done
done

while [ "$(jobs -p|wc -l)" -ge 1 ]
do
    echo "current running jobs.. $(jobs -p|wc -l) ... sleeping"
    sleep $SLEEP
    echo $(jobs -p)
done

Body:
As mentioned in the comments, you may want to consider using GNU Parallel, it makes life easier when managing parallel jobs. Your code could look like this:

#!/usr/bin/env bash

function job {
    # resource intensive job simulated by random sleeping
    echo param1="$1",param2="$2"
    ((s=(RANDOM%5)+1))
    echo Sleeping for $s
    sleep $s
}
# export function to subshells
export -f job

parallel -j8 job {1} {2} ::: 1e-6 1e-5 1e-4 1e-3 1e-2 ::: "ones" "random"

Sample Output

param1=1e-6,param2=ones
Sleeping for 1
param1=1e-5,param2=ones
Sleeping for 1
param1=1e-2,param2=ones
Sleeping for 1
param1=1e-4,param2=ones
Sleeping for 2
param1=1e-4,param2=random
Sleeping for 2
param1=1e-6,param2=random
Sleeping for 4
param1=1e-2,param2=random
Sleeping for 3
param1=1e-3,param2=random
Sleeping for 4
param1=1e-5,param2=random
Sleeping for 5
param1=1e-3,param2=ones
Sleeping for 5

There are many other switches and parameters:

parallel --dry-run ... will show you what it would do, without actually doing anything

parallel --eta ... which gives you an "Estimated Time of Arrival"

parallel --bar ... which gives you a progress bar

parallel -k ... which keeps output in order

parallel -j 8  ... which runs 8 jobs at a time rather than the default of 1 job per CPU core

parallel --pipepart ... which will split the contents of a massive file across subprocesses

Note also that GNU Parallel can distribute work across other machines in your network, and it has fail and retry handling, output tagging and so on...


问:
Log a clicked (external) link to webserver log or a file
I have a website written in php. I have a lots of external links like:

```<code><a href="http://example.com" target="_blank">
</code>```

What i want is that if the user clicks on these kind of links it should log this somewhere. Preferred is the apache log. If not possible then log in a file.

How can I do this with (probably with js)?

答:
A simple solution to get it in apache log is to replace external links with something like:

where  tracker.php  is on your server and simply redirects to the external site:

```<code>header('Location: ' . $_GET['url']);
</code>```

This could be done manually, or you could replace the links client side using jQuery like:

```<code>$("a[target='_blank']").each(function(e){
  var href = $(this).attr("href");
  $(this).attr("href", "tracker.php?url=" + encodeURIComponent(href));
});
</code>```

Fiddle of the above

Alternatively you can capture the click event using jQuery and make a request to your tracker.php file with the target URL as a query param and then redirect:

```<code><a href="http://example.com" target="_blank">test</a>

// Click event for a tags with target='_blank' attribute
$("a[target='_blank']").click(function(e){
  e.preventDefault(); // Prevent the default behaviour (the link opening)
  var href = $(this).attr("href"); // Get the href attribute of the clicked element

  // Make a get request to tracker.php passing the encoded href
  $.get("tracker.php?url=" + encodeURIComponent(href), function(data) {
    window.open(href); // Open the link in a new window once http request is complete
  });
});
</code>```

The downsides to this method are:

Right click + open in new tab won't be captured (nor middle mouse button clicks)

There will be a slight delay for the user during the http request.

Keyboard controls (focus + return key) will be captured.

For either of these to work you will need to ensure apache is configured to log GET requests, which it most likely will be by default, something like:

0.0.0.0 - - [20/Feb/2020:13:15:48 +0100] "GET /tracker.php?url=href="http://example.com" rel="nofollow noreferrer">http://example.com HTTP/1.1" 200

Body:
I have a website written in php. I have a lots of external links like:

What i want is that if the user clicks on these kind of links it should log this somewhere. Preferred is the apache log. If not possible then log in a file.

How can I do this with (probably with js)?

Body:
A simple solution to get it in apache log is to replace external links with something like:

<a href="tracker.php?url=http://example.com" target="_blank>

where  tracker.php  is on your server and simply redirects to the external site:

header('Location: ' . $_GET['url']);

This could be done manually, or you could replace the links client side using jQuery like:

$("a[target='_blank']").each(function(e){
  var href = $(this).attr("href");
  $(this).attr("href", "tracker.php?url=" + encodeURIComponent(href));
});

Fiddle of the above

Alternatively you can capture the click event using jQuery and make a request to your tracker.php file with the target URL as a query param and then redirect:

<a href="http://example.com" target="_blank">test</a>

// Click event for a tags with target='_blank' attribute
$("a[target='_blank']").click(function(e){
  e.preventDefault(); // Prevent the default behaviour (the link opening)
  var href = $(this).attr("href"); // Get the href attribute of the clicked element

  // Make a get request to tracker.php passing the encoded href
  $.get("tracker.php?url=" + encodeURIComponent(href), function(data) {
    window.open(href); // Open the link in a new window once http request is complete
  });
});

The downsides to this method are:

Right click + open in new tab won't be captured (nor middle mouse button clicks)

There will be a slight delay for the user during the http request.

Keyboard controls (focus + return key) will be captured.

For either of these to work you will need to ensure apache is configured to log GET requests, which it most likely will be by default, something like:

0.0.0.0 - - [20/Feb/2020:13:15:48 +0100] "GET /tracker.php?url=http://example.com HTTP/1.1" 200


问:
What library to install for Wonderpush in react native?
Hi what are the libraries to install in order to use the Wonderpush notifications in react-native ? Thanks !</p>

答:
How about this? https://github.com/wonderpush/react-native-wonderpush

 It's looks like working on React Native


问:
Can I send batched messages through a Websphere MQ Queue using Java JMS?
I'm working in a project that requires to send multiple messages to another application via asynchronous Websphere MQ messages. Actually I'm opening and closing sessions for every message I send. I appreciate your answers. By the way this is my first post here.</p>

答:
In your question header, you mentioned the word batched which made me think you might want to send all the grouped messages in a single transaction so that all messages in the group are delivered or none at all. (An atomic send). If this is an important piece, I would slightly modify Friek's (clean and concise) code as follows:

```<code>Session session = connection.createSession(true, SESSION_TRANSACTED);
....
producer.send(msgOne);
producer.send(msgTwo);
session.commit();
....
</code>```

Body:
In your question header, you mentioned the word batched which made me think you might want to send all the grouped messages in a single transaction so that all messages in the group are delivered or none at all. (An atomic send). If this is an important piece, I would slightly modify Friek's (clean and concise) code as follows:

Session session = connection.createSession(true, SESSION_TRANSACTED);
....
producer.send(msgOne);
producer.send(msgTwo);
session.commit();
....


问:
How align to bottom a row div in bootstrap?
I'm trying to align to bottm my row div or anyway tha last element.
I'm using bootstrap 3 and I have:

```<code><div id="main">
  <div class="container">
    <div class="row">
      <div class="col-md-12">
        <div class="logo col-centered">
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12 title text-center">THE TITLE</div>
    </div>
    <div class="row">
      <div class="col-md-5 col-centered text-center description">Lorem ipsum</div>
      <div class="description_arrow col-centered"></div>
    </div>
    <div class="row">
      <div class="col-md-5 col-sm-8 col-xs-12 col-centered">
        <div class="image-container">
          <img id="image-phone" src="img/image-phone.png" class="img-responsive" style="bottom:0px;">
        </div>
      </div>
    </div>
  </div>
</div>
</code>```

In the css I have:

```<code>#main {
  min-height: 100%;
}
</code>```

Now It look so:

```<code>|------------------------|
|==========ROW===========|
|==========ROW===========|
|==========ROW===========|
|==========SPACE=========|
|==========SPACE=========|
|------------------------|
</code>```

I want that look so:
Now It look so:

```<code>|------------------------|
|==========ROW===========|
|==========ROW===========|
|==========SPACE=========|
|==========SPACE=========|
|==========ROW===========|
|------------------------|
</code>```

So I want keep the last row in the bottom, how I can do ?

EDIT: I can't use margin-bottom on the 2° div, because the distance between the 2° row div and the last row div, can change, and I don't want and high value, because then on 13" screen the page became scrollable.

EDIT2: I can't use position: fixed and bottom: 0, because under div #main, I have other div(always 100% height).

WORKAROUND 1:
I do so:

```<code><div id="main" style="position: relative;">
</code>```

And in the row div class I do:

```<code><div class="row" style="position:absolute; bottom: 0px; width: 100%;">
</code>```

Seems works really fine, but I don't know if it's a good solution or not...please give me a feedback!

答:
A solution is if you add to the div with the class container the classes d-flex, flex-column and h-100.

Then you need to add mt-auto to the last row. That will add a margin to all the space that is left on the screen. So this works on all screensizes.

Also important is that the html, the body and all elements above the div with the class container use the full height. You can achieve this with the following css:

```<code>html, body {
  height: 100%;
}
</code>```

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

THE TITLE

Lorem ipsum

```

Body:
I'm trying to align to bottm my row div or anyway tha last element.
I'm using bootstrap 3 and I have:

THE TITLE

Lorem ipsum

In the css I have:

#main {
  min-height: 100%;
}

Now It look so:

|------------------------|
|==========ROW===========|
|==========ROW===========|
|==========ROW===========|
|==========SPACE=========|
|==========SPACE=========|
|------------------------|

I want that look so:
Now It look so:

|------------------------|
|==========ROW===========|
|==========ROW===========|
|==========SPACE=========|
|==========SPACE=========|
|==========ROW===========|
|------------------------|

So I want keep the last row in the bottom, how I can do ?

EDIT: I can't use margin-bottom on the 2° div, because the distance between the 2° row div and the last row div, can change, and I don't want and high value, because then on 13" screen the page became scrollable.

EDIT2: I can't use position: fixed and bottom: 0, because under div #main, I have other div(always 100% height).

WORKAROUND 1:
I do so:

And in the row div class I do:

Seems works really fine, but I don't know if it's a good solution or not...please give me a feedback!

Body:
A solution is if you add to the div with the class container the classes d-flex, flex-column and h-100.

Then you need to add mt-auto to the last row. That will add a margin to all the space that is left on the screen. So this works on all screensizes.

Also important is that the html, the body and all elements above the div with the class container use the full height. You can achieve this with the following css:

html, body {
  height: 100%;
}

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

<style>
html, body, #main {
  height: 100%;
}
</style>

<div id="main">
  <div class="container-fluid d-flex flex-column h-100">
    <div class="row">
      <div class="col-md-12">
        <div class="logo col-centered">
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12 title text-center">THE TITLE</div>
    </div>
    <div class="row">
      <div class="col-md-5 col-centered text-center description">Lorem ipsum</div>
      <div class="description_arrow col-centered"></div>
    </div>
    <div class="row mt-auto mb-3">
      <div class="col-md-5 col-sm-8 col-xs-12 col-centered">
        <div class="image-container">
          <img id="image-phone" src="https://upload.wikimedia.org/wikipedia/commons/f/f7/Stack_Overflow_logo.png" class="img-responsive" style="max-width: 100px; bottom:0px;">
        </div>
      </div>
    </div>
  </div>
</div>


问:
Equation rendering is not as expected
I'm playing around with equations, which I'm trying to render in LaTeX using KaTeX.

I think I'm doing something wrong, because the HTML render is not like it is shown on the demo output on KaTeX website.

For example, for the LaTeX code:

```<code>-1\times\frac{i\times\sqrt{64}}{8}\times\sqrt{i^2}
</code>```

This is what I've got:

This is what's expected according to the KaTeX demo:

In both case, it is the HTML rendering and not the MathML one.

I'm pretty sure I'm not using something correctly, but I can't point at the problem.

Any clue would be nice.

答:
Nevermind, I eventually found what was my mistake.

I just forgot to import katex stylesheet...

A simple @import '~katex/dist/katex.css'; in my styles.css did the trick.

Title: Equation rendering is not as expected

Body:
I'm playing around with equations, which I'm trying to render in LaTeX using KaTeX.

I think I'm doing something wrong, because the HTML render is not like it is shown on the demo output on KaTeX website.

For example, for the LaTeX code:

-1\times\frac{i\times\sqrt{64}}{8}\times\sqrt{i^2}

This is what I've got:

This is what's expected according to the KaTeX demo:

In both case, it is the HTML rendering and not the MathML one.

I'm pretty sure I'm not using something correctly, but I can't point at the problem.

Any clue would be nice.


问:
OUTER/CROSS APPLY Subquery without FROM clause
Most online documentation or tutorials discussing OUTER|CROSS APPLY describe something like:

```<code>SELECT columns
FROM table OUTER|CROSS APPLY (SELECT … FROM …);
</code>```

The subquery is normally a full SELECT … FROM … query.

I must have read somewhere that the subquery doesn’t need a FROM  in which case the columns appear to come from the main query:

```<code>SELECT columns
FROM table OUTER|CROSS APPLY (SELECT … );
</code>```

because I have used it routinely as a method to pre-calculate columns.

The question is what is really happening if the FROM is omitted from the sub query? Is it short for something else? I found that it does not mean the same as from the main table.

I have a sample here: http://sqlfiddle.com/#!18/0188f7/4/1

答:
What you have mentioned is not SUBQUERY. It is separate table expression. Whether you use FROM clause in the right expression or not problem.

If you use FROM clause in right table expression then you have got a source for the data in right table expression.

If you dont use FROM clause in the right expression, your source of data comes from left table expression.

First we will see what is APPLY operator. Reference BOL

Using APPLY

Both the left and right operands of the APPLY operator are table
  expressions. The main difference between these operands is that the
  right_table_source can use a table-valued function that takes a column
  from the left_table_source as one of the arguments of the function.
  The left_table_source can include table-valued functions, but it
  cannot contain arguments that are columns from the right_table_source.

The APPLY operator works in the following way to produce the table
  source for the FROM clause:

Evaluates right_table_source against each row of the left_table_source to produce rowsets.

The values in the right_table_source depend on left_table_source.
  right_table_source can be represented approximately this way:
  TVF(left_table_source.row), where TVF is a table-valued function.

Combines the result sets that are produced for each row in the evaluation of right_table_source with the left_table_source by
  performing a UNION ALL operation.

The list of columns produced by the result of the APPLY operator is
  the set of columns from the left_table_source that is combined with
  the list of columns from the right_table_source.

Based on the way you are using APPLY operator, it will behave as correlated subquery or CROSS JOIN

Using values of the left table expression in right table expression

--  without FROM (similar to Correlated Subquery)
    SELECT id, data, value
    FROM test OUTER APPLY(SELECT data*10 AS value) AS sq;
```

<ol start="2">
<li><strong>Not using values of left table expression in right table expression</strong></li>
</ol>

<pre class="lang-sql prettyprint-override"><code>--  FROM table (Similar to cross join)
    SELECT id, data, value
    FROM test OUTER APPLY(SELECT data*10 AS value FROM test) AS sq;
</code>```

Body:
Most online documentation or tutorials discussing OUTER|CROSS APPLY describe something like:

SELECT columns
FROM table OUTER|CROSS APPLY (SELECT … FROM …);

The subquery is normally a full SELECT … FROM … query.

I must have read somewhere that the subquery doesn’t need a FROM  in which case the columns appear to come from the main query:

SELECT columns
FROM table OUTER|CROSS APPLY (SELECT … );

because I have used it routinely as a method to pre-calculate columns.

The question is what is really happening if the FROM is omitted from the sub query? Is it short for something else? I found that it does not mean the same as from the main table.

I have a sample here: http://sqlfiddle.com/#!18/0188f7/4/1

Body:
What you have mentioned is not SUBQUERY. It is separate table expression. Whether you use FROM clause in the right expression or not problem.

If you use FROM clause in right table expression then you have got a source for the data in right table expression.

If you dont use FROM clause in the right expression, your source of data comes from left table expression.

First we will see what is APPLY operator. Reference BOL

Using APPLY

Both the left and right operands of the APPLY operator are table
  expressions. The main difference between these operands is that the
  right_table_source can use a table-valued function that takes a column
  from the left_table_source as one of the arguments of the function.
  The left_table_source can include table-valued functions, but it
  cannot contain arguments that are columns from the right_table_source.

The APPLY operator works in the following way to produce the table
  source for the FROM clause:

Evaluates right_table_source against each row of the left_table_source to produce rowsets.

The values in the right_table_source depend on left_table_source.
  right_table_source can be represented approximately this way:
  TVF(left_table_source.row), where TVF is a table-valued function.

Combines the result sets that are produced for each row in the evaluation of right_table_source with the left_table_source by
  performing a UNION ALL operation.

The list of columns produced by the result of the APPLY operator is
  the set of columns from the left_table_source that is combined with
  the list of columns from the right_table_source.

Based on the way you are using APPLY operator, it will behave as correlated subquery or CROSS JOIN

Using values of the left table expression in right table expression

--  without FROM (similar to Correlated Subquery)
    SELECT id, data, value
    FROM test OUTER APPLY(SELECT data*10 AS value) AS sq;

Not using values of left table expression in right table expression

--  FROM table (Similar to cross join)
    SELECT id, data, value
    FROM test OUTER APPLY(SELECT data*10 AS value FROM test) AS sq;