问:
User acess rights using MemberOfGroups in hybris
I have custome item type "Appeasement" , which contains attribute "appeasementStatus" of enum type "AppeasementStatusType" .

For customersupportagentgroup we dont have write access to item type "Appeasement" but I want to provide write access to attribute "appeasementStatus". I create below impex but this is not working as excepted.
Is any think missing?

```<code>enter code here
$START_USERRIGHTS;;;;;;;;;
Type;UID;MemberOfGroups;Password;Target;read;change;create;remove;change_perm
UserGroup;customersupportagentgroup;;;;;;;;
;;;;Appeasement;+;-;-;-;-
;;;;AppeasementStatusType;+;+;+;+;-
;;;;Appeasement.appeasementStatus;+;+;-;-;-
$END_USERRIGHTS;;;;;;;;;
</code>```

答:
What you are trying to do is not possible this way. Check the following section from https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/1905/en-US/8b4aa00e866910148df2920f69d68b27.html

Attribute Permissions

Using attribute permissions allows you to
  explicitly assign permission to selected attributes of a certain type.
  Attribute-related permissions don't override type-related permissions.
  For example, if the type permission for a type is set to deny:
  <Change>, you cannot grant permission: <Change> to any of the
  attributes of that type. You can, however, set the type permission for
  that type to permission: <Change>, and then decide which of the
  attribute-related permissions you want to set to permission: <Change>,
  and which to deny: <Change>.

As a summary, the type-level permissions can not be overridden to make less strict at attribute-level.

The workaround is the other way round i.e.

Grant <write> access to customersupportagentgroup for the  itemtype, Appeasement.

Deny <write> access to customersupportagentgroup for all the attributes, except appeasementStatus.

Body:
I have custome item type "Appeasement" , which contains attribute "appeasementStatus" of enum type "AppeasementStatusType" .

For customersupportagentgroup we dont have write access to item type "Appeasement" but I want to provide write access to attribute "appeasementStatus". I create below impex but this is not working as excepted.
Is any think missing?

enter code here
$START_USERRIGHTS;;;;;;;;;
Type;UID;MemberOfGroups;Password;Target;read;change;create;remove;change_perm
UserGroup;customersupportagentgroup;;;;;;;;
;;;;Appeasement;+;-;-;-;-
;;;;AppeasementStatusType;+;+;+;+;-
;;;;Appeasement.appeasementStatus;+;+;-;-;-
$END_USERRIGHTS;;;;;;;;;


来源: stackexchange

问:
How to resolve 'mdb-accordion' is not a known element: error in Angular app?
I am trying to add the Material Design Bootstrap Accordion to my angular app using this example.

Here is my HTML:

```<code><mdb-accordion [multiple]="false">
    <mdb-accordion-item [collapsed]="false">
      <mdb-accordion-item-head>Collapsible Group Item #1</mdb-accordion-item-head>
      <mdb-accordion-item-body>
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute,
        aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft
      </mdb-accordion-item-body>
</mdb-accordion-item>
</mdb-accordion>
</code>```

Here is the error message I am getting:

'mdb-accordion' is not a known element:

If 'mdb-accordion' is an Angular component, then verify that it is part of this module.

If 'mdb-accordion' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.ng(0)

Here is what I have in my Angular.json:

```<code>"styles": [
          "node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss",
          "node_modules/@fortawesome/fontawesome-free/scss/solid.scss",
          "node_modules/@fortawesome/fontawesome-free/scss/regular.scss",
          "node_modules/@fortawesome/fontawesome-free/scss/brands.scss",
          "node_modules/angular-bootstrap-md/assets/scss/bootstrap/bootstrap.scss",
          "node_modules/angular-bootstrap-md/assets/scss/mdb.scss",
          "./node_modules/quill/dist/quill.core.css",
          "./node_modules/quill/dist/quill.snow.css",
          "node_modules/animate.css/animate.css",
          "src/styles.css"
        ],
"scripts": [
          "node_modules/chart.js/dist/Chart.js",
          "node_modules/hammerjs/hammer.min.js",
          "./node_modules/quill/dist/quill.js"
         ]
</code>```

And I have the following in my App Module:

```<code>import { MDBBootstrapModule } from 'angular-bootstrap-md';

@NgModule({
imports: [
    MDBBootstrapModule.forRoot(),
],
})
export class AppModule { }
</code>```

I tried adding something like MDBootstrapAccordion to the import in App Module, but nothing was appearing.

Can someone please tell me what I'm missing to get the accordion displaying?

答:
You use MDB Free and mdb-accordion is not available in this version. You would need to purchase PRO version in order to use it in your project.

As you can see, there is a 'MDB Pro component' label in the documentation:

https://mdbootstrap.com/docs/angular/advanced/accordion/

ContentLicense: CC BY-SA 4.0

Body:
I am trying to add the Material Design Bootstrap Accordion to my angular app using this example.

Here is my HTML:

<mdb-accordion [multiple]="false">
    <mdb-accordion-item [collapsed]="false">
      <mdb-accordion-item-head>Collapsible Group Item #1</mdb-accordion-item-head>
      <mdb-accordion-item-body>
        Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute,
        aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft
      </mdb-accordion-item-body>
</mdb-accordion-item>
</mdb-accordion>

Here is the error message I am getting:

'mdb-accordion' is not a known element:

If 'mdb-accordion' is an Angular component, then verify that it is part of this module.

If 'mdb-accordion' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.ng(0)

Here is what I have in my Angular.json:

"styles": [
          "node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss",
          "node_modules/@fortawesome/fontawesome-free/scss/solid.scss",
          "node_modules/@fortawesome/fontawesome-free/scss/regular.scss",
          "node_modules/@fortawesome/fontawesome-free/scss/brands.scss",
          "node_modules/angular-bootstrap-md/assets/scss/bootstrap/bootstrap.scss",
          "node_modules/angular-bootstrap-md/assets/scss/mdb.scss",
          "./node_modules/quill/dist/quill.core.css",
          "./node_modules/quill/dist/quill.snow.css",
          "node_modules/animate.css/animate.css",
          "src/styles.css"
        ],
"scripts": [
          "node_modules/chart.js/dist/Chart.js",
          "node_modules/hammerjs/hammer.min.js",
          "./node_modules/quill/dist/quill.js"
         ]

And I have the following in my App Module:

import { MDBBootstrapModule } from 'angular-bootstrap-md';

@NgModule({
imports: [
    MDBBootstrapModule.forRoot(),
],
})
export class AppModule { }

I tried adding something like MDBootstrapAccordion to the import in App Module, but nothing was appearing.

Can someone please tell me what I'm missing to get the accordion displaying?


问:
Typescript : reuse both of for .. of and for .. in at same level
I want to reuse "for .. of " to loop over an array of objects ,
at same time i want to get the index inn each time (with : for.. in).

so that i can change a specifc object with another accortding to its index.

My purpose is to loop over a list , find a specifc object by its name attribute , and change it with another object.

```<code>updateObjectInList(list, newObject) {

    for(let item of list , let index in list ){
      if (item.name=== newObject.name){
        list[index] = newObject
      }
    }

}
</code>```

Of course this stament " let item of list , let index in list  " is not working

Suggestions ?

答:
You could take an iterator of the entries of the array and get index and value at the same time.

var array = [33, 22, 11];

for (const [index, value] of array.entries()) {
    console.log(index, value);
}```

Body:
I want to reuse "for .. of " to loop over an array of objects ,
at same time i want to get the index inn each time (with : for.. in).

so that i can change a specifc object with another accortding to its index.

My purpose is to loop over a list , find a specifc object by its name attribute , and change it with another object.

updateObjectInList(list, newObject) {

    for(let item of list , let index in list ){
      if (item.name=== newObject.name){
        list[index] = newObject
      }
    }

}

Of course this stament " let item of list , let index in list  " is not working

Suggestions ?


问:
How to pull the key and value of an item with the maximum value out of a python dictionary
The following code creates a dictionary of email addresses and how frequently each email appears.  What is the best way to pull out the key and value for the email with the max frequency?</p>

```<code>fname = input("Enter file:")
try:
    fhand = open(fname)
except:
    print('File cannot be opened:')
    exit()
counts = dict()
for line in fhand:
    if line.startswith('From:'):
         words = line.split(' ', 1)[1]
         words = words.rstrip('\n')

         counts[words] = counts.get(words,0)+1

print(counts)
</code>```

答:
you can get both the key and value using

```<code>sorted(counts.items(), key=lambda x: x[1])[-1]
</code>```

or

```<code>sorted(counts.items(), key=lambda x: x[1], reverse=True)[0]
</code>```

Body:
The following code creates a dictionary of email addresses and how frequently each email appears.  What is the best way to pull out the key and value for the email with the max frequency?

fname = input("Enter file:")
try:
    fhand = open(fname)
except:
    print('File cannot be opened:')
    exit()
counts = dict()
for line in fhand:
    if line.startswith('From:'):
         words = line.split(' ', 1)[1]
         words = words.rstrip('\n')

         counts[words] = counts.get(words,0)+1

print(counts)

Body:
you can get both the key and value using

sorted(counts.items(), key=lambda x: x[1])[-1]

or

sorted(counts.items(), key=lambda x: x[1], reverse=True)[0]


问:
Auto detecting serial COM port from VendorID, ProductID in Java
I have a program in java 11, control some hardware through USB using serial COM port.
I want to auto-detect hardware by VenderID and ProductID whenever I plug in a device.

I can get VendorID and ProductID through Linux command:

udevadm info -a -n /dev/ttyACM0

```<code>  looking at parent device '/devices/pci0000:00/0000:00:01.1/0000:01:00.0/usb1/1-5':
    KERNELS=="1-5"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{speed}=="12"
    ATTRS{avoid_reset_quirk}=="0"
    ...
    ...
    ATTRS{idVendor}=="0c2e"
    ATTRS{idProduct}=="0bea"
    ...
</code>```

Is it any way to get a COM port /dev/ttyACM0 from VendorID and ProductID with Java 11 in Linux and Windows?
Many Thanks.

答:
The USB abstraction library libusbp comes with an example program named lsport that lists all USB device and the serial ports they have.  You could compile that program and run it from your Java program, or just study how it works and reimplement the same thing in Java.

For Linux, another idea is to look at the symbolic links in /dev/serial/by-id.

Body:
I have a program in java 11, control some hardware through USB using serial COM port.
I want to auto-detect hardware by VenderID and ProductID whenever I plug in a device.

I can get VendorID and ProductID through Linux command:

udevadm info -a -n /dev/ttyACM0

  looking at parent device '/devices/pci0000:00/0000:00:01.1/0000:01:00.0/usb1/1-5':
    KERNELS=="1-5"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{speed}=="12"
    ATTRS{avoid_reset_quirk}=="0"
    ...
    ...
    ATTRS{idVendor}=="0c2e"
    ATTRS{idProduct}=="0bea"
    ...

Is it any way to get a COM port /dev/ttyACM0 from VendorID and ProductID with Java 11 in Linux and Windows?
Many Thanks.


问:
Is there a keyboard shortcut to maximize the Game window in Unity in Play Mode?
Ctrl + Space maximizes most windows in unity 2018 when in edit mode. Is there a keyboard shortcut to maximize the Game window when you're playing your game?

Can't find anything in the docs.

答:
You can implement it yourself.</p>

```<code>    void Update()
    {
#if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            UnityEditor.EditorWindow.focusedWindow.maximized = !UnityEditor.EditorWindow.focusedWindow.maximized;
        }
#endif
    }
</code>```

Body:
You can implement it yourself.

    void Update()
    {
#if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            UnityEditor.EditorWindow.focusedWindow.maximized = !UnityEditor.EditorWindow.focusedWindow.maximized;
        }
#endif
    }


问:
Can't access Ionic from browser while using docker
i'm trying to access localhost:8100 which is my ionic app that's running inside a docker container but it won't open.
Here is my dockerfile :

```<code>FROM node:10.16.3

WORKDIR /usr/src/ionic-app

COPY ./ /usr/src/ionic-app

RUN npm install -g cordova ionic
RUN npm install
</code>```

And here is my Docker-compose file
version: '3.6'

services:

```<code>  #Backend API
  backend-api:
    container_name: backend
    build:
      context: ./api/
    working_dir: /usr/src/smart-brain-api
    command: npm run debug
    ports:
      - "3000:3000"
    environment:
      REDIS_HOST: redis
      MONGOOSE_URI: 'mongodb://mongo:27017/appcomdill'
    links:
      - mongo
      - redis

  #MongoDB
  mongo:
    container_name: mongo
    image: mongo
    environment:
      MONGOOSE_URI: 'mongodb://mongo:27017/appcomdill'
    ports:
      - "27017:27017"

  #Redis
  redis:
    container_name: redis
    environment:
      REDIS_HOST: redis
    image: redis
    ports:
      - "6379:6379"

  #Ionic Front-end
  ionic:
    container_name: front-end
    build:
      context: ./ionic
    working_dir: /usr/src/ionic-app
    command: ionic serve
    ports:
      - "8100:8100"
</code>```

Every time i try to connect to http://localhost:8100/ it keeps on giving me "localhost didn't send any data"

答: Try changing your command to ionic serve --external

Body:
i'm trying to access localhost:8100 which is my ionic app that's running inside a docker container but it won't open.
Here is my dockerfile :

FROM node:10.16.3

WORKDIR /usr/src/ionic-app

COPY ./ /usr/src/ionic-app

RUN npm install -g cordova ionic
RUN npm install

And here is my Docker-compose file
version: '3.6'

services:

  #Backend API
  backend-api:
    container_name: backend
    build:
      context: ./api/
    working_dir: /usr/src/smart-brain-api
    command: npm run debug
    ports:
      - "3000:3000"
    environment:
      REDIS_HOST: redis
      MONGOOSE_URI: 'mongodb://mongo:27017/appcomdill'
    links:
      - mongo
      - redis

  #MongoDB
  mongo:
    container_name: mongo
    image: mongo
    environment:
      MONGOOSE_URI: 'mongodb://mongo:27017/appcomdill'
    ports:
      - "27017:27017"

  #Redis
  redis:
    container_name: redis
    environment:
      REDIS_HOST: redis
    image: redis
    ports:
      - "6379:6379"

  #Ionic Front-end
  ionic:
    container_name: front-end
    build:
      context: ./ionic
    working_dir: /usr/src/ionic-app
    command: ionic serve
    ports:
      - "8100:8100"

Every time i try to connect to http://localhost:8100/ it keeps on giving me "localhost didn't send any data"


问:
Error while Indtalling EFCodeFirst
I am developing ASP.NET MVC 3 music store site from the tutorial, Page 45.

When I am trying to install the EFCodeFirst I am getting the below error
Please help

答: You don't need to install EFCodeFirst when you have installed EntityFramework. Entity Framework is the latest version, EFCodeFirst was used during the beta.</p>

ContentLicense: CC BY-SA 3.0

Title: Error while Indtalling EFCodeFirst


问:
Cache in GrapghQl Flutter package settings and how to check it works
I'm trying to implement graphQl Flutter package in my app.

https://github.com/zino-app/graphql-flutter

Everything works well, but I have some issues with cache.

If we ran example from this package https://github.com/zino-app/graphql-flutter/tree/master/packages/graphql_flutter/example we can see that cache doesn't work.

In my app I also can't increase speed, it always get data online.

The code from this example

```<code>class GraphQLWidgetScreen extends StatelessWidget {
  const GraphQLWidgetScreen() : super();

  @override
  Widget build(BuildContext context) {
    final HttpLink httpLink = HttpLink(
      uri: 'https://api.github.com/graphql',
    );

    final AuthLink authLink = AuthLink(
      // ignore: undefined_identifier
      getToken: () async => 'Bearer $YOUR_TOKEN',
    );

    Link link = authLink.concat(httpLink);
    if (ENABLE_WEBSOCKETS) {
      final WebSocketLink websocketLink = WebSocketLink(
        url: 'ws://localhost:8080/ws/graphql',
        config: SocketClientConfig(
            autoReconnect: true, inactivityTimeout: Duration(seconds: 15)),
      );

      link = link.concat(websocketLink);
    }

    final ValueNotifier<GraphQLClient> client = ValueNotifier<GraphQLClient>(
      GraphQLClient(
        cache: OptimisticCache(
          dataIdFromObject: typenameDataIdFromObject,
        ),
        link: link,
      ),
    );

    return GraphQLProvider(
      client: client,
      child: const CacheProvider(
        child: MyHomePage(title: 'GraphQL Widget'),
      ),
    );
  }
}
</code>```

Animation that shows that cache doesn't work

So, the question is - what is the right way to implement cache and how check it works.

Thank you!

答: The examples are meant to be standalone - as such they use separate clients and caches. The consequence of this is that it is re-instantiated every mount. In other words, every time you navigates to the example's route, you get a new cache, so you can't see the caching effects. For a more substantial example where you can see if the cache is working, see the starwars example (related github discussion)</p>

Body:
I'm trying to implement graphQl Flutter package in my app.

https://github.com/zino-app/graphql-flutter

Everything works well, but I have some issues with cache.

If we ran example from this package https://github.com/zino-app/graphql-flutter/tree/master/packages/graphql_flutter/example we can see that cache doesn't work.

In my app I also can't increase speed, it always get data online.

The code from this example

class GraphQLWidgetScreen extends StatelessWidget {
  const GraphQLWidgetScreen() : super();

  @override
  Widget build(BuildContext context) {
    final HttpLink httpLink = HttpLink(
      uri: 'https://api.github.com/graphql',
    );

    final AuthLink authLink = AuthLink(
      // ignore: undefined_identifier
      getToken: () async => 'Bearer $YOUR_TOKEN',
    );

    Link link = authLink.concat(httpLink);
    if (ENABLE_WEBSOCKETS) {
      final WebSocketLink websocketLink = WebSocketLink(
        url: 'ws://localhost:8080/ws/graphql',
        config: SocketClientConfig(
            autoReconnect: true, inactivityTimeout: Duration(seconds: 15)),
      );

      link = link.concat(websocketLink);
    }

    final ValueNotifier<GraphQLClient> client = ValueNotifier<GraphQLClient>(
      GraphQLClient(
        cache: OptimisticCache(
          dataIdFromObject: typenameDataIdFromObject,
        ),
        link: link,
      ),
    );

    return GraphQLProvider(
      client: client,
      child: const CacheProvider(
        child: MyHomePage(title: 'GraphQL Widget'),
      ),
    );
  }
}

Animation that shows that cache doesn't work

So, the question is - what is the right way to implement cache and how check it works.

Thank you!


问:
Set <Avatar> backgroundColor randomly
I have defined three backgroundColor in the style theme.

```<code>avatar: {
    backgroundColor: red[500],
},
orangeAvatar: {
    margin: 10,
    color: '#fff',
    backgroundColor: deepOrange[500],
},
purpleAvatar: {
    margin: 10,
    color: '#fff',
    backgroundColor: deepPurple[500],
},
</code>```

When ever the Avatar is loaded I would like to select one of them randomly.

```<code><Card>
            <CardHeader
                avatar={
                    <Avatar id="av" aria-label="Recipe"
                        className={classes.avatar}>{this.props.userName.charAt(0).toLocaleUpperCase()}
                    </Avatar>}
                title={this.props.userName} disableTypography={true}/>
            <CardActionArea disabled={this.state.images.length == 1 ? true : false}>
                <CardMedia
                    id={this.props.ownerId}
                    className={classes.media}
                    image={this.state.images[this.state.imageIndex]}
                    onClick={this.handleOnClick}
                />
            </CardActionArea>
        </Card>
</code>```

Any advice how to do this?

Thank you

答:
I was presented with the same need, perhaps this solution will also serve you, there is a function to generate the color at random and then call the function from the online style.

```<code>const useStyles = makeStyles((theme: Theme) =>
  createStyles({
    large: {
      fontSize: "2.5rem",
      width: 100,
      height: 100
    }
  })
);

function randomColor() {
  let hex = Math.floor(Math.random() * 0xFFFFFF);
  let color = "#" + hex.toString(16);

  return color;
}
</code>```

...

```<code>  return (
    <Avatar
      variant="square"
      src={imageSrc}
      alt={alt}
      className={classes.large}
      style={{
        backgroundColor: randomColor()
      }}
    />
  )
</code>```

ref:

Javascript random color

Avatar random backgroundColor on fallback

Title: Set <Avatar> backgroundColor randomly

Body:
I have defined three backgroundColor in the style theme.

avatar: {
    backgroundColor: red[500],
},
orangeAvatar: {
    margin: 10,
    color: '#fff',
    backgroundColor: deepOrange[500],
},
purpleAvatar: {
    margin: 10,
    color: '#fff',
    backgroundColor: deepPurple[500],
},

When ever the Avatar is loaded I would like to select one of them randomly.

<Card>
            <CardHeader
                avatar={
                    <Avatar id="av" aria-label="Recipe"
                        className={classes.avatar}>{this.props.userName.charAt(0).toLocaleUpperCase()}
                    </Avatar>}
                title={this.props.userName} disableTypography={true}/>
            <CardActionArea disabled={this.state.images.length == 1 ? true : false}>
                <CardMedia
                    id={this.props.ownerId}
                    className={classes.media}
                    image={this.state.images[this.state.imageIndex]}
                    onClick={this.handleOnClick}
                />
            </CardActionArea>
        </Card>

Any advice how to do this?

Thank you

Body:
I was presented with the same need, perhaps this solution will also serve you, there is a function to generate the color at random and then call the function from the online style.

const useStyles = makeStyles((theme: Theme) =>
  createStyles({
    large: {
      fontSize: "2.5rem",
      width: 100,
      height: 100
    }
  })
);

function randomColor() {
  let hex = Math.floor(Math.random() * 0xFFFFFF);
  let color = "#" + hex.toString(16);

  return color;
}

...

  return (
    <Avatar
      variant="square"
      src={imageSrc}
      alt={alt}
      className={classes.large}
      style={{
        backgroundColor: randomColor()
      }}
    />
  )

ref:

Javascript random color

Avatar random backgroundColor on fallback


问:
CustomErrors does not work when setting redirectMode="ResponseRewrite"
In a old site, I was changing the way that CustomErrors works by adding redirectMode="ResponseRewrite" (new in 3.5 SP1):

```<code><customErrors mode="RemoteOnly" defaultRedirect="Error.aspx" redirectMode="ResponseRewrite">
    <error statusCode="404" redirect="404.aspx" />
</customErrors>
</code>```

The thing is: it shows me the generic error page (the one that you get when you don't set customErrors.  If I remove theredirectMode="ResponseRewrite" part, it works fine.

I'm sure 3.5 SP1 is installed in the server, because I use the same setting on other sites hosted in the same server.

Any ideas?

答:
According to @Amila's post and confirmation and completion of that post, I have same problem, I dig a lot google but had no chance to find the correct answer. The problem is when you are working with ASP.Net Web Application, whether it's an MVC or not you can't achieve custom error using the old way with Webform project.

Here the Option if you are using ASP.Net Web Application (whether it's an MVC or not):

In my scenarios I just want to define a custom error for a specific 404 error, The other error defined same as 404 error:

Senario1: Your custom page is a simple HTML file and placed in the root:

```<code><configuration>
   <system.web>
      <customErrors mode="Off" />
   </system.web>
   <system.webServer>
       <httpErrors errorMode="Custom" existingResponse="Replace">
           <remove statusCode="404" subStatusCode="-1" />
           <error statusCode="404" path="ErrorPage.html" responseMode="File" />
       </httpErrors>
   </system.webServer>
</configuration>
</code>```

Senario2: Your custom page is an aspx page and placed in the root:

```<code><configuration>
   <system.web>
      <customErrors mode="Off" />
   </system.web>
   <system.webServer>
       <httpErrors errorMode="Custom" existingResponse="Replace">
           <remove statusCode="404" subStatusCode="-1" />
           <error statusCode="404" path="ErrorPage" responseMode="Redirect" />
       </httpErrors>
   </system.webServer>
</configuration>
</code>```

Note: I remove the aspx extension due to RouteConfig.cs in ASP.net application, you can use ErrorPage.aspx if you like, it's optional.

Senario3: Your custom page is an aspx page and placed in the [ex: Page folder in The root (~/Page/ErrorPage.aspx)]:

The tip here that I noticed is YOU SHOULD NOT USE~/ to the root addressing; So I just addresing without ~/ mark:

```<code><configuration>
   <system.web>
      <customErrors mode="Off" />
   </system.web>
   <system.webServer>
       <httpErrors errorMode="Custom" existingResponse="Replace">
           <remove statusCode="404" subStatusCode="-1" />
           <error statusCode="404" path="Page/ErrorPage" responseMode="Redirect" />
       </httpErrors>
   </system.webServer>
</configuration>
</code>```

Body:
In a old site, I was changing the way that CustomErrors works by adding redirectMode="ResponseRewrite" (new in 3.5 SP1):

<customErrors mode="RemoteOnly" defaultRedirect="Error.aspx" redirectMode="ResponseRewrite">
    <error statusCode="404" redirect="404.aspx" />
</customErrors>

The thing is: it shows me the generic error page (the one that you get when you don't set customErrors.  If I remove theredirectMode="ResponseRewrite" part, it works fine.

I'm sure 3.5 SP1 is installed in the server, because I use the same setting on other sites hosted in the same server.

Any ideas?

Body:
According to @Amila's post and confirmation and completion of that post, I have same problem, I dig a lot google but had no chance to find the correct answer. The problem is when you are working with ASP.Net Web Application, whether it's an MVC or not you can't achieve custom error using the old way with Webform project.

Here the Option if you are using ASP.Net Web Application (whether it's an MVC or not):

In my scenarios I just want to define a custom error for a specific 404 error, The other error defined same as 404 error:

Senario1: Your custom page is a simple HTML file and placed in the root:

<configuration>
   <system.web>
      <customErrors mode="Off" />
   </system.web>
   <system.webServer>
       <httpErrors errorMode="Custom" existingResponse="Replace">
           <remove statusCode="404" subStatusCode="-1" />
           <error statusCode="404" path="ErrorPage.html" responseMode="File" />
       </httpErrors>
   </system.webServer>
</configuration>

Senario2: Your custom page is an aspx page and placed in the root:

<configuration>
   <system.web>
      <customErrors mode="Off" />
   </system.web>
   <system.webServer>
       <httpErrors errorMode="Custom" existingResponse="Replace">
           <remove statusCode="404" subStatusCode="-1" />
           <error statusCode="404" path="ErrorPage" responseMode="Redirect" />
       </httpErrors>
   </system.webServer>
</configuration>

Note: I remove the aspx extension due to RouteConfig.cs in ASP.net application, you can use ErrorPage.aspx if you like, it's optional.

Senario3: Your custom page is an aspx page and placed in the [ex: Page folder in The root (~/Page/ErrorPage.aspx)]:

The tip here that I noticed is YOU SHOULD NOT USE~/ to the root addressing; So I just addresing without ~/ mark:

<configuration>
   <system.web>
      <customErrors mode="Off" />
   </system.web>
   <system.webServer>
       <httpErrors errorMode="Custom" existingResponse="Replace">
           <remove statusCode="404" subStatusCode="-1" />
           <error statusCode="404" path="Page/ErrorPage" responseMode="Redirect" />
       </httpErrors>
   </system.webServer>
</configuration>


问:
Getting An AccessDeniedException with Tomcat?
I want to have access to static resources outside my webapp so that they don't get destroyed every time I redeploy, but I can't seem to get them

I have a servlet that is meant to serve these images via a FileOutputStream, but it can't get the file when I deploy it on my tomcat server - it gives me a java.nio.file.AccessDeniedException.

Error from Catalina Log File

```<code>13-Feb-2020 16:53:10.621 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [fileGetter] in context with path [] threw exception
    java.nio.file.AccessDeniedException: C:\Users\micro\Pictures\WebsiteStuff\BlogPosts\Test Image 2020-02-12.jpg
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:235)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:374)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:425)
        at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
        at java.base/java.nio.file.Files.newInputStream(Files.java:159)
        at java.base/java.nio.file.Files.copy(Files.java:3195)
        at ImageGetterServlet.doGet(ImageGetterServlet.java:37)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:830)
</code>```

This is especially strange given that I have allowed permission to the directory in my Catalina.policy file.

Catalina.Policy

```<code>grant {
...
permission java.io.FilePermission "C:${file.separator}Users${file.separator}micro${file.separator}Pictures${file.separator}WebsiteStuff", "read, write";

};
</code>```

For whatever reason, this exact same code (minus the permission) works perfectly in Intellij. However, here it is not able to access the file.

Could anyone let me know why this is happening? Did I set the wrong permission/put the permission in the wrong place?

EDIT: It is NOT a permission problem
I granted everything in Catalina.policy java.security.AllPermission but to no avail, I’m getting the same exception.

答:
I found out what was wrong. Tomcat cannot access anything inside the Users folder - probably a Windows 10 specific problem.

I just put my directory in question in the C: drive so that the path is now C:/WebsiteStuff and everything worked fine.

Body:
I want to have access to static resources outside my webapp so that they don't get destroyed every time I redeploy, but I can't seem to get them

I have a servlet that is meant to serve these images via a FileOutputStream, but it can't get the file when I deploy it on my tomcat server - it gives me a java.nio.file.AccessDeniedException.

Error from Catalina Log File

13-Feb-2020 16:53:10.621 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [fileGetter] in context with path [] threw exception
    java.nio.file.AccessDeniedException: C:\Users\micro\Pictures\WebsiteStuff\BlogPosts\Test Image 2020-02-12.jpg
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:235)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:374)
        at java.base/java.nio.file.Files.newByteChannel(Files.java:425)
        at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
        at java.base/java.nio.file.Files.newInputStream(Files.java:159)
        at java.base/java.nio.file.Files.copy(Files.java:3195)
        at ImageGetterServlet.doGet(ImageGetterServlet.java:37)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:830)

This is especially strange given that I have allowed permission to the directory in my Catalina.policy file.

Catalina.Policy

grant {
...
permission java.io.FilePermission "C:${file.separator}Users${file.separator}micro${file.separator}Pictures${file.separator}WebsiteStuff", "read, write";

};

For whatever reason, this exact same code (minus the permission) works perfectly in Intellij. However, here it is not able to access the file.

Could anyone let me know why this is happening? Did I set the wrong permission/put the permission in the wrong place?

EDIT: It is NOT a permission problem
I granted everything in Catalina.policy java.security.AllPermission but to no avail, I’m getting the same exception.


问:
TYPO3 9.5: RealURL Migration - postVarSets - Extbase RouteEnhancer
I had following RealURL Configuration (part):

````'postVarSets' => array(
    '_DEFAULT' => array(
             'level1' => array(
                 array(
                   'GETvar' => 'tx_bitproducts_productview[industryLevel1]',
                     'lookUpTable' => array(
                         'table' => 'tx_bitproducts_domain_model_industry',
                         'id_field' => 'uid',
                         'alias_field' => 'industriename',
                         'addWhereClause' => ' AND NOT deleted ',
                         'useUniqueCache' => 1,
                         'useUniqueCache_conf' => array(
                             'strtolower' => 1,
                             'spaceCharacter' => '-'
                         ),
                     )
                 ),
             ),
            'level2' => array(
              array(
                  'GETvar' => 'tx_bitproducts_productview[industryLevel2]',
                  'lookUpTable' => array(
                      'table' => 'tx_bitproducts_domain_model_industrylevel2',
                      'id_field' => 'uid',
                      'alias_field' => 'name',
                      'addWhereClause' => ' AND NOT deleted ',
                      'useUniqueCache' => 1,
                      'useUniqueCache_conf' => array(
                          'strtolower' => 1,
                          'spaceCharacter' => '-'
                      ),
                  ),
              ),
          ),
...`
```

which resulted in URLs like

.../level1/automotive/

and

.../level2/wheels/

all was handled by one Extbase Controller Action.
How could an Extbase RouteEnhancer for TYPO3 9 could look like ? I would use Slug TCA for these fields.

Thanks for any hints !

答:
Possible configuration for your example can look like:</p>

```<code>routeEnhancers:
  BitProducts:
    type: Extbase
    extension: BitProducts (or something like that, depends how called your extension)
    plugin: Productview (or something like that, depends how called your plugin)
    routes:
      - { routePath: '/level1/{level1}', _arguments: {level1: 'industryLevel1'} }
      - { routePath: '/level2/{level2}', _arguments: {level2: 'industryLevel2'} }
    defaultController: 'Controller::action'
    aspects:
      level1:
        type: PersistedAliasMapper
        tableName: 'tx_bitproducts_domain_model_industry'
        routeFieldName: 'slug'
      level2:
        type: PersistedAliasMapper
        tableName: 'tx_bitproducts_domain_model_industrylevel2'
        routeFieldName: 'slug'
</code>```

Body:
I had following RealURL Configuration (part):

`'postVarSets' => array(
    '_DEFAULT' => array(
             'level1' => array(
                 array(
                   'GETvar' => 'tx_bitproducts_productview[industryLevel1]',
                     'lookUpTable' => array(
                         'table' => 'tx_bitproducts_domain_model_industry',
                         'id_field' => 'uid',
                         'alias_field' => 'industriename',
                         'addWhereClause' => ' AND NOT deleted ',
                         'useUniqueCache' => 1,
                         'useUniqueCache_conf' => array(
                             'strtolower' => 1,
                             'spaceCharacter' => '-'
                         ),
                     )
                 ),
             ),
            'level2' => array(
              array(
                  'GETvar' => 'tx_bitproducts_productview[industryLevel2]',
                  'lookUpTable' => array(
                      'table' => 'tx_bitproducts_domain_model_industrylevel2',
                      'id_field' => 'uid',
                      'alias_field' => 'name',
                      'addWhereClause' => ' AND NOT deleted ',
                      'useUniqueCache' => 1,
                      'useUniqueCache_conf' => array(
                          'strtolower' => 1,
                          'spaceCharacter' => '-'
                      ),
                  ),
              ),
          ),
...`

which resulted in URLs like

.../level1/automotive/

and

.../level2/wheels/

all was handled by one Extbase Controller Action.
How could an Extbase RouteEnhancer for TYPO3 9 could look like ? I would use Slug TCA for these fields.

Thanks for any hints !

Body:
Possible configuration for your example can look like:

routeEnhancers:
  BitProducts:
    type: Extbase
    extension: BitProducts (or something like that, depends how called your extension)
    plugin: Productview (or something like that, depends how called your plugin)
    routes:
      - { routePath: '/level1/{level1}', _arguments: {level1: 'industryLevel1'} }
      - { routePath: '/level2/{level2}', _arguments: {level2: 'industryLevel2'} }
    defaultController: 'Controller::action'
    aspects:
      level1:
        type: PersistedAliasMapper
        tableName: 'tx_bitproducts_domain_model_industry'
        routeFieldName: 'slug'
      level2:
        type: PersistedAliasMapper
        tableName: 'tx_bitproducts_domain_model_industrylevel2'
        routeFieldName: 'slug'


问:
How can I remove the legend title in ggplot2?
I have a question concerning the legend in ggplot2.

Say I have a hypothetical dataset about mean carrot length for two different colours at two farms:

```<code>carrots<-NULL
carrots$Farm<-rep(c("X","Y"),2)
carrots$Type<-rep(c("Orange","Purple"),each=2)
carrots$MeanLength<-c(10,6,4,2)
carrots<-data.frame(carrots)
</code>```

I make a simple bar plot:

```<code>require(ggplot2)
p<-ggplot(carrots,aes(y=MeanLength,x=Farm,fill=Type)) +
geom_bar(position="dodge") +
opts(legend.position="top")
p
</code>```

My question is: is there a way to remove the title ('Type') from the legend?

Thanks!

答:
You can modify the legend title by passing it as the first parameter to a scale.  For example:

```<code>ggplot(carrots, aes(y=MeanLength, x=Farm, fill=Type)) +
  geom_bar(position="dodge") +
  theme(legend.position="top", legend.direction="horizontal") +
  scale_fill_discrete("")
</code>```

There is also a shortcut for this, i.e. labs(fill="")

Since your legend is at the top of the chart, you may also wish to modify the legend orientation.  You can do this using opts(legend.direction="horizontal").

Body:
I have a question concerning the legend in ggplot2.

Say I have a hypothetical dataset about mean carrot length for two different colours at two farms:

carrots<-NULL
carrots$Farm<-rep(c("X","Y"),2)
carrots$Type<-rep(c("Orange","Purple"),each=2)
carrots$MeanLength<-c(10,6,4,2)
carrots<-data.frame(carrots)

I make a simple bar plot:

require(ggplot2)
p<-ggplot(carrots,aes(y=MeanLength,x=Farm,fill=Type)) +
geom_bar(position="dodge") +
opts(legend.position="top")
p

My question is: is there a way to remove the title ('Type') from the legend?

Thanks!

Body:
You can modify the legend title by passing it as the first parameter to a scale.  For example:

ggplot(carrots, aes(y=MeanLength, x=Farm, fill=Type)) +
  geom_bar(position="dodge") +
  theme(legend.position="top", legend.direction="horizontal") +
  scale_fill_discrete("")

There is also a shortcut for this, i.e. labs(fill="")

Since your legend is at the top of the chart, you may also wish to modify the legend orientation.  You can do this using opts(legend.direction="horizontal").


问:
How to disambiguate a foreach loop in Xcode with SwiftUI
I am trying to create a hexagon grid using swiftUI on Xcode. To loop over the creation of the individual hexagons I am using a foreach loop. However I came Across an error when creating a function that creates a column of hexagons:

```<code>private func makeCol(C: Int, Bump:Int) -> some View {
        return ZStack {
            ForEach(-5...5, id: \.self) {Ynumber in
                self.hexagon(
                    x: (ThreeRooted * self.L * Double(C)) + self.centerWidth,
                    y: (ThreeRooted * self.L * Double(Ynumber)) + self.centerHeight + (ThreeRootedOverTwo * self.L * Bump))
                    .stroke(Color.red, lineWidth: CGFloat(self.L/4.0))
            }
        }
    }
</code>```

Error:
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions.

To get around this I extracted my location fields in separate variables. However, this gave another error:

```<code>private func makeCol(C: Int, Bump:Int) -> some View {
        return ZStack {
            ForEach(-5...5, id: \.self) {Ynumber in
                let xPlot = (ThreeRooted * self.L * Double(C)) + self.centerWidth
                let yPlot = (ThreeRooted * self.L * Double(Ynumber)) + self.centerHeight + (ThreeRootedOverTwo * self.L * Bump)

                self.hexagon(
                    x: xPlot,
                    y: yPlot)
                    .stroke(Color.red, lineWidth: CGFloat(self.L/4.0))
            }
        }
    }
</code>```

Error: Unable to infer complex closure return type; add explicit type to disambiguate.

How do I give this loop an explicit type?

答:
How do I give this loop an explicit type?

```<code>ForEach(-5...5, id: \.self) { (Ynumber) -> _ExplicitType_ in
  ...
  return self.hexagon(
            ...
         )
}
</code>```

Body:
I am trying to create a hexagon grid using swiftUI on Xcode. To loop over the creation of the individual hexagons I am using a foreach loop. However I came Across an error when creating a function that creates a column of hexagons:

private func makeCol(C: Int, Bump:Int) -> some View {
        return ZStack {
            ForEach(-5...5, id: \.self) {Ynumber in
                self.hexagon(
                    x: (ThreeRooted * self.L * Double(C)) + self.centerWidth,
                    y: (ThreeRooted * self.L * Double(Ynumber)) + self.centerHeight + (ThreeRootedOverTwo * self.L * Bump))
                    .stroke(Color.red, lineWidth: CGFloat(self.L/4.0))
            }
        }
    }

Error:
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions.

To get around this I extracted my location fields in separate variables. However, this gave another error:

private func makeCol(C: Int, Bump:Int) -> some View {
        return ZStack {
            ForEach(-5...5, id: \.self) {Ynumber in
                let xPlot = (ThreeRooted * self.L * Double(C)) + self.centerWidth
                let yPlot = (ThreeRooted * self.L * Double(Ynumber)) + self.centerHeight + (ThreeRootedOverTwo * self.L * Bump)

                self.hexagon(
                    x: xPlot,
                    y: yPlot)
                    .stroke(Color.red, lineWidth: CGFloat(self.L/4.0))
            }
        }
    }

Error: Unable to infer complex closure return type; add explicit type to disambiguate.

How do I give this loop an explicit type?

Body:
How do I give this loop an explicit type?

ForEach(-5...5, id: \.self) { (Ynumber) -> _ExplicitType_ in
  ...
  return self.hexagon(
            ...
         )
}


问:
React navigation not working on button press
I am working through a react native tutorial and I am trying to learn react native. I am using react-navigation@4.1.1 and its not working. I've installed the correct dependencies to get the project to run. Here is my code...

app.js

```<code>import React, {useState} from 'react';
import { StyleSheet, Text, View } from 'react-native';
import * as Font from 'expo-font';
import { AppLoading } from 'expo';
import MealsNavigator from './assets/navigation/MealsNavigator';

//const fetchFonts = ()=>{
  //return Font.loadAsync({
    //'open-sans': require('./assets/fonts/OpenSans-Regular.ttf'),
   // 'open-sans-bold': require('./assets/fonts/OpenSans-Bold.ttf')
 // });
//};

export default function App() {
 // const [fondLoaded, setFontLoaded] = useState(false);
  //if (!fondLoaded){
    //return ( <AppLoading
    //startAsync= {fetchFonts}
   // onFinish= {()=> setFontLoaded}
    ///>
    //);
  //}
  return (
    <MealsNavigator/>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});
</code>```

mealsnavigoter.js that holds navigation

```<code>import {createStackNavigator} from 'react-navigation-stack';
import { createAppContainer} from 'react-navigation';
import CategoriesScreen from '../../screens/CategoriesScreen';
import CategoryMealScreen from '../../screens/CategoryMealScreen';
import MealDetailScreen from '../../screens/MealDetailScreen';

const MealsNavigator = createStackNavigator({
    Categories: CategoriesScreen,
    CategoriesMeals: {
        screen: CategoryMealScreen
    },
    MealDetal: MealDetailScreen
});

export default createAppContainer(MealsNavigator);
</code>```

categories screen that has the button when pressed is supposed to navigate to the categories meal screen

```<code>import React from 'react';
import {View, Text,Button, StyleSheet} from 'react-native';

const CategoriesScreen = props =>{
    return(
        <View style={styles.screen}>
            <Text>The Categories Screen!</Text>
            <Button title="Go to Meals" onPress={()=>{props.navigation.navigate('CategoryMeals');}} />
        </View>
    );

};

const styles = StyleSheet.create({
    screen:{
        flex:1,
        justifyContent:'center',
        alignItems: 'center'
    }
});

export default CategoriesScreen;
</code>```

categoryMeals screen that i want to navigate to

```<code>import React from 'react';
import {View, Text, StyleSheet} from 'react-native';

const CategoryMealScreen = props =>{
    return(
        <View style={styles.screen}>
            <Text>The Category Meal Screen!</Text>
        </View>
    );

};

const styles = StyleSheet.create({
    screen:{
        flex:1,
        justifyContent:'center',
        alignItems: 'center'
    }
});

export default CategoryMealScreen;
</code>```

答:
Simple spelling mistake. Change your

```<code><Button title="Go to Meals" onPress={()=>{props.navigation.navigate('CategoryMeals');}} />
</code>```

to

```<code><Button title="Go to Meals" onPress={()=>{props.navigation.navigate('CategoriesMeals');}} />
</code>```

Body:
I am working through a react native tutorial and I am trying to learn react native. I am using react-navigation@4.1.1 and its not working. I've installed the correct dependencies to get the project to run. Here is my code...

app.js

import React, {useState} from 'react';
import { StyleSheet, Text, View } from 'react-native';
import * as Font from 'expo-font';
import { AppLoading } from 'expo';
import MealsNavigator from './assets/navigation/MealsNavigator';

//const fetchFonts = ()=>{
  //return Font.loadAsync({
    //'open-sans': require('./assets/fonts/OpenSans-Regular.ttf'),
   // 'open-sans-bold': require('./assets/fonts/OpenSans-Bold.ttf')
 // });
//};

export default function App() {
 // const [fondLoaded, setFontLoaded] = useState(false);
  //if (!fondLoaded){
    //return ( <AppLoading
    //startAsync= {fetchFonts}
   // onFinish= {()=> setFontLoaded}
    ///>
    //);
  //}
  return (
    <MealsNavigator/>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

mealsnavigoter.js that holds navigation

import {createStackNavigator} from 'react-navigation-stack';
import { createAppContainer} from 'react-navigation';
import CategoriesScreen from '../../screens/CategoriesScreen';
import CategoryMealScreen from '../../screens/CategoryMealScreen';
import MealDetailScreen from '../../screens/MealDetailScreen';

const MealsNavigator = createStackNavigator({
    Categories: CategoriesScreen,
    CategoriesMeals: {
        screen: CategoryMealScreen
    },
    MealDetal: MealDetailScreen
});

export default createAppContainer(MealsNavigator);

categories screen that has the button when pressed is supposed to navigate to the categories meal screen

import React from 'react';
import {View, Text,Button, StyleSheet} from 'react-native';

const CategoriesScreen = props =>{
    return(
        <View style={styles.screen}>
            <Text>The Categories Screen!</Text>
            <Button title="Go to Meals" onPress={()=>{props.navigation.navigate('CategoryMeals');}} />
        </View>
    );

};

const styles = StyleSheet.create({
    screen:{
        flex:1,
        justifyContent:'center',
        alignItems: 'center'
    }
});

export default CategoriesScreen;

categoryMeals screen that i want to navigate to

import React from 'react';
import {View, Text, StyleSheet} from 'react-native';

const CategoryMealScreen = props =>{
    return(
        <View style={styles.screen}>
            <Text>The Category Meal Screen!</Text>
        </View>
    );

};

const styles = StyleSheet.create({
    screen:{
        flex:1,
        justifyContent:'center',
        alignItems: 'center'
    }
});

export default CategoryMealScreen;

Body:
Simple spelling mistake. Change your

<Button title="Go to Meals" onPress={()=>{props.navigation.navigate('CategoryMeals');}} />

to

<Button title="Go to Meals" onPress={()=>{props.navigation.navigate('CategoriesMeals');}} />


问:
Python pandas function to concat into one row different values into one column based on repeating values in another
Apologies, I didn't even know how to title/describe the issue I am having, so bear with me. I have the following code:

```<code>import pandas as pd
data = {'Invoice Number':[1279581, 1279581,1229422, 1229422, 1229422],
        'Project Key':[263736, 263736, 259661, 259661, 259661],
        'Project Type': ['Visibility', 'Culture', 'Spend', 'Visibility', 'Culture']}
df= pd.DataFrame(data)
</code>```

How do I get the output to basically group the Invoice Numbers so that there is only 1 row per Invoice Number and combine the multiple Project Types (per that 1 Invoice) into 1 row?
Code and output for output is below.
Thanks much appreciated.

```<code>import pandas as pd
data = {'Invoice Number':[1279581,1229422],
        'Project Key':[263736, 259661],
        'Project Type': ['Visibility_Culture', 'Spend_Visibility_Culture']
}
output = pd.DataFrame(data)
output
</code>```

答:
```<code>>>> (df
     .groupby(['Invoice Number', 'Project Key'])['Project Type']
     .apply(lambda x: '_'.join(x))
     .reset_index()
    )
   Invoice Number  Project Key              Project Type
0         1229422       259661  Spend_Visibility_Culture
1         1279581       263736        Visibility_Culture
</code>```

Body:
Apologies, I didn't even know how to title/describe the issue I am having, so bear with me. I have the following code:

import pandas as pd
data = {'Invoice Number':[1279581, 1279581,1229422, 1229422, 1229422],
        'Project Key':[263736, 263736, 259661, 259661, 259661],
        'Project Type': ['Visibility', 'Culture', 'Spend', 'Visibility', 'Culture']}
df= pd.DataFrame(data)

How do I get the output to basically group the Invoice Numbers so that there is only 1 row per Invoice Number and combine the multiple Project Types (per that 1 Invoice) into 1 row?
Code and output for output is below.
Thanks much appreciated.

import pandas as pd
data = {'Invoice Number':[1279581,1229422],
        'Project Key':[263736, 259661],
        'Project Type': ['Visibility_Culture', 'Spend_Visibility_Culture']
}
output = pd.DataFrame(data)
output


问:
Link to the latest file uploaded in a GitHub repository
Is there a method to get the RAW link to the latest file uploaded in a folder within a GitHub repository?

For example, here is a link (to a specific file):

```<code>https://raw.githubusercontent.com/CSSEGISandData/2019-nCoV/master/daily_case_updates/02-10-2020_1030.csv
</code>```

Is there a method to get the link to most recent one?

答:
Throw this in a script

```<code>function reverse(collection) {
  if (typeof collection != "object") {
    return collection
  }
  return collection.reverse()
}
</code>```

then use the following and the cell you want is always B2 =reverse(IMPORTHTML("https://github.com/CSSEGISandData/2019-nCoV/tree/master/daily_case_updates","table", 1))

Body:
Is there a method to get the RAW link to the latest file uploaded in a folder within a GitHub repository?

For example, here is a link (to a specific file):

https://raw.githubusercontent.com/CSSEGISandData/2019-nCoV/master/daily_case_updates/02-10-2020_1030.csv

Is there a method to get the link to most recent one?

Body:
Throw this in a script

function reverse(collection) {
  if (typeof collection != "object") {
    return collection
  }
  return collection.reverse()
}

then use the following and the cell you want is always B2 =reverse(IMPORTHTML("https://github.com/CSSEGISandData/2019-nCoV/tree/master/daily_case_updates","table", 1))


问:
squid transparent proxy (intercept) + router
there is already a configured transparent proxy squid-3.5.27, there is an EdgeOSEdgeRouter router

I want to make a circuit

all computers on the network -> router -> squid

squid - 109.0.0.110
router - 109.0.0.1
test Windows - 109.0.0.8

configuration squid.conf, version - squid-3.5.27

```<code># You should use the same dns resolver on squid and all clients
dns_nameservers 127.0.0.1

# acls
acl localnet src 109.0.0.0/24        # RFC1918 possible internal network
acl localnet src 192.168.1.0/24 # RFC1918 possible internal network
acl localnet src 192.168.10.0/24        # RFC1918 possible internal network

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

acl blocked_http dstdomain "/etc/squid/blocked_sites.txt"

# http access
http_access deny !Safe_ports

http_access deny CONNECT !SSL_ports

http_access allow localhost manager
http_access deny manager

http_access deny blocked_http

http_access allow localnet
http_access allow localhost
http_access deny all

http_port 3128 intercept
https_port 3129 intercept  ssl-bump connection-auth=off cert=/etc/squid/squidCA.pem
http_port 3130

always_direct allow all
sslproxy_cert_error allow all
sslproxy_flags DONT_VERIFY_PEER

acl blocked ssl::server_name "/etc/squid/blocked_https.txt"
acl whitelist src "/etc/squid/whitelist_ip.txt"
ssl_bump splice whitelist
acl step1 at_step SslBump1
ssl_bump peek step1

ssl_bump terminate blocked
ssl_bump splice all

sslcrtd_program /opt/source/squid-3.5.27/src/ssl/ssl_crtd -s /var/lib/ssl_db -M 4MB
sslcrtd_children 8 startup=1 idle=1

acl YOUTUBE ssl::server_name .googlevideo.com
delay_pools 1
delay_class 1 2
delay_parameters 1 -1/-1 5120/5120
delay_access 1 allow YOUTUBE

coredump_dir /var/spool/squid
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320
cache_dir aufs /var/spool/squid 20000 49 256
maximum_object_size 61440 KB
minimum_object_size 3 KB

cache_swap_low 90
cache_swap_high 95
maximum_object_size_in_memory 512 KB
memory_replacement_policy lru
logfile_rotate 4
</code>```

try this doc

```<code>iptables -t nat -A PREROUTING -i eth0 ! -s 109.0.0.110 -p tcp --dport 80 -j DNAT --to 109.0.0.110:3128
iptables -t nat -A POSTROUTING -o eth0 -s 109.0.0.8/32 -d 109.0.0.110/32 -j SNAT --to 109.0.0.1
iptables -A FORWARD -s 109.0.0.8/32 -d 109.0.0.110/32 -i eth0 -o eth0 -p tcp --dport 3128 -j ACCEPT
</code>```

prescribed iptables

I try to open a site on a test Windows (109.0.0.8) - access is denied, on Windows the gateway is 109.0.0.1, in the logs on squid

```<code>1546203601.533      0 109.0.0.110 TCP_MISS/403 4857 GET http://myip.ru/ - HIER_NONE/- text/html
1546203601.533      1 109.0.0.1 TCP_MISS/403 4977 GET http://myip.ru/ - ORIGINAL_DST/109.0.0.110 text/html
</code>```

tcpdump squid server

```<code>11:00:57.141246 IP 109.0.0.8.54026 > myip.ru.http: Flags [F.], seq 1, ack 1, win 2087, length 0
11:00:57.141570 IP 109.0.0.8.54030 > myip.ru.http: Flags [S], seq 1736419147, win 64240, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
11:00:57.141971 IP myip.ru.http > 109.0.0.8.54026: Flags [.], ack 2, win 58, length 0
11:00:57.142115 IP myip.ru.http > 109.0.0.8.54026: Flags [F.], seq 1, ack 2, win 58, length 0
11:00:57.142304 IP myip.ru.http > 109.0.0.8.54030: Flags [S.], seq 4065681746, ack 1736419148, win 29200, options [mss 1452,nop,nop,sackOK,nop,wscale 9], length 0
11:00:57.142363 IP 109.0.0.8.54026 > myip.ru.http: Flags [.], ack 2, win 2087, length 0
11:00:57.142505 IP 109.0.0.8.54030 > myip.ru.http: Flags [.], ack 1, win 260, length 0
11:00:57.144743 IP 109.0.0.8.54025 > myip.ru.http: Flags [P.], seq 2136:2856, ack 23054, win 2087, length 720: HTTP: GET / HTTP/1.1
11:00:57.146027 IP myip.ru.http > 109.0.0.8.54025: Flags [P.], seq 23054:23572, ack 2856, win 69, length 518: HTTP: HTTP/1.1 403 Forbidden
</code>```

tell me what could be the problem, I will be grateful for any help?

Update

when you open a site on http by Windows, it is issued - 403, by https - an invalid certificate, the proxy server certificate is substituted in the browser, what am I doing wrong?

Update 2

when adding rules on a router

```<code>iptables -t nat -I PREROUTING -i eth0 -s 109.0.0.8 -p tcp --dport 80 -j DNAT --to 109.0.0.110:3128
iptables -t nat -I PREROUTING -i eth0 -s 109.0.0.8 -p tcp --dport 443 -j DNAT --to 109.0.0.110:3129
iptables -t nat -I POSTROUTING -o eth0 -s 109.0.0.8 -d 109.0.0.110 -j SNAT --to 109.0.0.1
</code>```

proxy server rules

```<code>*nat
:PREROUTING ACCEPT [314:20555]
:INPUT ACCEPT [313:20511]
:OUTPUT ACCEPT [844:60999]
:POSTROUTING ACCEPT [2:130]
-A PREROUTING -s 109.0.0.0/24 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3129
-A PREROUTING -s 109.0.0.0/24 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
-A PREROUTING -s 192.168.10.0/24 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3129
-A PREROUTING -s 192.168.10.0/24 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
-A PREROUTING -s 192.168.1.0/24 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3129
-A PREROUTING -s 192.168.1.0/24 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
-A POSTROUTING -s 109.0.0.0/24 -j SNAT --to-source 109.0.0.110
-A POSTROUTING -s 192.168.10.0/24 -j SNAT --to-source 109.0.0.110
-A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source 109.0.0.110
COMMIT
*filter
:INPUT ACCEPT [340:18626]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1809:273786]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -s 109.0.0.0/24 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -j ACCEPT
-A INPUT -s 192.168.10.0/24 -j ACCEPT
-A INPUT -j LOG
-A INPUT -p tcp -m multiport --dports 3128:3130 -j DROP
-A FORWARD -s 109.0.0.0/24 -p udp -m multiport --dports 80,443 -j DROP
COMMIT
</code>```

when you open a site on Windows on http, in cache.log

```<code>kid1| WARNING: Forwarding loop detected for:
GET / HTTP/1.1^M
Upgrade-Insecure-Requests: 1^M
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36^M
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8^M
Accept-Encoding: gzip, deflate^M
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7^M
Via: 1.1 proxy.server (squid/3.5.27)^M
X-Forwarded-For: 109.0.0.1^M
Cache-Control: max-age=259200^M
Connection: keep-alive^M
Host: myip.ru^M
^M
kid1| WARNING: Forwarding loop detected for:
GET /favicon.ico HTTP/1.1^M
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36^M
Accept: image/webp,image/apng,image/*,*/*;q=0.8^M
Referer: http://myip.ru/^M
Accept-Encoding: gzip, deflate^M
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7^M
Via: 1.1 proxy.server (squid/3.5.27)^M
X-Forwarded-For: 109.0.0.1^M
Cache-Control: max-age=259200^M
Connection: keep-alive^M
Host: myip.ru^M
</code>```

in access.log

```<code>1546711344.892      0 109.0.0.110 TCP_MISS/403 4514 GET http://myip.ru/ - HIER_NONE/- text/html
1546711344.893      0 109.0.0.1 TCP_MISS/403 4634 GET http://myip.ru/ - ORIGINAL_DST/109.0.0.110 text/html
1546711344.913      0 109.0.0.110 TCP_MISS/403 4479 GET http://myip.ru/favicon.ico - HIER_NONE/- text/html
1546711344.913      0 109.0.0.1 TCP_MISS/403 4599 GET http://myip.ru/favicon.ico - ORIGINAL_DST/109.0.0.110 text/html
</code>```

WARNING: Forwarding loop detected for

how to fix it, any help ?

答:
Don't use DNAT and change destination IP! Forward your traffic to the Squid machine as it was generated on the client machine by changing the IP routing table. See https://wiki.squid-cache.org/ConfigExamples/Intercept/IptablesPolicyRoute

I had the same problem which has been solved by this approach.

Body:
there is already a configured transparent proxy squid-3.5.27, there is an EdgeOSEdgeRouter router

I want to make a circuit

all computers on the network -> router -> squid

squid - 109.0.0.110
router - 109.0.0.1
test Windows - 109.0.0.8

configuration squid.conf, version - squid-3.5.27

# You should use the same dns resolver on squid and all clients
dns_nameservers 127.0.0.1

# acls
acl localnet src 109.0.0.0/24        # RFC1918 possible internal network
acl localnet src 192.168.1.0/24 # RFC1918 possible internal network
acl localnet src 192.168.10.0/24        # RFC1918 possible internal network

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

acl blocked_http dstdomain "/etc/squid/blocked_sites.txt"

# http access
http_access deny !Safe_ports

http_access deny CONNECT !SSL_ports

http_access allow localhost manager
http_access deny manager

http_access deny blocked_http

http_access allow localnet
http_access allow localhost
http_access deny all

http_port 3128 intercept
https_port 3129 intercept  ssl-bump connection-auth=off cert=/etc/squid/squidCA.pem
http_port 3130

always_direct allow all
sslproxy_cert_error allow all
sslproxy_flags DONT_VERIFY_PEER

acl blocked ssl::server_name "/etc/squid/blocked_https.txt"
acl whitelist src "/etc/squid/whitelist_ip.txt"
ssl_bump splice whitelist
acl step1 at_step SslBump1
ssl_bump peek step1

ssl_bump terminate blocked
ssl_bump splice all

sslcrtd_program /opt/source/squid-3.5.27/src/ssl/ssl_crtd -s /var/lib/ssl_db -M 4MB
sslcrtd_children 8 startup=1 idle=1

acl YOUTUBE ssl::server_name .googlevideo.com
delay_pools 1
delay_class 1 2
delay_parameters 1 -1/-1 5120/5120
delay_access 1 allow YOUTUBE

coredump_dir /var/spool/squid
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320
cache_dir aufs /var/spool/squid 20000 49 256
maximum_object_size 61440 KB
minimum_object_size 3 KB

cache_swap_low 90
cache_swap_high 95
maximum_object_size_in_memory 512 KB
memory_replacement_policy lru
logfile_rotate 4

try this doc

iptables -t nat -A PREROUTING -i eth0 ! -s 109.0.0.110 -p tcp --dport 80 -j DNAT --to 109.0.0.110:3128
iptables -t nat -A POSTROUTING -o eth0 -s 109.0.0.8/32 -d 109.0.0.110/32 -j SNAT --to 109.0.0.1
iptables -A FORWARD -s 109.0.0.8/32 -d 109.0.0.110/32 -i eth0 -o eth0 -p tcp --dport 3128 -j ACCEPT

prescribed iptables

I try to open a site on a test Windows (109.0.0.8) - access is denied, on Windows the gateway is 109.0.0.1, in the logs on squid

1546203601.533      0 109.0.0.110 TCP_MISS/403 4857 GET http://myip.ru/ - HIER_NONE/- text/html
1546203601.533      1 109.0.0.1 TCP_MISS/403 4977 GET http://myip.ru/ - ORIGINAL_DST/109.0.0.110 text/html

tcpdump squid server

11:00:57.141246 IP 109.0.0.8.54026 > myip.ru.http: Flags [F.], seq 1, ack 1, win 2087, length 0
11:00:57.141570 IP 109.0.0.8.54030 > myip.ru.http: Flags [S], seq 1736419147, win 64240, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
11:00:57.141971 IP myip.ru.http > 109.0.0.8.54026: Flags [.], ack 2, win 58, length 0
11:00:57.142115 IP myip.ru.http > 109.0.0.8.54026: Flags [F.], seq 1, ack 2, win 58, length 0
11:00:57.142304 IP myip.ru.http > 109.0.0.8.54030: Flags [S.], seq 4065681746, ack 1736419148, win 29200, options [mss 1452,nop,nop,sackOK,nop,wscale 9], length 0
11:00:57.142363 IP 109.0.0.8.54026 > myip.ru.http: Flags [.], ack 2, win 2087, length 0
11:00:57.142505 IP 109.0.0.8.54030 > myip.ru.http: Flags [.], ack 1, win 260, length 0
11:00:57.144743 IP 109.0.0.8.54025 > myip.ru.http: Flags [P.], seq 2136:2856, ack 23054, win 2087, length 720: HTTP: GET / HTTP/1.1
11:00:57.146027 IP myip.ru.http > 109.0.0.8.54025: Flags [P.], seq 23054:23572, ack 2856, win 69, length 518: HTTP: HTTP/1.1 403 Forbidden

tell me what could be the problem, I will be grateful for any help?

Update

when you open a site on http by Windows, it is issued - 403, by https - an invalid certificate, the proxy server certificate is substituted in the browser, what am I doing wrong?

Update 2

when adding rules on a router

iptables -t nat -I PREROUTING -i eth0 -s 109.0.0.8 -p tcp --dport 80 -j DNAT --to 109.0.0.110:3128
iptables -t nat -I PREROUTING -i eth0 -s 109.0.0.8 -p tcp --dport 443 -j DNAT --to 109.0.0.110:3129
iptables -t nat -I POSTROUTING -o eth0 -s 109.0.0.8 -d 109.0.0.110 -j SNAT --to 109.0.0.1

proxy server rules

*nat
:PREROUTING ACCEPT [314:20555]
:INPUT ACCEPT [313:20511]
:OUTPUT ACCEPT [844:60999]
:POSTROUTING ACCEPT [2:130]
-A PREROUTING -s 109.0.0.0/24 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3129
-A PREROUTING -s 109.0.0.0/24 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
-A PREROUTING -s 192.168.10.0/24 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3129
-A PREROUTING -s 192.168.10.0/24 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
-A PREROUTING -s 192.168.1.0/24 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3129
-A PREROUTING -s 192.168.1.0/24 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
-A POSTROUTING -s 109.0.0.0/24 -j SNAT --to-source 109.0.0.110
-A POSTROUTING -s 192.168.10.0/24 -j SNAT --to-source 109.0.0.110
-A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source 109.0.0.110
COMMIT
*filter
:INPUT ACCEPT [340:18626]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1809:273786]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -s 109.0.0.0/24 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -j ACCEPT
-A INPUT -s 192.168.10.0/24 -j ACCEPT
-A INPUT -j LOG
-A INPUT -p tcp -m multiport --dports 3128:3130 -j DROP
-A FORWARD -s 109.0.0.0/24 -p udp -m multiport --dports 80,443 -j DROP
COMMIT

when you open a site on Windows on http, in cache.log

kid1| WARNING: Forwarding loop detected for:
GET / HTTP/1.1^M
Upgrade-Insecure-Requests: 1^M
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36^M
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8^M
Accept-Encoding: gzip, deflate^M
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7^M
Via: 1.1 proxy.server (squid/3.5.27)^M
X-Forwarded-For: 109.0.0.1^M
Cache-Control: max-age=259200^M
Connection: keep-alive^M
Host: myip.ru^M
^M
kid1| WARNING: Forwarding loop detected for:
GET /favicon.ico HTTP/1.1^M
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36^M
Accept: image/webp,image/apng,image/*,*/*;q=0.8^M
Referer: http://myip.ru/^M
Accept-Encoding: gzip, deflate^M
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7^M
Via: 1.1 proxy.server (squid/3.5.27)^M
X-Forwarded-For: 109.0.0.1^M
Cache-Control: max-age=259200^M
Connection: keep-alive^M
Host: myip.ru^M

in access.log

1546711344.892      0 109.0.0.110 TCP_MISS/403 4514 GET http://myip.ru/ - HIER_NONE/- text/html
1546711344.893      0 109.0.0.1 TCP_MISS/403 4634 GET http://myip.ru/ - ORIGINAL_DST/109.0.0.110 text/html
1546711344.913      0 109.0.0.110 TCP_MISS/403 4479 GET http://myip.ru/favicon.ico - HIER_NONE/- text/html
1546711344.913      0 109.0.0.1 TCP_MISS/403 4599 GET http://myip.ru/favicon.ico - ORIGINAL_DST/109.0.0.110 text/html

WARNING: Forwarding loop detected for

how to fix it, any help ?


问:
Why can't I add concrete classes to a list of interfaces which the concrete classes implement?
I am having trouble adding an instance of a class that implements an interface to a list of that interface; I am getting type validation errors.

I have the following:

A base class Pet containing two fields common to all pets: PetId and Name.

An interface PetInterface enforcing two fields: PetId and Name.

Concrete classes Dog and Cat that inherit from Pet and implement PetInterface.

Code:

public interface PetInterface
{
  public int PetId { get; set; }
  public string Name { get; set; }
}

public class Pet
{
  public int PetId { get; set; }
  public string Name { get; set; }
}

public class Dog: Pet, PetInterface
{
}

public class Cat: Pet, PetInterface
{
}

```

<p>Scenario 1:</p>

<pre class="lang-cs prettyprint-override"><code>var dog = new Dog();
var cat = new Cat();

List<PetInterface> petInterfaceList = new List<PetInterface>();

petInterfaceList.Add(dog1); //Error: cannot convert Dog to PetInterface class
petInterfaceList.Add(cat1); //Error: cannot convert Cat to PetInterface class

</code>```

Scenario 2:

var dog = new Dog();
var cat = new Cat();
var petList = new List<Pet>({dog, cat});

List<PetInterface> petInterfaceList = petList //Error: cannot convert List<Pet> to List<PetInterface>

```

What am I missing here?

答:
I don't think your example code will compile.

You don't set access level on interface properties, methods, there will be no public, private, just int and String

You could probably just do away with the Interface altogether and just inherit from base class Pet.

```<code>    //The interface contract -> Assures these properties are part of base class
    public interface PetInterface
    {
        int petId { get; set; }
        String name { get; set; }
    }

    //base class which defines contract properties of interface PetInterface
    public class Pet : PetInterface
    {
        public int petId { get; set; }
        public String name { get; set; }
    }

    public class Dog: Pet
    {
       //Add dog specific properties/methods
    }

    public class Cat: Pet
    {
      //Add cat specific properties/methods
    }
</code>```

Body:
I am having trouble adding an instance of a class that implements an interface to a list of that interface; I am getting type validation errors.

I have the following:

A base class Pet containing two fields common to all pets: PetId and Name.

An interface PetInterface enforcing two fields: PetId and Name.

Concrete classes Dog and Cat that inherit from Pet and implement PetInterface.

Code:

public interface PetInterface
{
  public int PetId { get; set; }
  public string Name { get; set; }
}

public class Pet
{
  public int PetId { get; set; }
  public string Name { get; set; }
}

public class Dog: Pet, PetInterface
{
}

public class Cat: Pet, PetInterface
{
}

Scenario 1:

var dog = new Dog();
var cat = new Cat();

List<PetInterface> petInterfaceList = new List<PetInterface>();

petInterfaceList.Add(dog1); //Error: cannot convert Dog to PetInterface class
petInterfaceList.Add(cat1); //Error: cannot convert Cat to PetInterface class

Scenario 2:

var dog = new Dog();
var cat = new Cat();
var petList = new List<Pet>({dog, cat});

List<PetInterface> petInterfaceList = petList //Error: cannot convert List<Pet> to List<PetInterface>

What am I missing here?

Body:
I don't think your example code will compile.

You don't set access level on interface properties, methods, there will be no public, private, just int and String

You could probably just do away with the Interface altogether and just inherit from base class Pet.

    //The interface contract -> Assures these properties are part of base class
    public interface PetInterface
    {
        int petId { get; set; }
        String name { get; set; }
    }

    //base class which defines contract properties of interface PetInterface
    public class Pet : PetInterface
    {
        public int petId { get; set; }
        public String name { get; set; }
    }

    public class Dog: Pet
    {
       //Add dog specific properties/methods
    }

    public class Cat: Pet
    {
      //Add cat specific properties/methods
    }


问:
OpenCV Python with CUDA on Windows: DLL Load Failed
I am trying to get OpenCV python bindings to work with CUDA, but when I run

```<code>import cv2
</code>```

I get the following error:

```<code>OpenCV loader: os.name="nt"  platform.system()="Windows"
OpenCV loader: loading config: C:\opencv\build\python_loader\cv2\config.py
OpenCV loader: loading config: C:\opencv\build\python_loader\cv2\config-3.8.py
OpenCV loader: PYTHON_EXTENSIONS_PATHS=['C:/opencv/build/lib/python3/Release']
OpenCV loader: BINARIES_PATHS=['C:/opencv/build/bin/Release']
OpenCV loader: PATH=C:/opencv/build/bin/Release;C:\Program Files\Python38\Scripts\;C:\Program Files\Python38\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\libnvvp;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\CCM;C:\WINDOWS\CCM;C:\Perl64\c\bin;C:\Perl64\perl\site\bin;C:\Perl64\perl\bin;C:\WINDOWS\CCM;C:\WINDOWS\CCM;C:\WINDOWS\CCM;C:\Program Files\PuTTY\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.5.0\;C:\opencv\build\install\x64\vc16\bin\;C:\Users\md249\AppData\Local\Microsoft\WindowsApps;
OpenCV loader: replacing cv2 module
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\opencv\build\python_loader\cv2\__init__.py", line 96, in <module>
    bootstrap()
  File "C:\opencv\build\python_loader\cv2\__init__.py", line 86, in bootstrap
    import cv2
ImportError: DLL load failed while importing cv2: The specified module could not be found.
</code>```

I have the following environment variables set:

```<code>OPENCV_DIR: C:\opencv\build\
PATH: $PATH;C:\opencv\build\install\x64\vc16\bin\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin
</code>```

It seems that OpenCV builds binaries to multiple different directories for reasons I do not understand, so I am unsure where to point PATH and OPENCV_DIR.

Running Dependency Walker against cv2.cp38-win_amd64.pyd does not indicate any missing dependencies from OpenCV or CUDA.

Does the .pyd dynamically load any other dependencies that Dependency Walker might not catch?
C++ applications load OpenCV just fine so I imagine the problem has something to do with where the .pyd extension is looking for dependencies.

Hopefully I have included all the relevant information.

答:
It is probably because you didnt installed OpenCV, you donwloaded it, if you don't want to spend time configuring extra path to make sure python finds the right opencv package you just need to install it using 'pip':

```<code>pip install opencv-contrib-python
</code>```

It will probably solve you problem, and the C++ software can still use the downloaded version without conflict.

Install Reference

Body:
I am trying to get OpenCV python bindings to work with CUDA, but when I run

import cv2

I get the following error:

OpenCV loader: os.name="nt"  platform.system()="Windows"
OpenCV loader: loading config: C:\opencv\build\python_loader\cv2\config.py
OpenCV loader: loading config: C:\opencv\build\python_loader\cv2\config-3.8.py
OpenCV loader: PYTHON_EXTENSIONS_PATHS=['C:/opencv/build/lib/python3/Release']
OpenCV loader: BINARIES_PATHS=['C:/opencv/build/bin/Release']
OpenCV loader: PATH=C:/opencv/build/bin/Release;C:\Program Files\Python38\Scripts\;C:\Program Files\Python38\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\libnvvp;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\CCM;C:\WINDOWS\CCM;C:\Perl64\c\bin;C:\Perl64\perl\site\bin;C:\Perl64\perl\bin;C:\WINDOWS\CCM;C:\WINDOWS\CCM;C:\WINDOWS\CCM;C:\Program Files\PuTTY\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.5.0\;C:\opencv\build\install\x64\vc16\bin\;C:\Users\md249\AppData\Local\Microsoft\WindowsApps;
OpenCV loader: replacing cv2 module
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\opencv\build\python_loader\cv2\__init__.py", line 96, in <module>
    bootstrap()
  File "C:\opencv\build\python_loader\cv2\__init__.py", line 86, in bootstrap
    import cv2
ImportError: DLL load failed while importing cv2: The specified module could not be found.

I have the following environment variables set:

OPENCV_DIR: C:\opencv\build\
PATH: $PATH;C:\opencv\build\install\x64\vc16\bin\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin

It seems that OpenCV builds binaries to multiple different directories for reasons I do not understand, so I am unsure where to point PATH and OPENCV_DIR.

Running Dependency Walker against cv2.cp38-win_amd64.pyd does not indicate any missing dependencies from OpenCV or CUDA.

Does the .pyd dynamically load any other dependencies that Dependency Walker might not catch?
C++ applications load OpenCV just fine so I imagine the problem has something to do with where the .pyd extension is looking for dependencies.

Hopefully I have included all the relevant information.

Body:
It is probably because you didnt installed OpenCV, you donwloaded it, if you don't want to spend time configuring extra path to make sure python finds the right opencv package you just need to install it using 'pip':

pip install opencv-contrib-python

It will probably solve you problem, and the C++ software can still use the downloaded version without conflict.

Install Reference


问:
multiple IF else conditions issue
I have an issue where I want to segregate / split file based on search item into multiple files.

if I see add I want to put that line to addfile.
similar to changeprop, insert and if I cannot find any match then to otherfile.   I'm unable to process the if else conditions.

```<code>FOR /F "tokens=* delims=" %%a in ('TYPE "%File%"') DO (
    SET "eachline=%%a"
    IF /i "!eachline:~0,3!" == "ADD " (ECHO !eachline!>>"%ADDActionScriptsMergedFile%")
    ELSE ( IF /i "!eachline:~0,9!" == "ADDINSERT" (ECHO !eachline!>>"%ADDINSERTActionScriptsMergedFile%")
        ELSE ( IF /i "!eachline:~0,3!" == "MOV" (ECHO !eachline!>>"%MOVEActionScriptsMergedFile%")
            ELSE ( IF /i "!eachline:~0,6!" == "INSERT" (ECHO !eachline!>>"%INSERTPROPActionScriptsMergedFile%")
                ELSE ( IF /i "!eachline:~0,10!" == "CHANGEPROP" (ECHO !eachline!>>"%CHANGEPROPActionScriptsMergedFile%")
                    ELSE (ECHO !eachline!>>"%OTHERPROPActionScriptsMergedFile%")
                )
            )
        )
    )
)
</code>```

答:
As stated in my comment, your syntax for IF/ELSE is incorrect. The general syntax is that there should always be a space before any opening code block parenthesis, whereas spaces following a closing code block parenthesis are not strictly problematic, even if technically not correct. ELSE is not an individual command, it is dependent upon IF, so it must be read in the same line.

Example based upon your latest provided code:

FOR /F "TOKENS=* DELIMS=" %%a IN ('TYPE "%File%"')DO (SET "eachline=%%a"
    IF /I "!eachline:~0,3!" == "ADD" (>>"%ADDActionScriptsMergedFile%" ECHO !eachline!
    )ELSE (IF /I "!eachline:~0,9!" == "ADDINSERT" (>>"%ADDINSERTActionScriptsMergedFile%" ECHO !eachline!
        )ELSE (IF /I "!eachline:~0,3!" == "MOV" (>>"%MOVEActionScriptsMergedFile%" ECHO !eachline!
            )ELSE (IF /I "!eachline:~0,6!" == "INSERT" (>>"%INSERTPROPActionScriptsMergedFile%" ECHO !eachline!
                )ELSE (IF /I "!eachline:~0,10!" == "CHANGEPROP" (>>"%CHANGEPROPActionScriptsMergedFile%" ECHO !eachline!
                    )ELSE >>"%OTHERPROPActionScriptsMergedFile%" ECHO !eachline!
                )
            )
        )
    )
)
```

*You'll note that I changed IF /i "!eachline:~0,3!" == "ADD " ( to IF /I "!eachline:~0,3!" == "ADD" (, because I assumed it was a typo, ("!eachline:~0,3!" is always 3 characters, excluding the doublequotes, so it can never equal the four characters in "ADD ").

Title: multiple IF else conditions issue

Body:
I have an issue where I want to segregate / split file based on search item into multiple files.

if I see add I want to put that line to addfile.
similar to changeprop, insert and if I cannot find any match then to otherfile.   I'm unable to process the if else conditions.

FOR /F "tokens=* delims=" %%a in ('TYPE "%File%"') DO (
    SET "eachline=%%a"
    IF /i "!eachline:~0,3!" == "ADD " (ECHO !eachline!>>"%ADDActionScriptsMergedFile%")
    ELSE ( IF /i "!eachline:~0,9!" == "ADDINSERT" (ECHO !eachline!>>"%ADDINSERTActionScriptsMergedFile%")
        ELSE ( IF /i "!eachline:~0,3!" == "MOV" (ECHO !eachline!>>"%MOVEActionScriptsMergedFile%")
            ELSE ( IF /i "!eachline:~0,6!" == "INSERT" (ECHO !eachline!>>"%INSERTPROPActionScriptsMergedFile%")
                ELSE ( IF /i "!eachline:~0,10!" == "CHANGEPROP" (ECHO !eachline!>>"%CHANGEPROPActionScriptsMergedFile%")
                    ELSE (ECHO !eachline!>>"%OTHERPROPActionScriptsMergedFile%")
                )
            )
        )
    )
)

Body:
As stated in my comment, your syntax for IF/ELSE is incorrect. The general syntax is that there should always be a space before any opening code block parenthesis, whereas spaces following a closing code block parenthesis are not strictly problematic, even if technically not correct. ELSE is not an individual command, it is dependent upon IF, so it must be read in the same line.

Example based upon your latest provided code:

FOR /F "TOKENS=* DELIMS=" %%a IN ('TYPE "%File%"')DO (SET "eachline=%%a"
    IF /I "!eachline:~0,3!" == "ADD" (>>"%ADDActionScriptsMergedFile%" ECHO !eachline!
    )ELSE (IF /I "!eachline:~0,9!" == "ADDINSERT" (>>"%ADDINSERTActionScriptsMergedFile%" ECHO !eachline!
        )ELSE (IF /I "!eachline:~0,3!" == "MOV" (>>"%MOVEActionScriptsMergedFile%" ECHO !eachline!
            )ELSE (IF /I "!eachline:~0,6!" == "INSERT" (>>"%INSERTPROPActionScriptsMergedFile%" ECHO !eachline!
                )ELSE (IF /I "!eachline:~0,10!" == "CHANGEPROP" (>>"%CHANGEPROPActionScriptsMergedFile%" ECHO !eachline!
                    )ELSE >>"%OTHERPROPActionScriptsMergedFile%" ECHO !eachline!
                )
            )
        )
    )
)

*You'll note that I changed IF /i "!eachline:~0,3!" == "ADD " ( to IF /I "!eachline:~0,3!" == "ADD" (, because I assumed it was a typo, ("!eachline:~0,3!" is always 3 characters, excluding the doublequotes, so it can never equal the four characters in "ADD ").


问:
How to prevent scrollbar from repositioning web page?
I have a website with center-aligned DIV. Now, some pages need scrolling, some don't. When I move from one type to another, the appearance of a scrollbar moves the page a few pixels to the side. Is there any way to avoid this without explicitly showing the scrollbars on each page?</p>

答:
If the width of the table won't change, you can set the width of the element (such as tbody) that contains the scrollbar > 100% (allowing extra space for the scrollbar) and set overflow-y to "overlay" (so that the scrollbar stays fixed, and won't shift the table left when it appears). Also set a fixed height for the element with the scrollbar, so the scrollbar will appear once the height is exceeded. Like so:

```<code>tbody {
  height: 100px;
  overflow-y: overlay;
  width: 105%
}
</code>```

Note: you will have to manually adjust the width % as the % of space the scrollbar takes up will be relative to your table width (ie: smaller width of table, more % required to fit the scrollbar, as it's size in pixels is constant)

A dynamic table example:

function addRow(tableID)
{
    var table = document.getElementById(tableID);
    var rowCount = table.rows.length;
    var row = table.insertRow(rowCount);
    var colCount = table.rows[0].cells.length;

    for(var i=0; i<colCount; i++)
    {
        var newRow = row.insertCell(i);

        newRow.innerHTML = table.rows[0].cells[i].innerHTML;
        newRow.childNodes[0].value = "";
    }
}

function deleteRow(row)
{
    var table = document.getElementById("data");
    var rowCount = table.rows.length;
    var rowIndex = row.parentNode.parentNode.rowIndex;

    document.getElementById("data").deleteRow(rowIndex);
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.scroll-table {
  border-collapse: collapse;
}

.scroll-table tbody {
  display:block;
  overflow-y:overlay;
  height:60px;
  width: 105%
}

.scroll-table tbody td {
  color: #333;
  padding: 10px;
  text-shadow: 1px 1px 1px #fff;
}

.scroll-table thead tr {
  display:block;
}

.scroll-table td {
    border-top: thin solid;
    border-bottom: thin solid;
}

.scroll-table td:first-child {
    border-left: thin solid;
}

.scroll-table td:last-child {
    border-right: thin solid;
}

.scroll-table tr:first-child {
    display: none;
}

.delete_button {
    background-color: red;
    color: white;
}

.container {
  display: inline-block;
}

body {
  text-align: center;
}</code>```

<!DOCTYPE html>

  <link rel="stylesheet" href="test_table.css">

Dynamic Table

        <input type="text" />
        <input type="text" />
        <input type="button" class="delete_button" value="X" onclick="deleteRow(this)">

  <input type="button" value="Add" onclick="addRow('data')" />

```

Body:
If the width of the table won't change, you can set the width of the element (such as tbody) that contains the scrollbar > 100% (allowing extra space for the scrollbar) and set overflow-y to "overlay" (so that the scrollbar stays fixed, and won't shift the table left when it appears). Also set a fixed height for the element with the scrollbar, so the scrollbar will appear once the height is exceeded. Like so:

tbody {
  height: 100px;
  overflow-y: overlay;
  width: 105%
}

Note: you will have to manually adjust the width % as the % of space the scrollbar takes up will be relative to your table width (ie: smaller width of table, more % required to fit the scrollbar, as it's size in pixels is constant)

A dynamic table example:

function addRow(tableID)
{
    var table = document.getElementById(tableID);
    var rowCount = table.rows.length;
    var row = table.insertRow(rowCount);
    var colCount = table.rows[0].cells.length;

    for(var i=0; i<colCount; i++)
    {
        var newRow = row.insertCell(i);

        newRow.innerHTML = table.rows[0].cells[i].innerHTML;
        newRow.childNodes[0].value = "";
    }
}

function deleteRow(row)
{
    var table = document.getElementById("data");
    var rowCount = table.rows.length;
    var rowIndex = row.parentNode.parentNode.rowIndex;

    document.getElementById("data").deleteRow(rowIndex);
}

.scroll-table {
  border-collapse: collapse;
}

.scroll-table tbody {
  display:block;
  overflow-y:overlay;
  height:60px;
  width: 105%
}

.scroll-table tbody td {
  color: #333;
  padding: 10px;
  text-shadow: 1px 1px 1px #fff;
}

.scroll-table thead tr {
  display:block;
}

.scroll-table td {
    border-top: thin solid;
    border-bottom: thin solid;
}

.scroll-table td:first-child {
    border-left: thin solid;
}

.scroll-table td:last-child {
    border-right: thin solid;
}

.scroll-table tr:first-child {
    display: none;
}

.delete_button {
    background-color: red;
    color: white;
}

.container {
  display: inline-block;
}

body {
  text-align: center;
}

<!DOCTYPE html>
<html lang="en">
<head>
  <link rel="stylesheet" href="test_table.css">
</head>

<body>
<h1>Dynamic Table</h1>
<div class="container">

  <table id="data" class="scroll-table">
    <tbody>
      <tr>
        <td><input type="text" /></td>
        <td><input type="text" /></td>
        <td><input type="button" class="delete_button" value="X" onclick="deleteRow(this)"></td>
      </tr>
    </tbody>
  </table>

  <input type="button" value="Add" onclick="addRow('data')" />

</div>

<script src="test_table.js"></script>
</body>
</html>


问:
Bootstrap 4 - How to achieve this layout
I'm currently working on a website and I have come across with the following problem thinking the best practice to achieve the following layout using Bootstrap 4. (Wrapped in Red)

As you can see the first column is a col-md-7 and the other one is col-md-5. However, the first column includes an image and it has to touch the left corner of the page. However, the right column has to have the standard width and column size. To give you more insight following is what I'm trying to achieve.

```<code>[JS Fiddle][2]
</code>```

答:
You will need to wrap the left image and the right column in a row, set the column width for each, then place each item in the right column inside of that div with a full width.

I think if you continue to ask "do it for me" questions on SO you will get roasted, I know I have. But I'm here to help. LMK if you want more details.

There are a million solutions to this problem, This would be a great time to look into CSS Grid and learn the new new.

Here is a codepen of the general approach

```<code><div class="row">
  <div class="col-md-7 left-box"></div>

  <div class="col-md-5">
    <div class="col-md-12 item"></div>
    <div class="col-md-12 item"></div>
    <div class="col-md-12 item"></div>
  </div>
</div>
</code>```

Body:
I'm currently working on a website and I have come across with the following problem thinking the best practice to achieve the following layout using Bootstrap 4. (Wrapped in Red)

As you can see the first column is a col-md-7 and the other one is col-md-5. However, the first column includes an image and it has to touch the left corner of the page. However, the right column has to have the standard width and column size. To give you more insight following is what I'm trying to achieve.

[JS Fiddle][2]

Body:
You will need to wrap the left image and the right column in a row, set the column width for each, then place each item in the right column inside of that div with a full width.

I think if you continue to ask "do it for me" questions on SO you will get roasted, I know I have. But I'm here to help. LMK if you want more details.

There are a million solutions to this problem, This would be a great time to look into CSS Grid and learn the new new.

Here is a codepen of the general approach

<div class="row">
  <div class="col-md-7 left-box"></div>

  <div class="col-md-5">
    <div class="col-md-12 item"></div>
    <div class="col-md-12 item"></div>
    <div class="col-md-12 item"></div>
  </div>
</div>