问:
amqp client doesn't show that RabbitMQ server connection is blocked
I run RabbitMQ image in docker-compose like this:

```<code>version: '2.2'

services:
  rabbitmq:
    networks:
      - private
    image: rabbitmq:3.8.0-beta.3-management
    ports:
      - 15672:15672
</code>```

Then connect to via other Node.js app like this:

```<code>const amqp = require('amqplib');

this._connection = await amqp.connect(xxxxxx);
console.log(this._connection.blocked);

this._connection.on("blocked", (reason) => {
    console.log("!!!! connection blocked");
});
</code>```

It works fine but few questions:

Why console.log(this._connection.blocked); outputs undefined;

How do I detect that connection is already blocked when I start the client? I.e. service is out of resources and RabbitMA manager says that connection is in 'blocking' state right after it connected. This is why this._connection.on("blocked" doesn't work

答:
I have check the document and source of amqplib, register event callback is the only way to receive Blocked Connection Notifications, amqplib connection hasn't use some member variable to show blocking state.

From offical document, I am not sure whether this mean there is no notification when you connect to an already blocked server:

If before the connections are unblocked the node also starts running low on disk space, another connection.blocked will not be sent

Body:
I run RabbitMQ image in docker-compose like this:

version: '2.2'

services:
  rabbitmq:
    networks:
      - private
    image: rabbitmq:3.8.0-beta.3-management
    ports:
      - 15672:15672

Then connect to via other Node.js app like this:

const amqp = require('amqplib');

this._connection = await amqp.connect(xxxxxx);
console.log(this._connection.blocked);

this._connection.on("blocked", (reason) => {
    console.log("!!!! connection blocked");
});

It works fine but few questions:

Why console.log(this._connection.blocked); outputs undefined;

How do I detect that connection is already blocked when I start the client? I.e. service is out of resources and RabbitMA manager says that connection is in 'blocking' state right after it connected. This is why this._connection.on("blocked" doesn't work


来源: stackexchange

问:
Tool for generating a call flow graph [C C++ solaris linux]
I'm quite fond of IDA, but I'm working in Solaris on this project.  I do have a linux machine, and if nothing is in the same league as IDA then I'll convince management to purchase a license for it.

Barring that, I'm looking for alternative suggestions.  Some of the other features in IDA would be handy, but the main thing I need at the moment is a call flow graph generator not based on source code.  If it needs extra output from the build step, that's fine, but some of the libraries I need to look at I don't have source for.

So far, it looks like my best choices are Valgrind's Callgrind, lida, and gprof.  Any further suggestions are welcome.

re: gprof, the GNU compiler set provided to us by Windriver is missing some libraries that would normally be supplied with a GNU compiler to provide (among other things) facilities for profiling.  It's a good solution to the more general problem, but for now I'm opting to try other solutions first.

edit Some of the Rational tools (Purify, Quantify, etc) might also work well for this.  I'm in the same boat as with IDA with that, but I figure someone googling might find the suggestion helpful.

edit2 Valgrind hasn't been ported to solaris/sparc ;p

答:
Take a look at the ERESI Project. It's a reverse engineering framework and it has a tool, called ELFsh, with capabilities of generating CFG from machine code. It doesn't have a stable/final yet, but it's worth a shot.

If you want to try it:

download and install (apt-get on Ubuntu)

run elfsh32. You'll enter a shell.

load your binary: load /bin/bash

analyse it: analyse

generate the graph: graph

You'll get a graph in .dot format and a rendered PNG (this one was too large to post here).

ContentLicense: CC BY-SA 3.0


问:
Can't adjust line height of list items in a mat-tree
I’m working with a mat-tree in my Angular 7 application. It looks like this:

```<code><mat-tree [dataSource]="nestedDataSource" [treeControl]="nestedTreeControl" class="example-tree">

<mat-tree-node *matTreeNodeDef="let node">
  <li>
    <span *ngFor="let item of getArrayForIndenting(node)">    </span>
    <button mat-icon-button disabled></button>
    {{ node.name }}: {{ node.value }}
  </li>
</mat-tree-node>

<mat-nested-tree-node *matTreeNodeDef="let node; when: hasNestedChild">
  <div>
    <span *ngFor="let item of getArrayForIndenting(node)">    </span>
    <button mat-icon-button matTreeNodeToggle>
      <mat-icon class="mat-icon-rtl-mirror">
        {{ nestedTreeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}
      </mat-icon>
    </button>
    {{ node.name }}
  </div>
  <ul [class.example-tree-invisible]="!nestedTreeControl.isExpanded(node)">
    <ng-container matTreeNodeOutlet></ng-container>
  </ul>
</mat-nested-tree-node>
</code>```

Notice that each node is spaced really far apart vertically. This is what I’m trying to adjust.

I’ve tried everything. I’ve tried styling the height of various elements in the above markup, the line-height, the margins, the padding, etc., but nothing works.

According to this site:

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_ul_compact_css

I should be able to set the line-height on the ul element, but I tried that and it doesn’t work.

Can anyone tell what I’m supposed to do? Thanks.

EDIT: Here's the CSS:

```<code>.example-tree-invisible {
  display: none;
}

.example-tree li,
.example-tree ul {
  list-style-type: none;
}
</code>```

Note that I removed the "mat-tree-node" class 'cause it didn't exist.

There's also a reference to fonts.googleapis.com in my index.html file:

```<code><link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</code>```

...which is probably what mat-icon-rtl-mirror comes from.

Hope that helps

答:
Yes, you are right you should be able to set line height of ul or li elements. However, you have not pasted the css for the above code. Please give us css or create https://plnkr.co/
so that we can debug and help you. It is also possible that you may have margin or padding in ul or li element, check that as well.</p>

ContentLicense: CC BY-SA 4.0

Body:
I’m working with a mat-tree in my Angular 7 application. It looks like this:

<mat-tree [dataSource]="nestedDataSource" [treeControl]="nestedTreeControl" class="example-tree">

<mat-tree-node *matTreeNodeDef="let node">

    <button mat-icon-button disabled></button>
    {{ node.name }}: {{ node.value }}

</mat-tree-node>

<mat-nested-tree-node *matTreeNodeDef="let node; when: hasNestedChild">

    <button mat-icon-button matTreeNodeToggle>
      <mat-icon class="mat-icon-rtl-mirror">
        {{ nestedTreeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}
      </mat-icon>
    </button>
    {{ node.name }}

    <ng-container matTreeNodeOutlet></ng-container>

</mat-nested-tree-node>

Notice that each node is spaced really far apart vertically. This is what I’m trying to adjust.

I’ve tried everything. I’ve tried styling the height of various elements in the above markup, the line-height, the margins, the padding, etc., but nothing works.

According to this site:

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_ul_compact_css

I should be able to set the line-height on the ul element, but I tried that and it doesn’t work.

Can anyone tell what I’m supposed to do? Thanks.

EDIT: Here's the CSS:

.example-tree-invisible {
  display: none;
}

.example-tree li,
.example-tree ul {
  list-style-type: none;
}

Note that I removed the "mat-tree-node" class 'cause it didn't exist.

There's also a reference to fonts.googleapis.com in my index.html file:

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

...which is probably what mat-icon-rtl-mirror comes from.

Hope that helps


问:
C# Permutate a set of strings given n and given the maximum array length
How can you permutate the set of strings based on the set length, I have lets say 50 values in an array and only want to combine 24 values that is comma delimited Examples: (string1,string2,string3) but without ever repeating the combinations and the order. I have this code below. </p>

```<code>class Program
{
    static void Main(string[] args)
    {
        //var values1 = new[] { 1, 2, 3, 4, 5 };

        //foreach (var permutation in values1.GetPermutations())
        //{
        //    Console.WriteLine(string.Join(", ", permutation));
        //}

        var values2 = new[] { "asd", "das", "sad", "q1we", "asd" };

        foreach (var permutation in values2.GetPermutations())
        {
            Console.WriteLine(string.Join(",", permutation));
        }

        Console.ReadLine();
    }
}

public static class SomeExtensions
{
    public static IEnumerable<IEnumerable<T>> GetPermutations<T>(this IEnumerable<T> enumerable)
    {
        var array = enumerable as T[] ?? enumerable.ToArray();

        var factorials = Enumerable.Range(0, array.Length + 1)
            .Select(Factorial)
            .ToArray();

        for (var i = 0L; i < factorials[array.Length]; i++)
        {
            var sequence = GenerateSequence(i, array.Length - 1, factorials);

            yield return GeneratePermutation(array, sequence);
        }
    }

    private static IEnumerable<T> GeneratePermutation<T>(T[] array, IReadOnlyList<int> sequence)
    {
        var clone = (T[])array.Clone();

        for (int i = 0; i < clone.Length - 1; i++)
        {
            Swap(ref clone[i], ref clone[i + sequence[i]]);
        }

        return clone;
    }

    private static int[] GenerateSequence(long number, int size, IReadOnlyList<long> factorials)
    {
        var sequence = new int[size];

        for (var j = 0; j < sequence.Length; j++)
        {
            var facto = factorials[sequence.Length - j];

            sequence[j] = (int)(number / facto);
            number = (int)(number % facto);
        }

        return sequence;
    }

    static void Swap<T>(ref T a, ref T b)
    {
        T temp = a;
        a = b;
        b = temp;
    }

    private static long Factorial(int n)
    {
        long result = n;

        for (int i = 1; i < n; i++)
        {
            result = result * i;
        }

        return result;
    }
}
</code>```

<p>How can I be able to combine an array of string (24 values) into 100 rows of unique combination? Can you please explain how and whats the best way on how to do it? </p>

答:
I propose the use of more deterministic permutation generator. Couple this with existing LINQ extension methods like Select(), Distinct() and Take() and you've got what you need:

```<code>var results = values2.Permutations(24)
                     .Select(p => String.Join(",", p))
                     .Distinct()
                     .Take(100);
foreach (var permutation in results)
    Console.WriteLine(permutation);
</code>```

where Permutations() is implemented as an extension method. The number 24 here indicates how many items should be in each permutation. It is the k in nPk.

The Select() call creates a string string with all the items for the particular permutation.

The Distinct() call makes sure that we only end up with unique strings.

The Take() call limits the number of strings that we collect.

Here is a naive implementation using recursion to generate the permutations:

```<code>public static IEnumerable<T[]> Permutations<T>(this IEnumerable<T> source, int k)
{
    if (k < 0)
        throw new ArgumentOutOfRangeException(nameof(k), "May not be negative");

    var items = source.ToArray();
    if (k > items.Length)
        throw new ArgumentOutOfRangeException(nameof(k), "May not be bigger than the number of items in source");

    var buffer = new ArraySegment<T>(items, 0, k);
    return Permute(0);

    IEnumerable<T[]> Permute(int depth)
    {
        if (depth == k)
        {
            yield return buffer.ToArray();
            yield break;
        }

        for (int i = depth; i < items.Length; i++)
        {
            Swap(depth, i);
            foreach (var permutation in Permute(depth + 1))
                yield return permutation;
            Swap(depth, i);
        }
    }

    void Swap(int a, int b)
    {
        if (a != b)
        {
            T t = items[a];
            items[a] = items[b];
            items[b] = t;
        }
    }
}
</code>```

I leave it to you to replace the implementation with the algorithm of your choice.

Body:
How can you permutate the set of strings based on the set length, I have lets say 50 values in an array and only want to combine 24 values that is comma delimited Examples: (string1,string2,string3) but without ever repeating the combinations and the order. I have this code below.

class Program
{
    static void Main(string[] args)
    {
        //var values1 = new[] { 1, 2, 3, 4, 5 };

        //foreach (var permutation in values1.GetPermutations())
        //{
        //    Console.WriteLine(string.Join(", ", permutation));
        //}

        var values2 = new[] { "asd", "das", "sad", "q1we", "asd" };

        foreach (var permutation in values2.GetPermutations())
        {
            Console.WriteLine(string.Join(",", permutation));
        }

        Console.ReadLine();
    }
}

public static class SomeExtensions
{
    public static IEnumerable<IEnumerable<T>> GetPermutations<T>(this IEnumerable<T> enumerable)
    {
        var array = enumerable as T[] ?? enumerable.ToArray();

        var factorials = Enumerable.Range(0, array.Length + 1)
            .Select(Factorial)
            .ToArray();

        for (var i = 0L; i < factorials[array.Length]; i++)
        {
            var sequence = GenerateSequence(i, array.Length - 1, factorials);

            yield return GeneratePermutation(array, sequence);
        }
    }

    private static IEnumerable<T> GeneratePermutation<T>(T[] array, IReadOnlyList<int> sequence)
    {
        var clone = (T[])array.Clone();

        for (int i = 0; i < clone.Length - 1; i++)
        {
            Swap(ref clone[i], ref clone[i + sequence[i]]);
        }

        return clone;
    }

    private static int[] GenerateSequence(long number, int size, IReadOnlyList<long> factorials)
    {
        var sequence = new int[size];

        for (var j = 0; j < sequence.Length; j++)
        {
            var facto = factorials[sequence.Length - j];

            sequence[j] = (int)(number / facto);
            number = (int)(number % facto);
        }

        return sequence;
    }

    static void Swap<T>(ref T a, ref T b)
    {
        T temp = a;
        a = b;
        b = temp;
    }

    private static long Factorial(int n)
    {
        long result = n;

        for (int i = 1; i < n; i++)
        {
            result = result * i;
        }

        return result;
    }
}

How can I be able to combine an array of string (24 values) into 100 rows of unique combination? Can you please explain how and whats the best way on how to do it?

Body:
I propose the use of more deterministic permutation generator. Couple this with existing LINQ extension methods like Select(), Distinct() and Take() and you've got what you need:

var results = values2.Permutations(24)
                     .Select(p => String.Join(",", p))
                     .Distinct()
                     .Take(100);
foreach (var permutation in results)
    Console.WriteLine(permutation);

where Permutations() is implemented as an extension method. The number 24 here indicates how many items should be in each permutation. It is the k in nPk.

The Select() call creates a string string with all the items for the particular permutation.

The Distinct() call makes sure that we only end up with unique strings.

The Take() call limits the number of strings that we collect.

Here is a naive implementation using recursion to generate the permutations:

public static IEnumerable<T[]> Permutations<T>(this IEnumerable<T> source, int k)
{
    if (k < 0)
        throw new ArgumentOutOfRangeException(nameof(k), "May not be negative");

    var items = source.ToArray();
    if (k > items.Length)
        throw new ArgumentOutOfRangeException(nameof(k), "May not be bigger than the number of items in source");

    var buffer = new ArraySegment<T>(items, 0, k);
    return Permute(0);

    IEnumerable<T[]> Permute(int depth)
    {
        if (depth == k)
        {
            yield return buffer.ToArray();
            yield break;
        }

        for (int i = depth; i < items.Length; i++)
        {
            Swap(depth, i);
            foreach (var permutation in Permute(depth + 1))
                yield return permutation;
            Swap(depth, i);
        }
    }

    void Swap(int a, int b)
    {
        if (a != b)
        {
            T t = items[a];
            items[a] = items[b];
            items[b] = t;
        }
    }
}

I leave it to you to replace the implementation with the algorithm of your choice.


问:
What is better to use just one method with switch or 4 different methods?
I have a object and i get some fields from it, i made a method with a switch statement, the idea was make it generic and just call this method through parameters but now I´m not sure.

The options are

```<code>private String getCode(Row row, String code) {
    String result;
    switch (code) {
      case code1:
        result = row.getString("constant1");
        break;
      case code2:
        result = row.getString(constant2);
        break;
      case code3:
        result = row.getString(constant3);
        break;
      case code4:
        result = row.getString(constant4);
        break;
      default:
        result = null;
    }
    return result;
  }
</code>```

or

```<code>private String getcode1(Row row){
    return row.getString("constant1")
  }

  private String getcode1(Row row){
    return row.getString("constant2")
  }
  private String getcode1(Row row){
    return row.getString("constant3")
  }

  private String getcode1(Row row){
    return row.getString("constant4")
  }
</code>```

I wand to use the better way, I´m a little confuse

答:
This question is little bit to much, but I will try to explain best I could. For me second option is no no at all. Why? You are making methods that you will have to sort out with some if/else statements anyway, for example:

```<code>if (code.equals(code1))
    someString = getcode1(row);
else if (code.equals(code2))
    somestring = getcode2(row);
else if (code.equals(code3))
    someString = getcode3(row);
else
    someString = getcode4(row);
</code>```

Why not use this:

```<code>if (code.equals(code1))
    someString = row.getString("content1");
else if (code.equals(code2))
    somestring = row.getString("content2");
else if (code.equals(code3))
    someString = row.getString("content3");
else
    someString = row.getString("content4");
</code>```

The first one I can see being used, but there is alternative there. Give us entire minimal requirement code with entire class and methods and we could help you far more than using these snippets of code.

Body:
I have a object and i get some fields from it, i made a method with a switch statement, the idea was make it generic and just call this method through parameters but now I´m not sure.

The options are

private String getCode(Row row, String code) {
    String result;
    switch (code) {
      case code1:
        result = row.getString("constant1");
        break;
      case code2:
        result = row.getString(constant2);
        break;
      case code3:
        result = row.getString(constant3);
        break;
      case code4:
        result = row.getString(constant4);
        break;
      default:
        result = null;
    }
    return result;
  }

or

private String getcode1(Row row){
    return row.getString("constant1")
  }

  private String getcode1(Row row){
    return row.getString("constant2")
  }
  private String getcode1(Row row){
    return row.getString("constant3")
  }

  private String getcode1(Row row){
    return row.getString("constant4")
  }

I wand to use the better way, I´m a little confuse

Body:
This question is little bit to much, but I will try to explain best I could. For me second option is no no at all. Why? You are making methods that you will have to sort out with some if/else statements anyway, for example:

if (code.equals(code1))
    someString = getcode1(row);
else if (code.equals(code2))
    somestring = getcode2(row);
else if (code.equals(code3))
    someString = getcode3(row);
else
    someString = getcode4(row);

Why not use this:

if (code.equals(code1))
    someString = row.getString("content1");
else if (code.equals(code2))
    somestring = row.getString("content2");
else if (code.equals(code3))
    someString = row.getString("content3");
else
    someString = row.getString("content4");

The first one I can see being used, but there is alternative there. Give us entire minimal requirement code with entire class and methods and we could help you far more than using these snippets of code.


问:
Can't restore or backup Odoo Databases
I am getting the following error. I can't backup and cant't restore any database. This will be a huge issue if the database crashes:

```<code>Database restore error: Postgres subprocess ('/usr/bin/pg_restore', u'--dbname=back', '--no-owner', '/tmp/tmpKY434e') error 1

Database backup error: Postgres subprocess ('/usr/bin/pg_dump', '--no-owner', '--file=/tmp/tmp40EUve/dump.sql', u'Live_GasandOil') error 1
</code>```

Please help this is very critical

答: The issue was that there was an extra table in the database which was not supposed to be there. on drooping that table i got that fixed. </p>

Title: Can't restore or backup Odoo Databases

Body:
I am getting the following error. I can't backup and cant't restore any database. This will be a huge issue if the database crashes:

Database restore error: Postgres subprocess ('/usr/bin/pg_restore', u'--dbname=back', '--no-owner', '/tmp/tmpKY434e') error 1

Database backup error: Postgres subprocess ('/usr/bin/pg_dump', '--no-owner', '--file=/tmp/tmp40EUve/dump.sql', u'Live_GasandOil') error 1

Please help this is very critical


问:
Issue on Product version of Styled-Components when render with Rendertron
have very simple sample app which build Create React App + Styled-Components to prove this issue. But I have real big application which I am facing this issue which I am going to explain it below.

I would like to pre-render this app with Rendertron for SEO/GoogleBots and etc. But the problem is when I build PRODUCTION version of React App which use Styled-Components . all the style will be missing on static version which Rendertron produced, but from other side if I try the same workflow with  dev-server of app , everything looks fine .

So far I know there is different on PROD version and DEV version of my application when I render it with Rendertron . But I am not sure what cause this issue and how I can fix this issue .

I am looking for solution or idea which can help me to solve this issue .

Here is my sample code which I peppered for test .

https://github.com/AJ-7885/test-styled-component-with-rendertron

Here is screen shot from different version of Rendered version by Rendertron base on PROD or DEV version of the same application .

enter image description here

答:
You need to render your styles on the server side and inject those styles in your pre-rendered react app. Styled-components explains how to do that here: https://www.styled-components.com/docs/advanced#server-side-rendering

Also, I'd recommend using react-snap for pre-rendering since that is recommended by the Create React App docs. react-snap seems to be more of a React-specific solution that may be easier to implement, especially with styled-components.


问:
AspectJ 1.9.4 with OpenJDK 11 Without Spring Context not working as a dependent module
I am trying to create custom loadtime annotations with AspectJ, Open JDK11 without Spring Context. It works fine within a module and annotations are weaving at class load time and aspects are executing at runtime. No issues, But when aspectJ implemented module added as a dependency on another module. AspectJ and annotations are not processing. Am I missing any configuration?

module-a

@Documented
@Inherited
@Target(METHOD)
@Retention(RUNTIME)
public @interface Counter {
    String name() default "";
}
```

<pre class="lang-java prettyprint-override"><code>@Aspect
public class CounterAspect {
    @Around("execution(* *.*(..)) && @annotation(counter)")
    public void myBeforeLogger(ProceedingJoinPoint joinPoint, Counter counter) {

        System.out.println("Okay - we're in the before handler...");
        System.out.println("The test annotation value is: " + counter.name().toString());
}
</code>```

resources/META-INF/aop.xml

<aspectj>
    <aspects>
        <aspect name="CounterAspect"/>
    </aspects>
    <weaver options="-verbose">

        <include within="*" />
    </weaver>
</aspectj>
```

<p><strong>pom.xml</strong></p>

<pre class="lang-xml prettyprint-override"><code><properties>
    <aspectj.version>1.9.4</aspectj.version>
</properties>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>${aspectj.version}</version>
</dependency>
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.11</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <argLine>
                -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                </argLine>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>
</code>```

module-b

pom.xml

<dependency>
    <groupId>org.mymodule</groupId>
    <artifactId>module-a</artifactId>
    <version>1.0.0</version>
</dependency>
```

<pre class="lang-java prettyprint-override"><code>public class MyCounter {
    @Counter(name="call_count")
    public void count() {}
}
</code>```

public class MyCounterTest {
    @Test
    public void testCount() {
        MyCounter counter = new MyCounter();
        counter.count();
        //NOTE: I expect CounterAspect from module-a should be intercepted. It is not working!!!! There is no aspectJ class loading verbose in console.
    }
}
```

答:
I suggest you create a parent POM with some predefined properties, dependency versions and plugin configurations. Your two sub-modules (one for application + test, one for aspect) can use these definitions, which leads to shorter sub-module POMs:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>de.scrum-master</groupId>
  <artifactId>aspectj-ltw-test-multi-module</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.source-target.version>11</java.source-target.version>
    <aspectj.version>1.9.4</aspectj.version>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.3</version>
          <configuration>
            <source>${java.source-target.version}</source>
            <target>${java.source-target.version}</target>

            <useIncrementalCompilation>false</useIncrementalCompilation>
          </configuration>
        </plugin>
        <plugin>
          <groupId>com.nickwongdev</groupId>
          <artifactId>aspectj-maven-plugin</artifactId>
          <version>1.12.1</version>
          <configuration>

            <source>${java.source-target.version}</source>
            <target>${java.source-target.version}</target>
            <Xlint>ignore</Xlint>
            <complianceLevel>${java.source-target.version}</complianceLevel>
            <encoding>${project.build.sourceEncoding}</encoding>

          </configuration>
          <executions>
            <execution>

              <phase>process-sources</phase>
              <goals>
                <goal>compile</goal>
                <goal>test-compile</goal>
              </goals>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>org.aspectj</groupId>
              <artifactId>aspectjtools</artifactId>
              <version>${aspectj.version}</version>
            </dependency>
            <dependency>
              <groupId>org.aspectj</groupId>
              <artifactId>aspectjweaver</artifactId>
              <version>${aspectj.version}</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.9</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>${aspectj.version}</version>
      </dependency>
      <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${aspectj.version}</version>
      </dependency>
      <dependency>
        <groupId>de.scrum-master</groupId>
        <artifactId>aspect</artifactId>
        <version>1.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <modules>
    <module>aspect</module>
    <module>application</module>
  </modules>

</project>
```

<p>Please note that I am not using the original AspectJ Maven plugin but a fork which supports Java 11. The original still lags behind. As you said you want to use Java 11, you have to do that. With Java 8 you can use the original plugin.</p>

<p><strong>Aspect module:</strong></p>

<pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>de.scrum-master</groupId>
    <artifactId>aspectj-ltw-test-multi-module</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>

  <groupId>de.scrum-master</groupId>
  <artifactId>aspect</artifactId>
  <version>1.0-SNAPSHOT</version>

  <build>
    <plugins>
      <plugin>
        <groupId>com.nickwongdev</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
    </dependency>
  </dependencies>
</project>
</code>```

<aspectj>
  <aspects>
    <aspect name="de.scrum_master.aspect.CounterAspect"/>
  </aspects>
  <weaver options="-verbose">

    <include within="*"/>
  </weaver>
</aspectj>
```

<pre class="lang-java prettyprint-override"><code>package de.scrum_master.aspect;

import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Documented
@Inherited
@Target(METHOD)
@Retention(RUNTIME)
public @interface Counter {
  String name() default "";
}
</code>```

package de.scrum_master.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class CounterAspect {
  @Around("execution(* *.*(..)) && @annotation(counter)")
  public void myBeforeLogger(ProceedingJoinPoint joinPoint, Counter counter) {
    System.out.println(joinPoint + " -> " + counter.name());
  }
}
```

<p><strong>Application module:</strong></p>

<pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>de.scrum-master</groupId>
    <artifactId>aspectj-ltw-test-multi-module</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>

  <groupId>de.scrum-master</groupId>
  <artifactId>application</artifactId>
  <version>1.0-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>de.scrum-master</groupId>
      <artifactId>aspect</artifactId>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>
            -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
          </argLine>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
</code>```

package de.scrum_master.app;

import de.scrum_master.aspect.Counter;

public class MyCounter {
  @Counter(name = "call_count")
  public void count() {}
}
```

<pre class="lang-java prettyprint-override"><code>package de.scrum_master.app;

import org.junit.Test;

public class MyCounterTest {
  @Test
  public void testCount() {
    new MyCounter().count();
  }
}
</code>```

Now if you run mvn clean verify or just mvn clean test you will get the following console log for the application module test:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
[AppClassLoader@2aae9190] info AspectJ Weaver Version 1.9.4 built on Friday May 10, 2019 at 08:43:10 PDT
[AppClassLoader@2aae9190] info register classloader jdk.internal.loader.ClassLoaders$AppClassLoader@2aae9190
[AppClassLoader@2aae9190] info using configuration (...)/SO_AJ_LTWTestMultiModule_56397605/aspect/target/classes/META-INF/aop.xml
[AppClassLoader@2aae9190] info register aspect de.scrum_master.aspect.CounterAspect
[IsolatedClassLoader@74e52ef6] info AspectJ Weaver Version 1.9.4 built on Friday May 10, 2019 at 08:43:10 PDT
[IsolatedClassLoader@74e52ef6] info register classloader org.apache.maven.surefire.booter.IsolatedClassLoader@74e52ef6
[IsolatedClassLoader@74e52ef6] info using configuration (...)/SO_AJ_LTWTestMultiModule_56397605/aspect/target/classes/META-INF/aop.xml
[IsolatedClassLoader@74e52ef6] info register aspect de.scrum_master.aspect.CounterAspect
Running de.scrum_master.app.MyCounterTest
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor (file:/(...)/.m2/repository/org/aspectj/aspectjweaver/1.9.4/aspectjweaver-1.9.4.jar) to class java.lang.ClassLoader
WARNING: Please consider reporting this to the maintainers of org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[AppClassLoader@2aae9190] info processing reweavable type de.scrum_master.aspect.CounterAspect: de\scrum_master\aspect\CounterAspect.aj
[AppClassLoader@2aae9190] info successfully verified type de.scrum_master.aspect.CounterAspect exists.  Originates from de\scrum_master\aspect\CounterAspect.aj
execution(void de.scrum_master.app.MyCounter.count()) -> call_count
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.885 sec
```

<p>Please especially note</p>

<pre class="lang-none prettyprint-override"><code>execution(void de.scrum_master.app.MyCounter.count()) -> call_count
</code>```

This is what you want, the load-time-woven aspect kicks in for your test.

Update: I created a GitHub repository for you. You can just clone it instead of copying all my code snippets from this answer.

Body:
I am trying to create custom loadtime annotations with AspectJ, Open JDK11 without Spring Context. It works fine within a module and annotations are weaving at class load time and aspects are executing at runtime. No issues, But when aspectJ implemented module added as a dependency on another module. AspectJ and annotations are not processing. Am I missing any configuration?

module-a

@Documented
@Inherited
@Target(METHOD)
@Retention(RUNTIME)
public @interface Counter {
    String name() default "";
}

@Aspect
public class CounterAspect {
    @Around("execution(* *.*(..)) && @annotation(counter)")
    public void myBeforeLogger(ProceedingJoinPoint joinPoint, Counter counter) {

        System.out.println("Okay - we're in the before handler...");
        System.out.println("The test annotation value is: " + counter.name().toString());
}

resources/META-INF/aop.xml

<aspectj>
    <aspects>
        <aspect name="CounterAspect"/>
    </aspects>
    <weaver options="-verbose">

        <include within="*" />
    </weaver>
</aspectj>

pom.xml

<properties>
    <aspectj.version>1.9.4</aspectj.version>
</properties>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>${aspectj.version}</version>
</dependency>
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.11</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <argLine>
                -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                </argLine>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

module-b

pom.xml

<dependency>
    <groupId>org.mymodule</groupId>
    <artifactId>module-a</artifactId>
    <version>1.0.0</version>
</dependency>

public class MyCounter {
    @Counter(name="call_count")
    public void count() {}
}

public class MyCounterTest {
    @Test
    public void testCount() {
        MyCounter counter = new MyCounter();
        counter.count();
        //NOTE: I expect CounterAspect from module-a should be intercepted. It is not working!!!! There is no aspectJ class loading verbose in console.
    }
}

Body:
I suggest you create a parent POM with some predefined properties, dependency versions and plugin configurations. Your two sub-modules (one for application + test, one for aspect) can use these definitions, which leads to shorter sub-module POMs:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>de.scrum-master</groupId>
  <artifactId>aspectj-ltw-test-multi-module</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.source-target.version>11</java.source-target.version>
    <aspectj.version>1.9.4</aspectj.version>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.3</version>
          <configuration>
            <source>${java.source-target.version}</source>
            <target>${java.source-target.version}</target>
            <!-- IMPORTANT -->
            <useIncrementalCompilation>false</useIncrementalCompilation>
          </configuration>
        </plugin>
        <plugin>
          <groupId>com.nickwongdev</groupId>
          <artifactId>aspectj-maven-plugin</artifactId>
          <version>1.12.1</version>
          <configuration>
            <!--<showWeaveInfo>true</showWeaveInfo>-->
            <source>${java.source-target.version}</source>
            <target>${java.source-target.version}</target>
            <Xlint>ignore</Xlint>
            <complianceLevel>${java.source-target.version}</complianceLevel>
            <encoding>${project.build.sourceEncoding}</encoding>
            <!--<verbose>true</verbose>-->
            <!--<warn>constructorName,packageDefaultMethod,deprecation,maskedCatchBlocks,unusedLocals,unusedArguments,unusedImport</warn>-->
          </configuration>
          <executions>
            <execution>
              <!-- IMPORTANT -->
              <phase>process-sources</phase>
              <goals>
                <goal>compile</goal>
                <goal>test-compile</goal>
              </goals>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>org.aspectj</groupId>
              <artifactId>aspectjtools</artifactId>
              <version>${aspectj.version}</version>
            </dependency>
            <dependency>
              <groupId>org.aspectj</groupId>
              <artifactId>aspectjweaver</artifactId>
              <version>${aspectj.version}</version>
            </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.9</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>${aspectj.version}</version>
      </dependency>
      <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${aspectj.version}</version>
      </dependency>
      <dependency>
        <groupId>de.scrum-master</groupId>
        <artifactId>aspect</artifactId>
        <version>1.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <modules>
    <module>aspect</module>
    <module>application</module>
  </modules>

</project>

Please note that I am not using the original AspectJ Maven plugin but a fork which supports Java 11. The original still lags behind. As you said you want to use Java 11, you have to do that. With Java 8 you can use the original plugin.

Aspect module:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>de.scrum-master</groupId>
    <artifactId>aspectj-ltw-test-multi-module</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>

  <groupId>de.scrum-master</groupId>
  <artifactId>aspect</artifactId>
  <version>1.0-SNAPSHOT</version>

  <build>
    <plugins>
      <plugin>
        <groupId>com.nickwongdev</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
    </dependency>
  </dependencies>
</project>

<aspectj>
  <aspects>
    <aspect name="de.scrum_master.aspect.CounterAspect"/>
  </aspects>
  <weaver options="-verbose">
    <!-- weave anything -->
    <include within="*"/>
  </weaver>
</aspectj>

package de.scrum_master.aspect;

import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Documented
@Inherited
@Target(METHOD)
@Retention(RUNTIME)
public @interface Counter {
  String name() default "";
}

package de.scrum_master.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class CounterAspect {
  @Around("execution(* *.*(..)) && @annotation(counter)")
  public void myBeforeLogger(ProceedingJoinPoint joinPoint, Counter counter) {
    System.out.println(joinPoint + " -> " + counter.name());
  }
}

Application module:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>de.scrum-master</groupId>
    <artifactId>aspectj-ltw-test-multi-module</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>

  <groupId>de.scrum-master</groupId>
  <artifactId>application</artifactId>
  <version>1.0-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>de.scrum-master</groupId>
      <artifactId>aspect</artifactId>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>
            -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
          </argLine>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

package de.scrum_master.app;

import de.scrum_master.aspect.Counter;

public class MyCounter {
  @Counter(name = "call_count")
  public void count() {}
}

package de.scrum_master.app;

import org.junit.Test;

public class MyCounterTest {
  @Test
  public void testCount() {
    new MyCounter().count();
  }
}

Now if you run mvn clean verify or just mvn clean test you will get the following console log for the application module test:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
[AppClassLoader@2aae9190] info AspectJ Weaver Version 1.9.4 built on Friday May 10, 2019 at 08:43:10 PDT
[AppClassLoader@2aae9190] info register classloader jdk.internal.loader.ClassLoaders$AppClassLoader@2aae9190
[AppClassLoader@2aae9190] info using configuration (...)/SO_AJ_LTWTestMultiModule_56397605/aspect/target/classes/META-INF/aop.xml
[AppClassLoader@2aae9190] info register aspect de.scrum_master.aspect.CounterAspect
[IsolatedClassLoader@74e52ef6] info AspectJ Weaver Version 1.9.4 built on Friday May 10, 2019 at 08:43:10 PDT
[IsolatedClassLoader@74e52ef6] info register classloader org.apache.maven.surefire.booter.IsolatedClassLoader@74e52ef6
[IsolatedClassLoader@74e52ef6] info using configuration (...)/SO_AJ_LTWTestMultiModule_56397605/aspect/target/classes/META-INF/aop.xml
[IsolatedClassLoader@74e52ef6] info register aspect de.scrum_master.aspect.CounterAspect
Running de.scrum_master.app.MyCounterTest
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor (file:/(...)/.m2/repository/org/aspectj/aspectjweaver/1.9.4/aspectjweaver-1.9.4.jar) to class java.lang.ClassLoader
WARNING: Please consider reporting this to the maintainers of org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[AppClassLoader@2aae9190] info processing reweavable type de.scrum_master.aspect.CounterAspect: de\scrum_master\aspect\CounterAspect.aj
[AppClassLoader@2aae9190] info successfully verified type de.scrum_master.aspect.CounterAspect exists.  Originates from de\scrum_master\aspect\CounterAspect.aj
execution(void de.scrum_master.app.MyCounter.count()) -> call_count
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.885 sec

Please especially note

execution(void de.scrum_master.app.MyCounter.count()) -> call_count

This is what you want, the load-time-woven aspect kicks in for your test.

Update: I created a GitHub repository for you. You can just clone it instead of copying all my code snippets from this answer.


问:
Display rows to other table
I want to show less rows for print preview.

For example: I have 4 rows in my table(Items) and each row has the same Item no, Item name and Color but the other column (Sizes and Quantity) are not the same.

Is there a way I can show this data into one row to the table?

I expect each same Item_no shows one row only to the table.

```<code><?php
       $sql = "SELECT * FROM Items";
       $items = mysqli_query($connection, $sql);
       while($item = mysqli_fetch_assoc($items)){
       ?>
              <td><?php echo $item['Item_no'];?></td>
              <td><?php echo $item['Item_name'];?></td>
              <td><?php echo $item['Item_color'];?></td>
              <td><?php echo $item['Item_size'];?></td>
              <td><?php echo $item['Item_qty'];?></td>
       <?php } ?>
</code>```

答:
If the Item_no are the same, you can always group by Item_no and get a SUM of Item_qty

```<code>$sql = "SELECT Item_no,Item_name,Item_color,Item_size,SUM(Item_qty) FROM Items GROUP BY Item_no";
</code>```

More at,

https://www.w3resource.com/mysql/aggregate-functions-and-grouping/aggregate-functions-and-grouping-sum-with-group-by.php

Title: Display rows to other table

Body:
I want to show less rows for print preview.

For example: I have 4 rows in my table(Items) and each row has the same Item no, Item name and Color but the other column (Sizes and Quantity) are not the same.

Is there a way I can show this data into one row to the table?

I expect each same Item_no shows one row only to the table.

<?php
       $sql = "SELECT * FROM Items";
       $items = mysqli_query($connection, $sql);
       while($item = mysqli_fetch_assoc($items)){
       ?>
              <?php echo $item['Item_no'];?>
              <?php echo $item['Item_name'];?>
              <?php echo $item['Item_color'];?>
              <?php echo $item['Item_size'];?>
              <?php echo $item['Item_qty'];?>
       <?php } ?>

Body:
If the Item_no are the same, you can always group by Item_no and get a SUM of Item_qty

$sql = "SELECT Item_no,Item_name,Item_color,Item_size,SUM(Item_qty) FROM Items GROUP BY Item_no";

More at,

https://www.w3resource.com/mysql/aggregate-functions-and-grouping/aggregate-functions-and-grouping-sum-with-group-by.php


问:
Changing breadcrumb according to user parameters in ASP.NET MVC
I use MvcSiteMapProvider to add Breadcrumbs to my site.
I want to change breadcrumb trail according to parameters used in ActionResult.
So, link looks like this:
localhost:49345/Evaluation/ChoicePeriod?typeControl=Input

Current view of SiteMapPath:
Main > Evaluation

Expected view:
Main > Evaluation > Input

Routes:

```<code>  routes.MapRoute(
            name: "Evaluation",
            url: "Evaluation/ChoicePeriod/{action}/{typeControl}",
            defaults: new { action = "Index", typeControl = UrlParameter.Optional }
        );

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Main", action = "Index", id = UrlParameter.Optional }
        );
</code>```

Sitemap:

```<code><mvcSiteMapNode title="Main" controller="Main" action="Index">
 <mvcSiteMapNode title="Evaluation" area="Evaluation" controller="ChoicePeriod" action="Index" >
  <mvcSiteMapNode title="Input" area="Evaluation" controller="ChoicePeriod" action="Index" preservedRouteParameters="typeControl" key="typeControl"/>
 </mvcSiteMapNode>
</mvcSiteMapNode>
</code>```

I've added typeControl value to RouteValues and now i don't know how to show it in SiteMapPath

```<code>    public ActionResult Index(string typeControl, int? id_pred)
    {
        var node = MvcSiteMapProvider.SiteMaps.Current.FindSiteMapNodeFromKey("typeControl");
        if (node != null)
        {
            node.RouteValues["typeControl"] = typeControl;
        }
        ...
</code>```

Is there any way to make my breadcrumbs look like i expected to? Thanks.

答:
you should use URL in your mvc.sitemap: </p>

```<code><mvcSiteMapNode title="Main" controller="Main" action="Index">
 <mvcSiteMapNode title="Evaluation" area="Evaluation" controller="ChoicePeriod" action="Index" >
  <mvcSiteMapNode title="Input" area="Evaluation" controller="ChoicePeriod" action="Index" url="/Evaluation/ChoicePeriod/Input"/>
 </mvcSiteMapNode>
</mvcSiteMapNode>
</code>```

Body:
I use MvcSiteMapProvider to add Breadcrumbs to my site.
I want to change breadcrumb trail according to parameters used in ActionResult.
So, link looks like this:
localhost:49345/Evaluation/ChoicePeriod?typeControl=Input

Current view of SiteMapPath:
Main > Evaluation

Expected view:
Main > Evaluation > Input

Routes:

  routes.MapRoute(
            name: "Evaluation",
            url: "Evaluation/ChoicePeriod/{action}/{typeControl}",
            defaults: new { action = "Index", typeControl = UrlParameter.Optional }
        );

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Main", action = "Index", id = UrlParameter.Optional }
        );

Sitemap:

<mvcSiteMapNode title="Main" controller="Main" action="Index">
 <mvcSiteMapNode title="Evaluation" area="Evaluation" controller="ChoicePeriod" action="Index" >
  <mvcSiteMapNode title="Input" area="Evaluation" controller="ChoicePeriod" action="Index" preservedRouteParameters="typeControl" key="typeControl"/>
 </mvcSiteMapNode>
</mvcSiteMapNode>

I've added typeControl value to RouteValues and now i don't know how to show it in SiteMapPath

    public ActionResult Index(string typeControl, int? id_pred)
    {
        var node = MvcSiteMapProvider.SiteMaps.Current.FindSiteMapNodeFromKey("typeControl");
        if (node != null)
        {
            node.RouteValues["typeControl"] = typeControl;
        }
        ...

Is there any way to make my breadcrumbs look like i expected to? Thanks.

Body:
you should use URL in your mvc.sitemap:

<mvcSiteMapNode title="Main" controller="Main" action="Index">
 <mvcSiteMapNode title="Evaluation" area="Evaluation" controller="ChoicePeriod" action="Index" >
  <mvcSiteMapNode title="Input" area="Evaluation" controller="ChoicePeriod" action="Index" url="/Evaluation/ChoicePeriod/Input"/>
 </mvcSiteMapNode>
</mvcSiteMapNode>


问:
How to retain slf4j MDC logging context in CompletableFuture?
When executing async CompletableFuture, the parent threadcontext and moreover the org.slf4j.MDC context is lost.

This is bad as I'm using some kind of "fish tagging" to track logs from one request among multiple logfiles.

MDC.put("fishid", randomId())

Question: how can I retain that id during the tasks of CompletableFutures in general?

```<code>List<CompletableFuture<UpdateHotelAllotmentsRsp>> futures =
    tasks.stream()
        .map(task -> CompletableFuture.supplyAsync(
            () -> businesslogic(task))
        .collect(Collectors.toList());

List results = futures.stream()
    .map(CompletableFuture::join)
    .collect(Collectors.toList());

public void businesslogic(Task task) {
       LOGGER.info("mdc fishtag context is lost here");
}
</code>```

答:
The most readable way I solved this problem was as below -

---------------Thread utils class--------------------

```<code>public static Runnable withMdc(Runnable runnable) {
    Map<String, String> mdc = MDC.getCopyOfContextMap();
    return () -> {
        MDC.setContextMap(mdc);
        runnable.run();
    };
}

public static <U> Supplier<U> withMdc(Supplier<U> supplier) {
    Map<String, String> mdc = MDC.getCopyOfContextMap();
    return (Supplier) () -> {
        MDC.setContextMap(mdc);
        return supplier.get();
    };
}
</code>```

---------------Usage--------------

```<code>CompletableFuture.supplyAsync(withMdc(() -> someSupplier()))
                 .thenRunAsync(withMdc(() -> someRunnable())
                 ....
</code>```

WithMdc in ThreadUtils would have to be overloaded to include other functional interfaces which are accepted by CompletableFuture

Please note that the withMdc() method is statically imported to improve readability.

Body:
When executing async CompletableFuture, the parent threadcontext and moreover the org.slf4j.MDC context is lost.

This is bad as I'm using some kind of "fish tagging" to track logs from one request among multiple logfiles.

MDC.put("fishid", randomId())

Question: how can I retain that id during the tasks of CompletableFutures in general?

List<CompletableFuture<UpdateHotelAllotmentsRsp>> futures =
    tasks.stream()
        .map(task -> CompletableFuture.supplyAsync(
            () -> businesslogic(task))
        .collect(Collectors.toList());

List results = futures.stream()
    .map(CompletableFuture::join)
    .collect(Collectors.toList());

public void businesslogic(Task task) {
       LOGGER.info("mdc fishtag context is lost here");
}

Body:
The most readable way I solved this problem was as below -

---------------Thread utils class--------------------

public static Runnable withMdc(Runnable runnable) {
    Map<String, String> mdc = MDC.getCopyOfContextMap();
    return () -> {
        MDC.setContextMap(mdc);
        runnable.run();
    };
}

public static <U> Supplier<U> withMdc(Supplier<U> supplier) {
    Map<String, String> mdc = MDC.getCopyOfContextMap();
    return (Supplier) () -> {
        MDC.setContextMap(mdc);
        return supplier.get();
    };
}

---------------Usage--------------

CompletableFuture.supplyAsync(withMdc(() -> someSupplier()))
                 .thenRunAsync(withMdc(() -> someRunnable())
                 ....

WithMdc in ThreadUtils would have to be overloaded to include other functional interfaces which are accepted by CompletableFuture

Please note that the withMdc() method is statically imported to improve readability.


问:
How to use grep to extract ip adresses and date/time strings from log file?
I have a log file that looks like this:

```<code>May 25 05:34:16 server sshd[1203]: Received disconnect from 192.0.2.2 port 39102:11
May 25 05:34:16 server sshd[1203]: Disconnected from 192.0.2.1 port 39102
</code>```

Now i want to extract all of the ip addresses and the date/time strings at the beginning using grep. I already know how to get the ips:

```<code>grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' /log.txt
</code>```

and the dates/times:

```<code>grep -o '[A-Z][a-z][a-z] [0-3][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]' /log.txt
</code>```

but i don't know how to get both at the same time in a format like:

```<code>May 25 05:34:16 192.0.2.1
</code>```

I've read something like:

```<code> grep -oE 'match1|match2' /log.txt
</code>```

but that doesn't seem to work.

Body:
I have a log file that looks like this:

May 25 05:34:16 server sshd[1203]: Received disconnect from 192.0.2.2 port 39102:11
May 25 05:34:16 server sshd[1203]: Disconnected from 192.0.2.1 port 39102

Now i want to extract all of the ip addresses and the date/time strings at the beginning using grep. I already know how to get the ips:

grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' /log.txt

and the dates/times:

grep -o '[A-Z][a-z][a-z] [0-3][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]' /log.txt

but i don't know how to get both at the same time in a format like:

May 25 05:34:16 192.0.2.1

I've read something like:

 grep -oE 'match1|match2' /log.txt

but that doesn't seem to work.

Body:
With any awk in any shell on any UNIX box:

$ awk '{print $1, $2, $3, $(NF-2)}' file
May 25 05:34:16 192.0.2.2
May 25 05:34:16 192.0.2.1


问:
How the Apache Cassandra process is named on the Windows?
I am trying to run Apache Cassandra on the Windows 10, some installation tool place when I ran cassandra.bat for the first time but repeated call to it returns port used errors. So, I suspect that I have already started accidently Cassandra process. How this process is named - for I can check its status in Task Manager?</p>

答:
Since Apache Cassandra uses the java runtime, it should show up as Java(TM) Platform SE Binary, but the name may vary based on what java installation you are using.

I'll admit that's a bit vague.  I'd recommend using Process Explorer to get more details about running programs.

After installing that, locate processes named java.exe and hover over them to see the command line arguments.  The huge listing of configuration flags and jar files makes Cassandra a dead give away:


问:
What differences are between `format()` and `str()`?
```<code>>>> format(sys.stdout)
"<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>"
>>> str(sys.stdout)
"<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>"
</code>```

I am not very sure about the following quotes from Python library references. What differences are between format() and str(), or between object.__format__(self, format_spec) and object.__str__(self )? When shall we use which?

object.__str__(self )

Called by str(object) and the built-in functions format() and print()
  to compute the “informal” or nicely printable string representation of
  an object.

object.__format__(self, format_spec)

Called by the format() built-in function, and by extension, evaluation
  of formatted string literals and the str.format() method, to produce a
  “formatted” string representation of an object.

答:
I am gonna break down the main three (technically main 2 because __format__ is not commonly implemented). I'll go through all three then put it all together in one nice class.

The most common __str__:

This is how you want to represent this object as a str.
Often this is less detailed than __repr__ and is used
mainly for the end user. For example if we have a person class we may implement str this way:

```<code>class Person:
    def __init__(self, name):
        self.name = name
    def __str__(self):
        return f"Hello my name is {self.name}"

p = Person("John Smith")
print(str(p)) # Prints "Hello my name is John Smith"
</code>```

The less common __repr__:

To be honest I implement this more than str for most projects. This should return the representation of the object as a str in such a way that it is helpful to the developer instead of the end user and is called via repr(my_obj).  If a class does not implement a __str__ magic method then python will attempt to call its __repr__ method automatically when you use str(my_obj) (thus you can implement repr first and str later). Often the repr of a class returns the way to recreate that object. For example:

```<code>class Person:
    def __init__(self, name):
        self.name = name
    def __repr__(self):
        return f"Person(name='{self.name}')"

p = Person("John Smith")
print(repr(p)) # Prints "Person(name='John Smith')"
print(str(p))  # Prints "Person(name='John Smith')"
</code>```

The cursed child __format__: [I just call it that because it is so uncommonly used :)]

The main difference between __format__ and the other two methods is that it also accepts a format_spec that can be used to style the returned string.

To understand this in further detail I must first explain some formatting stuff. You may have seen some of this stuff before or you may not have.

Lets use a dummy class:

```<code>class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
    def __repr__(self):
        return f'Person(name="{self.name}", age={self.age})'
    def __str__(self):
        return str(self.name)

p = Person(name="John Smith", age=22)
# This prints the str of p
print("{!s}".format(p)) # John Smith
# This prints the representation of p
print("{!r}".format(p)) # Person(name="John Smith", age=22)
</code>```

Okay so you can format your class as its str or as its repr, but what if you want to format it your own way? Most people don't need to do this; but, this is the power of python, you can do anything. We can create different tags instead of r and s (though it uses : instead of !):

```<code>class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
    def __repr__(self):
        return f'Person(name="{self.name}", age={self.age})'
    def __str__(self):
        return str(self.name)
    def __format__(self, format_spec):
        if format_spec == 'age': # get a persons age
            return f"{self.name} is {self.age} years old"
        elif format_spec == 'birthday':
            return "Yesterday"
        return str(self) # A default case

p = Person(name="John Smith", age=22)
# This prints the str of p
print("{!s}".format(p))
# This with representation of p
print("{!r}".format(p))
print("{:age}".format(p))
print("{:birthday}".format(p))
print(f"{p:age} and his birthday was {p:birthday}")
</code>```

There is obviously more to this than my limited knowledge can go into but this should be a good general scope :).

There are some packages that use this such as datetime. If you are interested learning more about the power of format Pyformat walks through this pretty well: PyFormat.

Disclaimer:

I do not have much experience using __format__ so I can not provide a good use-case (though datetime's use-case isn't bad).  Everything here is just to show the broad difference between str, repr, and format magic methods.  If I got anything wrong (especially __format__'s use-case) please let me know and I will update it.

Body:
>>> format(sys.stdout)
"<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>"
>>> str(sys.stdout)
"<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>"

I am not very sure about the following quotes from Python library references. What differences are between format() and str(), or between object.__format__(self, format_spec) and object.__str__(self )? When shall we use which?

object.__str__(self )

Called by str(object) and the built-in functions format() and print()
  to compute the “informal” or nicely printable string representation of
  an object.

object.__format__(self, format_spec)

Called by the format() built-in function, and by extension, evaluation
  of formatted string literals and the str.format() method, to produce a
  “formatted” string representation of an object.

Body:
I am gonna break down the main three (technically main 2 because __format__ is not commonly implemented). I'll go through all three then put it all together in one nice class.

The most common __str__:

This is how you want to represent this object as a str.
Often this is less detailed than __repr__ and is used
mainly for the end user. For example if we have a person class we may implement str this way:

class Person:
    def __init__(self, name):
        self.name = name
    def __str__(self):
        return f"Hello my name is {self.name}"

p = Person("John Smith")
print(str(p)) # Prints "Hello my name is John Smith"

The less common __repr__:

To be honest I implement this more than str for most projects. This should return the representation of the object as a str in such a way that it is helpful to the developer instead of the end user and is called via repr(my_obj).  If a class does not implement a __str__ magic method then python will attempt to call its __repr__ method automatically when you use str(my_obj) (thus you can implement repr first and str later). Often the repr of a class returns the way to recreate that object. For example:

class Person:
    def __init__(self, name):
        self.name = name
    def __repr__(self):
        return f"Person(name='{self.name}')"

p = Person("John Smith")
print(repr(p)) # Prints "Person(name='John Smith')"
print(str(p))  # Prints "Person(name='John Smith')"

The cursed child __format__: [I just call it that because it is so uncommonly used :)]

The main difference between __format__ and the other two methods is that it also accepts a format_spec that can be used to style the returned string.

To understand this in further detail I must first explain some formatting stuff. You may have seen some of this stuff before or you may not have.

Lets use a dummy class:

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
    def __repr__(self):
        return f'Person(name="{self.name}", age={self.age})'
    def __str__(self):
        return str(self.name)

p = Person(name="John Smith", age=22)
# This prints the str of p
print("{!s}".format(p)) # John Smith
# This prints the representation of p
print("{!r}".format(p)) # Person(name="John Smith", age=22)

Okay so you can format your class as its str or as its repr, but what if you want to format it your own way? Most people don't need to do this; but, this is the power of python, you can do anything. We can create different tags instead of r and s (though it uses : instead of !):

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age
    def __repr__(self):
        return f'Person(name="{self.name}", age={self.age})'
    def __str__(self):
        return str(self.name)
    def __format__(self, format_spec):
        if format_spec == 'age': # get a persons age
            return f"{self.name} is {self.age} years old"
        elif format_spec == 'birthday':
            return "Yesterday"
        return str(self) # A default case

p = Person(name="John Smith", age=22)
# This prints the str of p
print("{!s}".format(p))
# This with representation of p
print("{!r}".format(p))
print("{:age}".format(p))
print("{:birthday}".format(p))
print(f"{p:age} and his birthday was {p:birthday}")

There is obviously more to this than my limited knowledge can go into but this should be a good general scope :).

There are some packages that use this such as datetime. If you are interested learning more about the power of format Pyformat walks through this pretty well: PyFormat.

Disclaimer:

I do not have much experience using __format__ so I can not provide a good use-case (though datetime's use-case isn't bad).  Everything here is just to show the broad difference between str, repr, and format magic methods.  If I got anything wrong (especially __format__'s use-case) please let me know and I will update it.


问:
How to get this output in local
hdfs dfs -ls -R hdfs:///data/msd > msd_filename.txt.

how to get the text file at local

hdfs dfs -ls -R hdfs:///data/msd > msd_filename.txt

答:
Assuming you mean you want to copy a file from hdfs to your local directory. This command should help you:</p>

```<code>hadoop fs -copyToLocal /hdfs/source/path /localfs/destination/path
</code>```

Title: How to get this output in local

Body:
Assuming you mean you want to copy a file from hdfs to your local directory. This command should help you:

hadoop fs -copyToLocal /hdfs/source/path /localfs/destination/path


问:
How to print symbol's table, symbol name
I want to print symbol's name in symbol table.
i'm mapping the the elf to the virtual memory (using mmap), I successfully an accessed  to the symbol table, but when trying to print symbol names it fails (an odd string is show, comparing it to the elf file results).

my code :

```<code>void printSymboles() {
Elf32_Sym* symtab;
Elf32_Shdr * sh_strtab_p ;
char *sh_strtab;
int symbol_num=-1;
  if(currentFd==-1){
    printf("not legal file set\n");
} else {

    sectionHeader=(Elf32_Shdr*)(map_start+header->e_shoff);
    int section_num=header->e_shnum;

    int numSectionsFound=0;
    for(int i=0;i<section_num &&numSectionsFound<2;i++){
        if(sectionHeader[i].sh_type==SHT_SYMTAB) {
            symtab=(Elf32_Sym *) (map_start+sectionHeader[i].sh_offset);
            symbol_num= sectionHeader[i].sh_size/sectionHeader[i].sh_entsize; // symobl tbl size/ entrysize
            numSectionsFound++;
        }
        if(sectionHeader[i].sh_type==SHT_STRTAB) {
            sh_strtab_p=&sectionHeader[i];
            sh_strtab=(char*) map_start+sh_strtab_p->sh_offset;
            numSectionsFound++;

        }
    }

    if(symbol_num==-1) {
        printf("symbol table doesn't exist");
    } else {
        printf("symbol table : \n");
        for(int i=0;i<symbol_num;i++) {
        printf("name : %s\n",sh_strtab+symtab[i].st_name);
        }
    }
</code>```

答:
The problem is almost certainly that you're looking in the wrong SHT_STRTAB section -- you scan through the header looking for SHT_STRTAB sections and whichever one you find last, you remember in sh_strtab_p.  If your ELF file is like most elf files, that's probably the section header string table (contains section header names) and not the string table with your symbol names.

To find the string table with your symbol names, you need to look in the sh_link field of the symbol table section header -- that tells you the section number (index in the section header) of the string table section containing the names of the symbols in that symbol section.  There can be arbitrarily many SYMTAB sections in the file, each with its own STRTAB section.

Putting all that together, you want something more like:

```<code>Elf32_Shdr *section = (Elf32_Shdr*)(map_start+header->e_shoff);
char *section_names = (char *)(map_start + section[header->e_shstrndx].sh_offset);

for(int i=0; i<header->e_shnum; i++) {
    if(section[i].sh_type==SHT_SYMTAB) {
        printf("Symobl table %s:\n",  section_names + section[i].sh_name);
        Elf32_Sym *symtab = (Elf32_Sym *)(map_start+section[i].sh_offset);
        int symbol_num = section[i].sh_size/section[i].sh_entsize;
        char *symbol_names = (char *)(map_start + section[section[i].sh_link].sh_offset);
        for (int j=0; j<symbol_num; j++) {
            printf("name : %s\n", symbol_names + symtab[j].st_name);
        }
    }
}
</code>```

Of course, it would also be good to do sanity checking to make sure that none of the indexes are out of range for the section they are indexing into, and that sh_entsize and and e_shentsize match the sizeof the structs you are using, just in case the ELF file has been corrupted.

Body:
I want to print symbol's name in symbol table.
i'm mapping the the elf to the virtual memory (using mmap), I successfully an accessed  to the symbol table, but when trying to print symbol names it fails (an odd string is show, comparing it to the elf file results).

my code :

void printSymboles() {
Elf32_Sym* symtab;
Elf32_Shdr * sh_strtab_p ;
char *sh_strtab;
int symbol_num=-1;
  if(currentFd==-1){
    printf("not legal file set\n");
} else {

    sectionHeader=(Elf32_Shdr*)(map_start+header->e_shoff);
    int section_num=header->e_shnum;

    int numSectionsFound=0;
    for(int i=0;i<section_num &&numSectionsFound<2;i++){
        if(sectionHeader[i].sh_type==SHT_SYMTAB) {
            symtab=(Elf32_Sym *) (map_start+sectionHeader[i].sh_offset);
            symbol_num= sectionHeader[i].sh_size/sectionHeader[i].sh_entsize; // symobl tbl size/ entrysize
            numSectionsFound++;
        }
        if(sectionHeader[i].sh_type==SHT_STRTAB) {
            sh_strtab_p=&sectionHeader[i];
            sh_strtab=(char*) map_start+sh_strtab_p->sh_offset;
            numSectionsFound++;

        }
    }

    if(symbol_num==-1) {
        printf("symbol table doesn't exist");
    } else {
        printf("symbol table : \n");
        for(int i=0;i<symbol_num;i++) {
        printf("name : %s\n",sh_strtab+symtab[i].st_name);
        }
    }

Body:
The problem is almost certainly that you're looking in the wrong SHT_STRTAB section -- you scan through the header looking for SHT_STRTAB sections and whichever one you find last, you remember in sh_strtab_p.  If your ELF file is like most elf files, that's probably the section header string table (contains section header names) and not the string table with your symbol names.

To find the string table with your symbol names, you need to look in the sh_link field of the symbol table section header -- that tells you the section number (index in the section header) of the string table section containing the names of the symbols in that symbol section.  There can be arbitrarily many SYMTAB sections in the file, each with its own STRTAB section.

Putting all that together, you want something more like:

Elf32_Shdr *section = (Elf32_Shdr*)(map_start+header->e_shoff);
char *section_names = (char *)(map_start + section[header->e_shstrndx].sh_offset);

for(int i=0; i<header->e_shnum; i++) {
    if(section[i].sh_type==SHT_SYMTAB) {
        printf("Symobl table %s:\n",  section_names + section[i].sh_name);
        Elf32_Sym *symtab = (Elf32_Sym *)(map_start+section[i].sh_offset);
        int symbol_num = section[i].sh_size/section[i].sh_entsize;
        char *symbol_names = (char *)(map_start + section[section[i].sh_link].sh_offset);
        for (int j=0; j<symbol_num; j++) {
            printf("name : %s\n", symbol_names + symtab[j].st_name);
        }
    }
}

Of course, it would also be good to do sanity checking to make sure that none of the indexes are out of range for the section they are indexing into, and that sh_entsize and and e_shentsize match the sizeof the structs you are using, just in case the ELF file has been corrupted.


问:
CSS and JS not loading in laravel
My css and js files are not loading when i launch my project i already included the link of my files in the stylesheet of my code where it is located. I already trided several methods but it is not working

The components is directly in my public folders directory

public folder contains:

bower_components

build

css

dist

documentation

pages

plugins

my head.blade.php

```<code><head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>BET ADMIN | Dashboard</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/Ionicons/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/dist/css/skins/_all-skins.min.css'">
    <!-- Morris chart -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/morris .js/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/jvectormap/jquery-jvectormap.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/bootstrap-daterangepicker/daterangepicker.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="{{URL::to('/')}}/public/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  </head>

</code>```

my footer-scripts.blade.php

```<code><!-- jQuery 3 -->
<script src="{{URL::to('/')}}/public/bower_components/jquery/dist/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="{{URL::to('/')}}/public/bower_components/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
  $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.7 -->
<script src="{{URL::to('/')}}/public/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Morris.js charts -->
<script src="{{URL::to('/')}}/public/bower_components/raphael/raphael.min.js"></script>
<script src="{{URL::to('/')}}/public/bower_components/morris.js/morris.min.js"></script>
<!-- Sparkline -->
<script src="{{URL::to('/')}}/public/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<!-- jvectormap -->
<script src="{{URL::to('/')}}/public/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="{{URL::to('/')}}/public/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- jQuery Knob Chart -->
<script src="{{URL::to('/')}}/public/bower_components/jquery-knob/dist/jquery.knob.min.js"></script>
<!-- daterangepicker -->
<script src="{{URL::to('/')}}/public/bower_components/moment/min/moment.min.js"></script>
<script src="{{URL::to('/')}}/public/bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="{{URL::to('/')}}/public/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="{{URL::to('/')}}/public/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<script src="{{URL::to('/')}}/public/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="{{URL::to('/')}}/public/bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="{{URL::to('/')}}/public/dist/js/adminlte.min.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="{{URL::to('/')}}/public/dist/js/pages/dashboard.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="{{URL::to('/')}}/public/dist/js/demo.js"></script>

</code>```

demo.blade.php

```<code>
@extends('layouts.mainlayout')

@section('content')

<div>
    HELLO
</div>

@endsection

</code>```

web.php /routes

```<code><?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/demo', function () {
    return view('demo');
});

Auth::routes();

//Route::get('/demo', 'HomeController@index')->name('demo');

Route::get('demo', 'HomeController@index');

</code>```

HomeController.php

```<code><?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        return view('demo');
    }
}

</code>```

答:
If your project working fine but css and js not working follow this steps

1.Open your file in chrome and press ctrl + u then open any link if link open then css working fine error something else

use this {{ asset('css/min.css') }} or  Laravel’s URL::to() vs URL::asset()

Title: CSS and JS not loading in laravel

Body:
My css and js files are not loading when i launch my project i already included the link of my files in the stylesheet of my code where it is located. I already trided several methods but it is not working

The components is directly in my public folders directory

public folder contains:

bower_components

build

css

dist

documentation

pages

plugins

my head.blade.php

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>BET ADMIN | Dashboard</title>

    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/bootstrap/dist/css/bootstrap.min.css">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/font-awesome/css/font-awesome.min.css">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/Ionicons/css/ionicons.min.css">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/dist/css/AdminLTE.min.css">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/dist/css/skins/_all-skins.min.css'">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/morris .js/morris.css">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/jvectormap/jquery-jvectormap.css">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/bower_components/bootstrap-daterangepicker/daterangepicker.css">

    <link rel="stylesheet" href="{{URL::to('/')}}/public/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">

    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

my footer-scripts.blade.php

demo.blade.php

@extends('layouts.mainlayout')

@section('content')

    HELLO

@endsection

web.php /routes

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/demo', function () {
    return view('demo');
});

Auth::routes();

//Route::get('/demo', 'HomeController@index')->name('demo');

Route::get('demo', 'HomeController@index');

HomeController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        return view('demo');
    }
}

Body:
If your project working fine but css and js not working follow this steps

1.Open your file in chrome and press ctrl + u then open any link if link open then css working fine error something else

use this {{ asset('css/min.css') }} or <script src="{{ URL::asset('js/bootstrap.js') }}"></script> Laravel’s URL::to() vs URL::asset()


问:
Selecting Related Entities When No Association Exists
EF4 is great for pulling in associated data but what do you do when the association is not explicit? An example illustrates my situation:

MasterTable has a child1Id and child2Id column.

There are two tables Child1 and Child2 with corresponding primary key child1Id and child2Id. There are Master, Child1 and Child2 entities.

There is no foreign key or entity framework association between Master and Child1 / Child2 tables or entities.

How can I select the master records and corresponding child records from the two child tables when all I have are the matching child Ids in the master?

I can't retrofit a relationship or association.

Richard

答:
You must select them manually by linq to entities. Here is how to do left join between two tables:

```<code>var query = from m in context.Masters
            where m.Id == 1
            join c in context.Childs on m.Child.Id equals c.Id into leftJoin
            from x in leftJoin.DefaultIfEmpty()
            select new
                {
                    Id = x.Id,
                    Name = x.Name,
                    Child = x.Childs
                };
</code>```

Btw. if your entities have a property which contains a value of PK from other entity you can create relation in EF designer. In such case you will be able to use navigation properties.

Body:
You must select them manually by linq to entities. Here is how to do left join between two tables:

var query = from m in context.Masters
            where m.Id == 1
            join c in context.Childs on m.Child.Id equals c.Id into leftJoin
            from x in leftJoin.DefaultIfEmpty()
            select new
                {
                    Id = x.Id,
                    Name = x.Name,
                    Child = x.Childs
                };

Btw. if your entities have a property which contains a value of PK from other entity you can create relation in EF designer. In such case you will be able to use navigation properties.