问:
How to size a SingleChildScrollView dynamically inside a Column?
I'm having a bit of a problem with Flutter's widget placement. Here's the code:

```<code>import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;
  final _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        controller: _scrollController,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            SingleChildScrollView(
              scrollDirection: Axis.horizontal,
              controller: _scrollController,
              child: DataTable(
                //Rows and columns filled with random data
                columns: const <DataColumn>[
                  DataColumn(
                    label: Text(
                      'Name',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Age',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Role',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Name',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Age',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Role',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                ],
                rows: const <DataRow>[
                  DataRow(
                    cells: <DataCell>[
                      DataCell(Text('Sarah')),
                      DataCell(Text('19')),
                      DataCell(Text('Student')),
                      DataCell(Text('Sarah')),
                      DataCell(Text('19')),
                      DataCell(Text('Student')),
                    ],
                  ),
                  DataRow(
                    cells: <DataCell>[
                      DataCell(Text('Janine')),
                      DataCell(Text('43')),
                      DataCell(Text('Professor')),
                      DataCell(Text('Sarah')),
                      DataCell(Text('19')),
                      DataCell(Text('Student')),
                    ],
                  ),
                  DataRow(
                    cells: <DataCell>[
                      DataCell(Text('William')),
                      DataCell(Text('27')),
                      DataCell(Text('Associate Professor')),
                      DataCell(Text('Sarah')),
                      DataCell(Text('19')),
                      DataCell(Text('Student')),
                    ],
                  ),
                ],
              ),
            ),
            //How to make this widget be at the bottom?
            const Text('This widget should be at the bottom'),
          ],
        ),
      ),
    );
  }
}
</code>```

I have a DataTable and a Text widget, wrapped with a Column and two SingleChilScrollViews in order to have bidirectional scrolling (the table is larger than the screen). I want to place the Text widget on the bottom of the screen. Tinkering with the code, I can do it pretty easily by giving the Column widget a parent Container, and fixing its size to my screen. However, how would I go about sizing it dynamically? I've tried using MediaQuery but the result was not that accurate. This "fix" can be found below:

```<code>import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;
  final _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        controller: _scrollController,
        child: Container(
          width: MediaQuery.of(context).size.width,
          height: MediaQuery.of(context).size.height,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SingleChildScrollView(
                scrollDirection: Axis.horizontal,
                controller: _scrollController,
                child: DataTable(
                  //Rows and columns filled with random data
                  columns: const <DataColumn>[
                    DataColumn(
                      label: Text(
                        'Name',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Age',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Role',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Name',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Age',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Role',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                  ],
                  rows: const <DataRow>[
                    DataRow(
                      cells: <DataCell>[
                        DataCell(Text('Sarah')),
                        DataCell(Text('19')),
                        DataCell(Text('Student')),
                        DataCell(Text('Sarah')),
                        DataCell(Text('19')),
                        DataCell(Text('Student')),
                      ],
                    ),
                    DataRow(
                      cells: <DataCell>[
                        DataCell(Text('Janine')),
                        DataCell(Text('43')),
                        DataCell(Text('Professor')),
                        DataCell(Text('Sarah')),
                        DataCell(Text('19')),
                        DataCell(Text('Student')),
                      ],
                    ),
                    DataRow(
                      cells: <DataCell>[
                        DataCell(Text('William')),
                        DataCell(Text('27')),
                        DataCell(Text('Associate Professor')),
                        DataCell(Text('Sarah')),
                        DataCell(Text('19')),
                        DataCell(Text('Student')),
                      ],
                    ),
                  ],
                ),
              ),
              //How to make this widget be at the bottom?
              const Text('This widget should be at the bottom'),
            ],
          ),
        ),
      ),
    );
  }
}
</code>```

Any ideas or suggestions on how to tackle this issue? Thanks.

EDIT

Using the text in the bottomNavigationBar of the Scaffold works as well, however it doens't seem an appropriate solution.

```<code>import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;
  final _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: ListView(
        children: [
          SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: DataTable(
              //Rows and columns filled with random data
              columns: const <DataColumn>[
                DataColumn(
                  label: Text(
                    'Name',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Age',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Role',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Name',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Age',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Role',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
              ],
              rows: const <DataRow>[
                DataRow(
                  cells: <DataCell>[
                    DataCell(Text('Sarah')),
                    DataCell(Text('19')),
                    DataCell(Text('Student')),
                    DataCell(Text('Sarah')),
                    DataCell(Text('19')),
                    DataCell(Text('Student')),
                  ],
                ),
                DataRow(
                  cells: <DataCell>[
                    DataCell(Text('Janine')),
                    DataCell(Text('43')),
                    DataCell(Text('Professor')),
                    DataCell(Text('Sarah')),
                    DataCell(Text('19')),
                    DataCell(Text('Student')),
                  ],
                ),
                DataRow(
                  cells: <DataCell>[
                    DataCell(Text('William')),
                    DataCell(Text('27')),
                    DataCell(Text('Associate Professor')),
                    DataCell(Text('Sarah')),
                    DataCell(Text('19')),
                    DataCell(Text('Student')),
                  ],
                ),
              ],
            ),
          ),
        ],
      ),
      bottomNavigationBar: const Text('Is at the bottom - doesnt seem right'),
    );
  }
}
</code>```

答:
i think This might get you resolved your Error.

Code:

```<code>Scaffold(
      body:SizedBox(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        child: Column(
          children: [
            SizedBox(
              height: MediaQuery.of(context).size.height-100,
              width: MediaQuery.of(context).size.width,
              child: SingleChildScrollView(
                child: Column(
                  children: [
                    ///// your Scrollabel Data Table will be here
                    for(int i=0;i<20;i++)
                      ListTile(
                        title: Text('Tile $i'),
                      ),
                  ],
                ),
              ),
            ),
            const Align(
              alignment: Alignment.bottomCenter,
              child: Text('Hello I am at the Bottom'),
            ),
          ],
        ),
      ) ,)
</code>```

Body:
I'm having a bit of a problem with Flutter's widget placement. Here's the code:

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;
  final _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        controller: _scrollController,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            SingleChildScrollView(
              scrollDirection: Axis.horizontal,
              controller: _scrollController,
              child: DataTable(
                //Rows and columns filled with random data
                columns: const <DataColumn>[
                  DataColumn(
                    label: Text(
                      'Name',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Age',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Role',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Name',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Age',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                  DataColumn(
                    label: Text(
                      'Role',
                      style: TextStyle(fontStyle: FontStyle.italic),
                    ),
                  ),
                ],
                rows: const <DataRow>[
                  DataRow(
                    cells: <DataCell>[
                      DataCell(Text('Sarah')),
                      DataCell(Text('19')),
                      DataCell(Text('Student')),
                      DataCell(Text('Sarah')),
                      DataCell(Text('19')),
                      DataCell(Text('Student')),
                    ],
                  ),
                  DataRow(
                    cells: <DataCell>[
                      DataCell(Text('Janine')),
                      DataCell(Text('43')),
                      DataCell(Text('Professor')),
                      DataCell(Text('Sarah')),
                      DataCell(Text('19')),
                      DataCell(Text('Student')),
                    ],
                  ),
                  DataRow(
                    cells: <DataCell>[
                      DataCell(Text('William')),
                      DataCell(Text('27')),
                      DataCell(Text('Associate Professor')),
                      DataCell(Text('Sarah')),
                      DataCell(Text('19')),
                      DataCell(Text('Student')),
                    ],
                  ),
                ],
              ),
            ),
            //How to make this widget be at the bottom?
            const Text('This widget should be at the bottom'),
          ],
        ),
      ),
    );
  }
}

I have a DataTable and a Text widget, wrapped with a Column and two SingleChilScrollViews in order to have bidirectional scrolling (the table is larger than the screen). I want to place the Text widget on the bottom of the screen. Tinkering with the code, I can do it pretty easily by giving the Column widget a parent Container, and fixing its size to my screen. However, how would I go about sizing it dynamically? I've tried using MediaQuery but the result was not that accurate. This "fix" can be found below:

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;
  final _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        controller: _scrollController,
        child: Container(
          width: MediaQuery.of(context).size.width,
          height: MediaQuery.of(context).size.height,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SingleChildScrollView(
                scrollDirection: Axis.horizontal,
                controller: _scrollController,
                child: DataTable(
                  //Rows and columns filled with random data
                  columns: const <DataColumn>[
                    DataColumn(
                      label: Text(
                        'Name',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Age',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Role',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Name',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Age',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                    DataColumn(
                      label: Text(
                        'Role',
                        style: TextStyle(fontStyle: FontStyle.italic),
                      ),
                    ),
                  ],
                  rows: const <DataRow>[
                    DataRow(
                      cells: <DataCell>[
                        DataCell(Text('Sarah')),
                        DataCell(Text('19')),
                        DataCell(Text('Student')),
                        DataCell(Text('Sarah')),
                        DataCell(Text('19')),
                        DataCell(Text('Student')),
                      ],
                    ),
                    DataRow(
                      cells: <DataCell>[
                        DataCell(Text('Janine')),
                        DataCell(Text('43')),
                        DataCell(Text('Professor')),
                        DataCell(Text('Sarah')),
                        DataCell(Text('19')),
                        DataCell(Text('Student')),
                      ],
                    ),
                    DataRow(
                      cells: <DataCell>[
                        DataCell(Text('William')),
                        DataCell(Text('27')),
                        DataCell(Text('Associate Professor')),
                        DataCell(Text('Sarah')),
                        DataCell(Text('19')),
                        DataCell(Text('Student')),
                      ],
                    ),
                  ],
                ),
              ),
              //How to make this widget be at the bottom?
              const Text('This widget should be at the bottom'),
            ],
          ),
        ),
      ),
    );
  }
}

Any ideas or suggestions on how to tackle this issue? Thanks.

EDIT

Using the text in the bottomNavigationBar of the Scaffold works as well, however it doens't seem an appropriate solution.

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;
  final _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: ListView(
        children: [
          SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: DataTable(
              //Rows and columns filled with random data
              columns: const <DataColumn>[
                DataColumn(
                  label: Text(
                    'Name',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Age',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Role',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Name',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Age',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
                DataColumn(
                  label: Text(
                    'Role',
                    style: TextStyle(fontStyle: FontStyle.italic),
                  ),
                ),
              ],
              rows: const <DataRow>[
                DataRow(
                  cells: <DataCell>[
                    DataCell(Text('Sarah')),
                    DataCell(Text('19')),
                    DataCell(Text('Student')),
                    DataCell(Text('Sarah')),
                    DataCell(Text('19')),
                    DataCell(Text('Student')),
                  ],
                ),
                DataRow(
                  cells: <DataCell>[
                    DataCell(Text('Janine')),
                    DataCell(Text('43')),
                    DataCell(Text('Professor')),
                    DataCell(Text('Sarah')),
                    DataCell(Text('19')),
                    DataCell(Text('Student')),
                  ],
                ),
                DataRow(
                  cells: <DataCell>[
                    DataCell(Text('William')),
                    DataCell(Text('27')),
                    DataCell(Text('Associate Professor')),
                    DataCell(Text('Sarah')),
                    DataCell(Text('19')),
                    DataCell(Text('Student')),
                  ],
                ),
              ],
            ),
          ),
        ],
      ),
      bottomNavigationBar: const Text('Is at the bottom - doesnt seem right'),
    );
  }
}

Body:
i think This might get you resolved your Error.

Code:

Scaffold(
      body:SizedBox(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        child: Column(
          children: [
            SizedBox(
              height: MediaQuery.of(context).size.height-100,
              width: MediaQuery.of(context).size.width,
              child: SingleChildScrollView(
                child: Column(
                  children: [
                    ///// your Scrollabel Data Table will be here
                    for(int i=0;i<20;i++)
                      ListTile(
                        title: Text('Tile $i'),
                      ),
                  ],
                ),
              ),
            ),
            const Align(
              alignment: Alignment.bottomCenter,
              child: Text('Hello I am at the Bottom'),
            ),
          ],
        ),
      ) ,)


来源: stackexchange

问:
Object defined error in VBA - code continues to run afterwards
I am working on a report generating tool in Excel using OLAP data transcribed to pivottables. As using slicers in the past affected performance of the file very negatively, I am now attempting to implement it using macro's to set filter values. The code below sets a filter on the month level, using a year (FilterYear), month (FilterMonth), Pivottable name (PivotTable) and worksheet containing the table (SheetCase).

The problem I've been having is that, while iterating over the tables, I get random "object or application defined errors" on the first ".VisibleItemsList" statement. These do not always appear in the same iteration and furthermore, when I hit "continue" the macro just continues running until the next time this error pops up (also randomly). Continuing like this finishes the code and it will have done everything it's supposed to do, but the error messages are a real nuissance.

I found that using "with" statements could help resolve this issue (LINK), which is why I added the worksheet parameter in the sub (before I just used ActiveSheet), but this does not resolve the issue. Has anyone had any problems like this before? I am happy to provide more information if needed. Thank you very much in advace for any help you might be able to give.

```<code>Sub FilterPivotFieldMonth(FilterYear As Integer, FilterMonth As Integer, PivotTable As String, SheetCase As Worksheet)

' Macro to filter PivotTable according to FilterYear and FilterMonth
 With SheetCase
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Year]").VisibleItemsList = Array("")
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Month]").VisibleItemsList = Array( _
    "[Date and Time].[By Year].[Month].&[" & FilterMonth & " / " & FilterYear & "]")
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Date]").VisibleItemsList = Array("")
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Hour]").VisibleItemsList = Array("")
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Quarter Hour]").VisibleItemsList = Array("")
End With

End Sub
</code>```

答:
You should check if the filter in your pivot has the selection "multiple item" checked. filter

If it is unchecked probably you cannot use the method .Visibleitemlist and that might cause an error.

ContentLicense: CC BY-SA 4.0

Body:
I am working on a report generating tool in Excel using OLAP data transcribed to pivottables. As using slicers in the past affected performance of the file very negatively, I am now attempting to implement it using macro's to set filter values. The code below sets a filter on the month level, using a year (FilterYear), month (FilterMonth), Pivottable name (PivotTable) and worksheet containing the table (SheetCase).

The problem I've been having is that, while iterating over the tables, I get random "object or application defined errors" on the first ".VisibleItemsList" statement. These do not always appear in the same iteration and furthermore, when I hit "continue" the macro just continues running until the next time this error pops up (also randomly). Continuing like this finishes the code and it will have done everything it's supposed to do, but the error messages are a real nuissance.

I found that using "with" statements could help resolve this issue (LINK), which is why I added the worksheet parameter in the sub (before I just used ActiveSheet), but this does not resolve the issue. Has anyone had any problems like this before? I am happy to provide more information if needed. Thank you very much in advace for any help you might be able to give.

Sub FilterPivotFieldMonth(FilterYear As Integer, FilterMonth As Integer, PivotTable As String, SheetCase As Worksheet)

' Macro to filter PivotTable according to FilterYear and FilterMonth
 With SheetCase
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Year]").VisibleItemsList = Array("")
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Month]").VisibleItemsList = Array( _
    "[Date and Time].[By Year].[Month].&[" & FilterMonth & " / " & FilterYear & "]")
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Date]").VisibleItemsList = Array("")
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Hour]").VisibleItemsList = Array("")
    .PivotTables(PivotTable).PivotFields( _
    "[Date and Time].[By Year].[Quarter Hour]").VisibleItemsList = Array("")
End With

End Sub


问:
Error with prettier in ReactJS app: Expected atom at position 0
I am trying to deploy my ReactJS app (note: branch is custom_section_formatter) on Netlify. Previously everything worked fine, but today after making some changes I keep getting this error:

4:54:51 PM: ./node_modules/prettier/standalone.js

4:54:51 PM: SyntaxError: /opt/build/repo/apps/live-paper-builder/node_modules/prettier/standalone.js: Expected atom at position 0

4:54:51 PM:     {{(.+?)}}

4:54:51 PM:     ^

4:54:51 PM: error Command failed with exit code 1.

From everything I have searched on the web, it seems to be related to a BabelJS issue, but that apparently has been resolved. So not sure why I still get this error.
My build logs are here. I am obviously doing something wrong, but not sure what.

答:
This problem can be fixed by using an older version of the 'prettier' package. Specifically

```<code>"prettier": "<=2.3.0",
</code>```

in the 'dependencies' section of your package.json file

Found a related query here and its related PR, which helped resolve this.

Body:
This problem can be fixed by using an older version of the 'prettier' package. Specifically

"prettier": "<=2.3.0",

in the 'dependencies' section of your package.json file

Found a related query here and its related PR, which helped resolve this.


问:
Font in footer changes despite footer already having CSS class declared
I have a design which uses DIV with flex, at https://jsfiddle.net/1s2mpba6/, but the main problem here relates to use of webfonts, one area, despite not having a webfont, seems to have been replaced even though the body font is used.

I get this when it should be Helvetica:

These are the areas of the HTML and CSS which seem to be problematic:

header.california-m {
  background-color: #B22222;
  border-radius: 10px;
  color: #FFF;
  padding: 30px;
  width: 840px;
}

footer.california-m {
  background-color: #333;
  color: #FFF;
  padding: 30px;
  width: 840px;
  margin-bottom: 20px;
}

footer.california-m h2 {
  margin-left: 20px;
}

@font-face {
  font-family: Fabriga Regular;
  src: url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.eot?v=1.1.0");
  src: url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.eot?#iefix&v=1.1.0") format("embedded-opentype"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.woff2?v=1.1.0") format("woff2"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.woff?v=1.1.0") format("woff"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.ttf?v=1.1.0") format("truetype"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.svg?v=1.1.0#Regular") format("svg");
  font-weight: 400;
  font-style: normal
}

@font-face {
  font-family: Fabriga Medium;
  src: url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.eot?v=1.1.0");
  src: url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.eot?#iefix&v=1.1.0") format("embedded-opentype"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.woff2?v=1.1.0") format("woff2"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.woff?v=1.1.0") format("woff"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.ttf?v=1.1.0") format("truetype"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.svg?v=1.1.0#Medium") format("svg");
  font-weight: 400;
  font-style: normal
}

@font-face {
  font-family: ATVFabriga;
  src: url("https://c.atcdn.co.uk/fonts/ATVFabriga.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
}

.columns-vehicleresult+h1,
h2,
h3 {
  font-family: Fabriga Regular, Helvetica, sans-serif;
}

.columns-vehicleresult .column p.autog1 {
  font-family: Fabriga Regular, Helvetica, sans-serif;
}

.columns-vehicleresult .column p.autog1 b {
  line-height: 16px;
}

.atc-type-picanto {
  font-family: ATVFabriga, Helvetica, sans-serif;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><footer class="california-m">
  <h2>1 Anytown Road, Anytown 1</h2>
  <h2>☎ 555 0100</h2>
</footer></code>```

However, I've not used a font-family for header or footer so why is this only happening to the footer and what do I need to fix?

Functionally, it works well, aesthetically, it's a small thing to fix, advice welcomed!

It should be in Helvetica as with the rest of the text for body declared in CSS, apart from the .columns-vehicle-result which use a webfont.

答:
The content of your footer are two h2 elements, and the rule with selector .columns-vehicleresult + h1, h2, h3 applies to those.

If the formatting of that rule is supposed to only apply to headline elements that immediately follow a .columns-vehicleresult, for all three of those headline levels - then this would need to become

```<code>.columns-vehicleresult + h1, .columns-vehicleresult + h2, .columns-vehicleresult + h3 { }
</code>```

Body:
I have a design which uses DIV with flex, at https://jsfiddle.net/1s2mpba6/, but the main problem here relates to use of webfonts, one area, despite not having a webfont, seems to have been replaced even though the body font is used.

I get this when it should be Helvetica:

These are the areas of the HTML and CSS which seem to be problematic:

header.california-m {
  background-color: #B22222;
  border-radius: 10px;
  color: #FFF;
  padding: 30px;
  width: 840px;
}

footer.california-m {
  background-color: #333;
  color: #FFF;
  padding: 30px;
  width: 840px;
  margin-bottom: 20px;
}

footer.california-m h2 {
  margin-left: 20px;
}

@font-face {
  font-family: Fabriga Regular;
  src: url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.eot?v=1.1.0");
  src: url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.eot?#iefix&v=1.1.0") format("embedded-opentype"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.woff2?v=1.1.0") format("woff2"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.woff?v=1.1.0") format("woff"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.ttf?v=1.1.0") format("truetype"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Regular.svg?v=1.1.0#Regular") format("svg");
  font-weight: 400;
  font-style: normal
}

@font-face {
  font-family: Fabriga Medium;
  src: url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.eot?v=1.1.0");
  src: url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.eot?#iefix&v=1.1.0") format("embedded-opentype"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.woff2?v=1.1.0") format("woff2"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.woff?v=1.1.0") format("woff"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.ttf?v=1.1.0") format("truetype"), url("https://c.atcdn.co.uk/fonts/ATFabriga-Medium.svg?v=1.1.0#Medium") format("svg");
  font-weight: 400;
  font-style: normal
}

@font-face {
  font-family: ATVFabriga;
  src: url("https://c.atcdn.co.uk/fonts/ATVFabriga.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
}

.columns-vehicleresult+h1,
h2,
h3 {
  font-family: Fabriga Regular, Helvetica, sans-serif;
}

.columns-vehicleresult .column p.autog1 {
  font-family: Fabriga Regular, Helvetica, sans-serif;
}

.columns-vehicleresult .column p.autog1 b {
  line-height: 16px;
}

.atc-type-picanto {
  font-family: ATVFabriga, Helvetica, sans-serif;
}

1 Anytown Road, Anytown 1

☎ 555 0100

However, I've not used a font-family for header or footer so why is this only happening to the footer and what do I need to fix?

Functionally, it works well, aesthetically, it's a small thing to fix, advice welcomed!

It should be in Helvetica as with the rest of the text for body declared in CSS, apart from the .columns-vehicle-result which use a webfont.

Body:
The content of your footer are two h2 elements, and the rule with selector .columns-vehicleresult + h1, h2, h3 applies to those.

If the formatting of that rule is supposed to only apply to headline elements that immediately follow a .columns-vehicleresult, for all three of those headline levels - then this would need to become

.columns-vehicleresult + h1, .columns-vehicleresult + h2, .columns-vehicleresult + h3 { }


答: did you try to use BottomSheetNavigtor?</p>

Title: How to size a SingleChildScrollView dynamically inside a Column?

Body: did you try to use BottomSheetNavigtor?


问:
How to call another function within the same object?
```<code>let role = {
    test: (variable) => {
        // How do I call toLog(variable) from here?
    },
    toLog: (variable) => {
        console.log(variable);
    }
};
</code>```

I'd like to call the toLog() function within the test() function but I'm unaware how to.

答:
Since you are using arrow functions, using this here will not work but you have your object referenced as role so you can call the function as role.toLog from your another function i.e. test as shown below

let role = {
    test: (variable) => {
        // How do I call toLog(variable) from here?
        role.toLog(`${variable} from test`);
    },
    toLog: (variable) => {
        console.log(variable);
    }
};

role.test('hello world');```

ContentLicense: CC BY-SA 3.0

Body:
let role = {
    test: (variable) => {
        // How do I call toLog(variable) from here?
    },
    toLog: (variable) => {
        console.log(variable);
    }
};

I'd like to call the toLog() function within the test() function but I'm unaware how to.


问:
What a struct/class has to implement to work with many (if not all) STL features when it's inside a container?
For example, if I have a struct to hold some information like this:

struct Two {
  int a, b;
}

```
<p>I don't want to use a tuple and I can't use C++20 and <code><=></code> (the highest I can go is C++17).</p>
<p>Then what is the minimum set of operand overloads (and other functions) I have to implement to make it work with all (or most of the) STL algorithms and containers?</p>
<p>If I will assume the user will <strong>not</strong> do any operation on his own, like these:</p>
<pre class="lang-cpp prettyprint-override"><code>Two a(1,2);
Two b(2,3);
const float c = 1.4;

a *= b;
a *= 2;
a += c;
</code>```

And I do not want to provide anything extra implementation for the user's convenience, only to support the STL.

Is there a documentation page similar to https://www.cplusplus.com/reference/stl/ summarizing them in one document and what they need to have implemented to function?

答:
Note: Yes for this example using a Tuple<int, int> would be more suiting

I disagree. Tuple lacks the ability to give a name for the type and for the members. That is a significant drawback in most cases.

Let's give it default and initializing constructors:

```<code>  Two(void): a(0), b(0) {
  }

  Two(int x, int y): a(x), b(y) {
  }
</code>```

I recommend against this in most cases. Aggregate classes are useful.

have to implement my hashFunction. If I understand it correctly that applies to set, map and unordered_map.

No, you don't need a hash function for set nor map. You only need a hash function for unordered containers. For set and map, the keys must be orderable instead.

If I then use this unordered_set, but want to order it:

```<code>std::unordered_set<Two, hashFunction> exist;
std::sort(exist.begin(), exist.end());
</code>```

This isn't possible. You cannot sort unordered containers (the clue is in the name). The iterators of the set are const.

Then I have to implement the - operator so it can compare the diff to know if it's bigger/smaller.

Subtraction operator isn't necessary to sort objects. What you need is a way to compare them. This can be done with a less-than operator, but it isn't necessary since you may use a comparison functor instead (just like you used a hash functor in your example).

If I want to use .find on this set:

```<code>auto it = exist.find(Two(i, index)
</code>```

Then I have to implement the == operator:

Equality comparison is a general requirement of the unordered containers whether you want to use find or not. The equality operator isn't required if you use an equality comparator functor instead.

then how I could know what to implement in the advance?

You don't need to know, because the standard containers and algorithms support custom functors for all such functionality. The user of the class can implement those in any way they prefer.

But you can implement all the operators expected from regular types for convenience of the user of the class. I recommend adding all relational operators like this (C++20 required):

```<code>struct Two {
    int a, b;
    friend auto operator<=>(const Two&, const Two&) = default;
};
</code>```

In general, you can know what standard library containers and algorithms require by reading their documentation.

if we are using at max C++17 ?

Then you must implement each comparison operator explicitly. Only less-than and equality are used by standard library containers, but it's convenient to have all. You can reduce boilerplate by using a base class such as those from Boost.Operators library.

Body:
For example, if I have a struct to hold some information like this:

struct Two {
  int a, b;
}

I don't want to use a tuple and I can't use C++20 and <=> (the highest I can go is C++17).

Then what is the minimum set of operand overloads (and other functions) I have to implement to make it work with all (or most of the) STL algorithms and containers?

If I will assume the user will not do any operation on his own, like these:

Two a(1,2);
Two b(2,3);
const float c = 1.4;

a *= b;
a *= 2;
a += c;

And I do not want to provide anything extra implementation for the user's convenience, only to support the STL.

Is there a documentation page similar to https://www.cplusplus.com/reference/stl/ summarizing them in one document and what they need to have implemented to function?

Body:
Note: Yes for this example using a Tuple<int, int> would be more suiting

I disagree. Tuple lacks the ability to give a name for the type and for the members. That is a significant drawback in most cases.

Let's give it default and initializing constructors:

  Two(void): a(0), b(0) {
  }

  Two(int x, int y): a(x), b(y) {
  }

I recommend against this in most cases. Aggregate classes are useful.

have to implement my hashFunction. If I understand it correctly that applies to set, map and unordered_map.

No, you don't need a hash function for set nor map. You only need a hash function for unordered containers. For set and map, the keys must be orderable instead.

If I then use this unordered_set, but want to order it:

std::unordered_set<Two, hashFunction> exist;
std::sort(exist.begin(), exist.end());

This isn't possible. You cannot sort unordered containers (the clue is in the name). The iterators of the set are const.

Then I have to implement the - operator so it can compare the diff to know if it's bigger/smaller.

Subtraction operator isn't necessary to sort objects. What you need is a way to compare them. This can be done with a less-than operator, but it isn't necessary since you may use a comparison functor instead (just like you used a hash functor in your example).

If I want to use .find on this set:

auto it = exist.find(Two(i, index)

Then I have to implement the == operator:

Equality comparison is a general requirement of the unordered containers whether you want to use find or not. The equality operator isn't required if you use an equality comparator functor instead.

then how I could know what to implement in the advance?

You don't need to know, because the standard containers and algorithms support custom functors for all such functionality. The user of the class can implement those in any way they prefer.

But you can implement all the operators expected from regular types for convenience of the user of the class. I recommend adding all relational operators like this (C++20 required):

struct Two {
    int a, b;
    friend auto operator<=>(const Two&, const Two&) = default;
};

In general, you can know what standard library containers and algorithms require by reading their documentation.

if we are using at max C++17 ?

Then you must implement each comparison operator explicitly. Only less-than and equality are used by standard library containers, but it's convenient to have all. You can reduce boilerplate by using a base class such as those from Boost.Operators library.


问:
How to query for installed "packaged COM" extension points
I work on a plugin-based application that is currently scanning the Windows registry for compatible COM servers that expose certain "Implemented Categories" entries. This works well for "regular" COM servers installed through MSI installers.

However, I'm now facing a problem with COM servers installed through MSIX installers that expose COM extension points through the "Packaged COM" catalog as described in https://blogs.windows.com/windowsdeveloper/2017/04/13/com-server-ole-document-support-desktop-bridge/ . These COM servers can still be instantiated through CoCreateInstance, but RegOpenKey/RegEnumKey searches aren't able to detect their presence.

I'm not sure how to approach this problem. The best outcome would be some sort of Windows API for querying the "Packaged COM" catalog for installed COM servers that I can run in addition to the registry search. However, I don't know if that even exist? I'm also open for other suggestions, as long as they still allows my application to dynamically detect the presence of new COM-based plugins.

答:
Answering myself with sample code to query all installed COM servers, including the "Packaged COM" catalog, using ICatInformation::EnumClassesOfCategories. Based on suggestion by Aditi_Narvekar:</p>
```<code>#include <atlstr.h>
#include <vector>

static void CHECK(HRESULT hr) {
    if (FAILED(hr))
        abort(); // TODO: More graceful error handling
}

/** Return COM classes that implement any of the provided "Implemented Categories". */
inline std::vector<CLSID> GetClassesWithAnyOfCategories(std::vector<CATID> impl_categories) {
    CComPtr<ICatInformation> cat_search;
    CHECK(cat_search.CoCreateInstance(CLSID_StdComponentCategoriesMgr));

    CComPtr<IEnumGUID> class_list;
    CHECK(cat_search->EnumClassesOfCategories((ULONG)impl_categories.size(), impl_categories.data(), -1, nullptr, &class_list));

    std::vector<CLSID> app_clsids;
    app_clsids.reserve(64);
    for (;;) {
        CLSID cur_cls = {};
        ULONG num_read = 0;
        CHECK(class_list->Next(1, &cur_cls, &num_read));
        if (num_read == 0)
            break;

        // can also call ProgIDFromCLSID to get the ProgID
        // can also call OleRegGetUserType to get the COM class name

        app_clsids.push_back(cur_cls);
    }

    return app_clsids;
}
</code>```

Body:
Answering myself with sample code to query all installed COM servers, including the "Packaged COM" catalog, using ICatInformation::EnumClassesOfCategories. Based on suggestion by Aditi_Narvekar:

#include <atlstr.h>
#include <vector>

static void CHECK(HRESULT hr) {
    if (FAILED(hr))
        abort(); // TODO: More graceful error handling
}

/** Return COM classes that implement any of the provided "Implemented Categories". */
inline std::vector<CLSID> GetClassesWithAnyOfCategories(std::vector<CATID> impl_categories) {
    CComPtr<ICatInformation> cat_search;
    CHECK(cat_search.CoCreateInstance(CLSID_StdComponentCategoriesMgr));

    CComPtr<IEnumGUID> class_list;
    CHECK(cat_search->EnumClassesOfCategories((ULONG)impl_categories.size(), impl_categories.data(), -1, nullptr, &class_list));

    std::vector<CLSID> app_clsids;
    app_clsids.reserve(64);
    for (;;) {
        CLSID cur_cls = {};
        ULONG num_read = 0;
        CHECK(class_list->Next(1, &cur_cls, &num_read));
        if (num_read == 0)
            break;

        // can also call ProgIDFromCLSID to get the ProgID
        // can also call OleRegGetUserType to get the COM class name

        app_clsids.push_back(cur_cls);
    }

    return app_clsids;
}


问:
Polar plot: Modify digit precision in Y-axis label
I can't seem to be able to modify the digit precision of the Y-axis label values in a polar plot.  I am pretty sure the long labels shown in the image below are the Y-axis, but just in case, neither of the following two lines has any effect on digit precision.  Is there another form of syntax required for changing these axis labels in polar plots?

```<code> chart1.ChartAreas(k - 1).AxisX.LabelStyle.Format = "N2"
 chart1.ChartAreas(k - 1).AxisY.LabelStyle.Format = "N2"
</code>```

答:
This should work:</p>
```<code>chart1.ChartAreas(k - 1).AxisX.LabelStyle.Format = "0.00";
</code>```

Body:
I can't seem to be able to modify the digit precision of the Y-axis label values in a polar plot.  I am pretty sure the long labels shown in the image below are the Y-axis, but just in case, neither of the following two lines has any effect on digit precision.  Is there another form of syntax required for changing these axis labels in polar plots?

 chart1.ChartAreas(k - 1).AxisX.LabelStyle.Format = "N2"
 chart1.ChartAreas(k - 1).AxisY.LabelStyle.Format = "N2"

Body:
This should work:

chart1.ChartAreas(k - 1).AxisX.LabelStyle.Format = "0.00";


问:
TopMost form in a thread?
I am using the following code to open a form in a new thread:

```<code>private void button1_Click(object sender, EventArgs e)
{

    Thread thread = new Thread(ThreadProc);
    thread.Start();
}

public void ThreadProc()
{

    Form form = new Form();
    form.TopMost = true;
    form.ShowDialog();
}
</code>```

But the newly created form isn't TopMost even though I set it to true.

How can I make a form in a thread TopMost ?

答:
Just ran into this problem myself. It seems that if the form has an Owner, then TopMost works as expected. If the owning form was created on another thread, though, it's a little tricky to set. Here's what I used:

```<code>var form = new Form();

form.Shown += (sender, e) => {
    Control.CheckForIllegalCrossThreadCalls = false;
    form.Owner = /* Owning form here */;
    form.CenterToParent();      // Not necessary
    Control.CheckForIllegalCrossThreadCalls = true;

    form.TopMost = true;        // Works now!
};

Application.Run(form);
</code>```

ContentLicense: CC BY-SA 2.5

Title: TopMost form in a thread?

Body:
I am using the following code to open a form in a new thread:

private void button1_Click(object sender, EventArgs e)
{

    Thread thread = new Thread(ThreadProc);
    thread.Start();
}

public void ThreadProc()
{

    Form form = new Form();
    form.TopMost = true;
    form.ShowDialog();
}

But the newly created form isn't TopMost even though I set it to true.

How can I make a form in a thread TopMost ?

Body:
Just ran into this problem myself. It seems that if the form has an Owner, then TopMost works as expected. If the owning form was created on another thread, though, it's a little tricky to set. Here's what I used:

var form = new Form();

form.Shown += (sender, e) => {
    Control.CheckForIllegalCrossThreadCalls = false;
    form.Owner = /* Owning form here */;
    form.CenterToParent();      // Not necessary
    Control.CheckForIllegalCrossThreadCalls = true;

    form.TopMost = true;        // Works now!
};

Application.Run(form);


问:
IntelliJ cannot resolve symbol 'NULL' in JPA @Query
In any @Query in a Spring Repository, IntelliJ inspection is highlighting NULL with a red underline, saying "Cannot resolve symbol 'NULL'". Note that changing the case to all lowercase doesn't to fix it. After checking similar posts I did ensure I have the JPA & Spring facets configured properly.

Note this isn't actually an issue at runtime or compile time; everything actually works fine. It's just annoying/distracting seeing the highlights in IntelliJ. Does anyone know how to resolve this, or why it is happening?

Below is a minimal example showing the issue.

I am using

IntelliJ Ultimate 2021.3.2

spring-data-jpa 2.3.4.RELEASE

openjdk 11

答:
Set the nativeQuery attribute to true, something like:

```<code>@Query(nativeQuery=true,value="")
</code>```

Body:
Set the nativeQuery attribute to true, something like:

@Query(nativeQuery=true,value="")


问:
PHP - How to install PDO driver? (Windows)
I am setting up PHP and MySQL (Maria DB) on Windows 8.1. I edited php.ini file and uncommented the following lines:

```<code>extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
</code>```

But unfortunately I cannot connect to database because there are no pdo drivers shown in phpinfo output. So, when I try to establish database connection, an exception is thrown:

```<code>Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'
</code>```

How can this problem be solved?

答:
In the php.ini file, just below ;On Windows, uncomment 'extension_dir = "ext"'

It worked for me.

Body:
I am setting up PHP and MySQL (Maria DB) on Windows 8.1. I edited php.ini file and uncommented the following lines:

extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll

But unfortunately I cannot connect to database because there are no pdo drivers shown in phpinfo output. So, when I try to establish database connection, an exception is thrown:

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'

How can this problem be solved?


问:
AWS SES how to deliberately delay sending an email
Is there an option in AWS to deliberately delay sending an email?
I mean is it possible to tell AWS to send this email after 5 or 10 or 30 minutes when we call the AmazonSimpleEmailService library?

答:
ideally NO !!!

Amazon SES attempts to deliver emails to the Internet within a few seconds of each request.

code in lambda can be delayed using any of the time based libraries but the problem is when to invoke lambda or what will invoke lambda.For this
, you can use sqs with lambda.

send the request to sqs queue

you will know when request has come. this will act as a

execute lambda after your desire time

source faq


问:
Why doesn't Console.WriteLine work in Visual Studio Code?
I have scriptcs and coderunner installed on Visual Studio Code. When I run a simple program that includes Console.WriteLine("Test") I don't see any output. The program seems to run successfully and exits with code 0.

Any suggestions?

Here's all the code in case anyone is interested:

```<code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Test");
    }
}
</code>```

答: An alternative would be to use Debug.WriteLine("test") instead, it writes to the immediate window. Needs using System.Diagnostics</p>

Body:
I have scriptcs and coderunner installed on Visual Studio Code. When I run a simple program that includes Console.WriteLine("Test") I don't see any output. The program seems to run successfully and exits with code 0.

Any suggestions?

Here's all the code in case anyone is interested:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Test");
    }
}


问:
how can i update a specific object property within an array in firebase
im having trouble updating the quantity property in my angular-firebase project

```<code>chosenMeal(meal,price,quantity){
  for (let i = 0; i < this.order.length; i++) {
        const element = this.order[i];
        if(element.meal != meal){
          this.db.collection('tables').doc(this.table.propertyId).update({order:({meal,price,quantity})})
        }else{
        // my question
  }
}
</code>```

so the logic is like this if the chosen meal isn't in the order array then add it to the order array in firebase, else if the meal exists on the order array just increment the quantity, i don't know how to update just the quantity in the order object in firebase, or i don't know how to access only the one property in a firebase object

答:
Unfortunately you can't update a single property of an object within an array. You can't even update a single index of an array for that matter. You need to get the entire array, modify it, then put it back. There are the arrayUnion() and arrayRemove() but those are for inserting and removing unique values.

You could use a firestore sub-collection rather than an array, so each order would be a document. You could then use the increment function: https://firebase.google.com/docs/firestore/manage-data/add-data#increment_a_numeric_value

Body:
im having trouble updating the quantity property in my angular-firebase project

chosenMeal(meal,price,quantity){
  for (let i = 0; i < this.order.length; i++) {
        const element = this.order[i];
        if(element.meal != meal){
          this.db.collection('tables').doc(this.table.propertyId).update({order:({meal,price,quantity})})
        }else{
        // my question
  }
}

so the logic is like this if the chosen meal isn't in the order array then add it to the order array in firebase, else if the meal exists on the order array just increment the quantity, i don't know how to update just the quantity in the order object in firebase, or i don't know how to access only the one property in a firebase object


问:
Resize and drag issues with jQuery dialog over iFrame
I am using jQuery dialogs over an iframe in my webpage and the resizing and dragging does not work as expected.

What it does, is it stops working when your mouse gets outside of the window, which is quite annoying because it happens really fast. This happens by both dragging and resizing of the dialogs.

Here is a small skeleton in which I was able to reproduce the problem:

```<code><!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="jquery-ui-1.8.15.css" />
    <script src="jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="jquery-ui-1.8.15.min.js"  type="text/javascript"></script>
    <script>
    $(function() {
        $("#awesomewindow").dialog();
    });
    </script>
</head>
<body style="background-color: red; margin: 0px; padding: 0px;">
    <div id="awesomewindow">
        Window content here!
    </div>
    <div style="position: absolute; width: 100%; height: 100%; overflow: hidden">
        <iframe src="Blue.html" frameborder="0" scrolling="no" height="100%" width="100%" />
    </div>
</body>
</html>
</code>```

I think the iframe just steals the focus, but I have no idea how to fix this.

Thanks for watching!

答:
set these two parameters to make it work:</p>

```<code>$(function () {
        $("#awesomewindow").dialog({
            iframe: true,
            modal : true
        });
    });
</code>```

Body:
I am using jQuery dialogs over an iframe in my webpage and the resizing and dragging does not work as expected.

What it does, is it stops working when your mouse gets outside of the window, which is quite annoying because it happens really fast. This happens by both dragging and resizing of the dialogs.

Here is a small skeleton in which I was able to reproduce the problem:

<!DOCTYPE html>

    <link rel="stylesheet" type="text/css" href="jquery-ui-1.8.15.css" />

        Window content here!

I think the iframe just steals the focus, but I have no idea how to fix this.

Thanks for watching!

Body:
set these two parameters to make it work:

$(function () {
        $("#awesomewindow").dialog({
            iframe: true,
            modal : true
        });
    });


问:
How to apply 2 regex patterns simultaneously in grep
I would like to check for 2 patterns across a piece of text (a total of 4 delimiters).

Either one of the two patterns matches is fine.  However when they qualify, I would like the results to be next to each other side by side.

This is the INPUT TEXT (it contains two separate long lines. Actual input text is much more. I have chosen relevent snippets as shown below):

```<code>Query Response #5: [2659] ID,(0010,0030) DA #8 [19801024] PatientÆs Birth Date,,,(0020,000D) UI #42 Station Title,,,>(0040,0002) DA #8 [20301212] Scheduled Procedure Step Start Date,,,>(0040,0003) TM #4Information

Query Response #6: ID, (0010,0030) DA #8 [19410203] PatientÆs Birth Date, Title,,,>(0040,0002) DA #8 [20210826] Scheduled Procedure Step Start Date, FIND]
</code>```

This is the DESIRED OUTPUT:

```<code>19801024 20301212
19410203 20210826
</code>```

There are 2 pairs of delimiters. The 1st set of delimiters is this:

```<code>(0010,0030) DA #8 [
] Patient
</code>```

The 2nd set of delimiters is this:

```<code>(0040,0002) DA #8 [
] Scheduled Procedure Step Start Date
</code>```

I am able to apply each pair of delimiter by itself.  Specifically, when I do this:

```<code>grep -o -P "(?<=0010,0030\) DA #8 \[).*(?=\] Patient)"
</code>```

I get this output:

```<code>19801024
19410203
</code>```

When I apply this 2nd pair of delimiter like this below:

```<code>grep -o -P "(?<=0040,0002\) DA #8 \[).*(?=\] Scheduled Procedure Step Start Date)"
</code>```

I get this output:

```<code>20301212
20210826
</code>```

How do I issue a correct combined grep command such that the output result is as shown below? :

```<code>19801024 20301212
19410203 20210826
</code>```

I tried this following approach without success:

```<code>grep -e "(?<=0040,0002\) DA #8 \[).*(?=\] Scheduled Procedure Step Start Date)" -e "(?<=0010,0030\) DA #8 \[).*(?=\] Patient)"
</code>```

The error message I get is follows:

```<code>grep: Unmatched ) or \)
</code>```

Thanks in advance. I hope my question is clear.  (Please note I'm using grep under Windows10. The outer quatations marks have to be double quotation marks)

Body:
I would like to check for 2 patterns across a piece of text (a total of 4 delimiters).

Either one of the two patterns matches is fine.  However when they qualify, I would like the results to be next to each other side by side.

This is the INPUT TEXT (it contains two separate long lines. Actual input text is much more. I have chosen relevent snippets as shown below):

Query Response #5: [2659] ID,(0010,0030) DA #8 [19801024] PatientÆs Birth Date,,,(0020,000D) UI #42 Station Title,,,>(0040,0002) DA #8 [20301212] Scheduled Procedure Step Start Date,,,>(0040,0003) TM #4Information

Query Response #6: ID, (0010,0030) DA #8 [19410203] PatientÆs Birth Date, Title,,,>(0040,0002) DA #8 [20210826] Scheduled Procedure Step Start Date, FIND]

This is the DESIRED OUTPUT:

19801024 20301212
19410203 20210826

There are 2 pairs of delimiters. The 1st set of delimiters is this:

(0010,0030) DA #8 [
] Patient

The 2nd set of delimiters is this:

(0040,0002) DA #8 [
] Scheduled Procedure Step Start Date

I am able to apply each pair of delimiter by itself.  Specifically, when I do this:

grep -o -P "(?<=0010,0030\) DA #8 \[).*(?=\] Patient)"

I get this output:

19801024
19410203

When I apply this 2nd pair of delimiter like this below:

grep -o -P "(?<=0040,0002\) DA #8 \[).*(?=\] Scheduled Procedure Step Start Date)"

I get this output:

20301212
20210826

How do I issue a correct combined grep command such that the output result is as shown below? :

19801024 20301212
19410203 20210826

I tried this following approach without success:

grep -e "(?<=0040,0002\) DA #8 \[).*(?=\] Scheduled Procedure Step Start Date)" -e "(?<=0010,0030\) DA #8 \[).*(?=\] Patient)"

The error message I get is follows:

grep: Unmatched ) or \)

Thanks in advance. I hope my question is clear.  (Please note I'm using grep under Windows10. The outer quatations marks have to be double quotation marks)

Body:
This is actually job for sed more than grep:

sed -E 's/.*\(0010,0030\) DA #8 \[([^]]+)\] Patient.*\(0040,0002\) DA #8 \[([^]]+)\] Scheduled Procedure Step Start Date.*/\1 \2/' file

19801024 20301212
19410203 20210826


问:
awk/sed replace multiple newlines in the record except end of record
I have file where:

field delimiter is \x01

the record delimiter is \n

Some lines contain multiple newlines I need to remove them, however I don't want to remove the legitimate newlines at the end of each lines. I have tried this with awk:

```<code>awk -F '\x01' 'NF < 87 {getline s; $0 = $0 s} 1' infile > outfile
</code>```

But this is only working when the line contains one newline in the record (except end of line newline). This does not work for multiple newlines.

Note: the record contains 87 fields.

What am I doing wrong here?

Example of file:

```<code>PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000
test^A00000000
 Test^A^A^A^A
PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000
test^A00000000
 Test^A^A^A^A
SL^ANov-21^A30-11-2021^AB^A0000^A1234567^A00000
test^A12102120^A00000^A00^A^A
</code>```

NOTE: The file contains 11 fields; field separate \x01; record separator \n

Expected result:

```<code>PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000test^A00000000 Test^A^A^A^A
PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000test^A00000000 Test^A^A^A^A
SL^ANov-21^A30-11-2021^AB^A0000^A1234567^A00000test^A12102120^A00000^A00^A^A
</code>```

Note: I need to preserve the field delimiter (\x01) and record delimiter (\n)

Thank you very much in advance for looking into this.

The file always contains 87 fields;
The fild delimiter is '\x01', but when viewing in Linux it is represented as '^A'
Some lines contain newlines - I need to remove them, but I don't want to remove the legitimate newlines at the end of each line.
The newline appears twice in the 1st and second record and once in third record - this are the newlines I want to remove.

In the examples/expected results there are 11 delimiters "x01" represented as "^A",
I expect to have 3 records and not 6, i.e.:

First record:

test^A00000000 should be joined to the previous line

Test^A^A^A^A should be joined to the first line as well

forming one record:

PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000test^A00000000 Test^A^A^A^A

Second record

test^A00000000 should be joined to the previous line

Test^A^A^A^A should be joined to that previous line as well

forming one record:

PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000test^A00000000 Test^A^A^A^A

Third record:

test^A12102120^A00000^A00^A^A should be joined to the previous line

forming one record:

SL^ANov-21^A30-11-2021^AB^A0000^A1234567^A00000test^A12102120^A00000^A00^A^A

Note:
The example of awk - provided works when there is one unwanted newline in the record  but not when there are multiple newlines

Thank you so very much. It works perfectly. Thank you for explaining it so well to me too.

答:
This might work for you (GNU sed):

```<code>sed ':a;N;s/\x01/&/87;Ta;s/\n//g' file
</code>```

Gather up lines until there are 87 separators, remove any newlines and print the result.

Body:
I have file where:

field delimiter is \x01

the record delimiter is \n

Some lines contain multiple newlines I need to remove them, however I don't want to remove the legitimate newlines at the end of each lines. I have tried this with awk:

awk -F '\x01' 'NF < 87 {getline s; $0 = $0 s} 1' infile > outfile

But this is only working when the line contains one newline in the record (except end of line newline). This does not work for multiple newlines.

Note: the record contains 87 fields.

What am I doing wrong here?

Example of file:

PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000
test^A00000000
 Test^A^A^A^A
PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000
test^A00000000
 Test^A^A^A^A
SL^ANov-21^A30-11-2021^AB^A0000^A1234567^A00000
test^A12102120^A00000^A00^A^A

NOTE: The file contains 11 fields; field separate \x01; record separator \n

Expected result:

PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000test^A00000000 Test^A^A^A^A
PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000test^A00000000 Test^A^A^A^A
SL^ANov-21^A30-11-2021^AB^A0000^A1234567^A00000test^A12102120^A00000^A00^A^A

Note: I need to preserve the field delimiter (\x01) and record delimiter (\n)

Thank you very much in advance for looking into this.

The file always contains 87 fields;
The fild delimiter is '\x01', but when viewing in Linux it is represented as '^A'
Some lines contain newlines - I need to remove them, but I don't want to remove the legitimate newlines at the end of each line.
The newline appears twice in the 1st and second record and once in third record - this are the newlines I want to remove.

In the examples/expected results there are 11 delimiters "x01" represented as "^A",
I expect to have 3 records and not 6, i.e.:

First record:

test^A00000000 should be joined to the previous line

Test^A^A^A^A should be joined to the first line as well

forming one record:

PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000test^A00000000 Test^A^A^A^A

Second record

test^A00000000 should be joined to the previous line

Test^A^A^A^A should be joined to that previous line as well

forming one record:

PL^ANov-21^A29-11-2021^A0^A00^A00^A0000000test^A00000000 Test^A^A^A^A

Third record:

test^A12102120^A00000^A00^A^A should be joined to the previous line

forming one record:

SL^ANov-21^A30-11-2021^AB^A0000^A1234567^A00000test^A12102120^A00000^A00^A^A

Note:
The example of awk - provided works when there is one unwanted newline in the record  but not when there are multiple newlines

Thank you so very much. It works perfectly. Thank you for explaining it so well to me too.

Body:
This might work for you (GNU sed):

sed ':a;N;s/\x01/&/87;Ta;s/\n//g' file

Gather up lines until there are 87 separators, remove any newlines and print the result.


问:
react native ImageBackground not showing on IOS device
I am using the ImageBackground component of react native, but in IOS (device) it is not displaying the image, in the simulator the image appears
What can this be?

code below:

```<code>import { ImageBackground } from 'react-native';

const imgSrc = require('../../assets/images/bg-login.png');

<ImageBackground
        resizeMode="cover"
        source={imgSrc}
        style={style.backgroundImage}
      >
</code>```

style below:

```<code>backgroundImage: {
        width: screenWidth,
        height: '100%'
    },
</code>```

答:
Did you add asset folder to your iOS build ?

Here the commande to do it :

```<code>react-native bundle --minify --entry-file index.js --platform ios --dev false --bundle-output ./ios/main.jsbundle --assets-dest ./ios
</code>```

You will see asset folder and main.jsbundle file in the ios folder. After that go to Xcode -> build phases -> copy bundle resources and then add the asset folder and main.jsbundle file. Don't forget to click on the Copy if needed

Body:
I am using the ImageBackground component of react native, but in IOS (device) it is not displaying the image, in the simulator the image appears
What can this be?

code below:

import { ImageBackground } from 'react-native';

const imgSrc = require('../../assets/images/bg-login.png');

<ImageBackground
        resizeMode="cover"
        source={imgSrc}
        style={style.backgroundImage}
      >

style below:

backgroundImage: {
        width: screenWidth,
        height: '100%'
    },

Body:
Did you add asset folder to your iOS build ?

Here the commande to do it :

react-native bundle --minify --entry-file index.js --platform ios --dev false --bundle-output ./ios/main.jsbundle --assets-dest ./ios

You will see asset folder and main.jsbundle file in the ios folder. After that go to Xcode -> build phases -> copy bundle resources and then add the asset folder and main.jsbundle file. Don't forget to click on the Copy if needed


问:
How to map two keys to a single member in JSON struct. (with Marshal/Unmarshal)
I have a situation where my API return []byte {"name":"Windows"} on Windows and {"myName":"Linux"} on Linux, both are reporting OS Name but the key (name/MyName) is changed based on OS. How to Marshal/Unmarshal it to a JSON struct. Where I have single ember that can hold OS Name.

```<code>type OsName struct {
    Name   string `json:"name"` //I want to map Myname as well to this member.
}
</code>```

Note: above question is not about how to get OS name, its about how to map 2 different keys to a single Json member.

答:
You should probably Unmarshall to a map[string]string{} and then go from there.

```<code>    dataFromAPI := "{\"name\": \"Windows\"}"
    m := map[string]string{}
    err := json.Unmarshal([]byte(dataFromAPI), &m)
    if err != nil {
        panic(err)
    }
    if _, ok := m["name"]; ok {
        fmt.Println(m["name"]) // or m["myName"]
    }
</code>```

Body:
I have a situation where my API return []byte {"name":"Windows"} on Windows and {"myName":"Linux"} on Linux, both are reporting OS Name but the key (name/MyName) is changed based on OS. How to Marshal/Unmarshal it to a JSON struct. Where I have single ember that can hold OS Name.

type OsName struct {
    Name   string `json:"name"` //I want to map Myname as well to this member.
}

Note: above question is not about how to get OS name, its about how to map 2 different keys to a single Json member.

Body:
You should probably Unmarshall to a map[string]string{} and then go from there.

    dataFromAPI := "{\"name\": \"Windows\"}"
    m := map[string]string{}
    err := json.Unmarshal([]byte(dataFromAPI), &m)
    if err != nil {
        panic(err)
    }
    if _, ok := m["name"]; ok {
        fmt.Println(m["name"]) // or m["myName"]
    }


问:
change the order of a factor character vector
I have a character factor-leveled vector.

```<code>cat <- as.factor(c("AS-GEN-SUM-10-Fall", "AS-GEN-SUM-3-Fall","AS-GEN-SUM-4-Fall","AS-GEN-SUM-5-Fall"))

cat
[1] AS-GEN-SUM-10-Fall AS-GEN-SUM-3-Fall  AS-GEN-SUM-4-Fall  AS-GEN-SUM-5-Fall
Levels: AS-GEN-SUM-10-Fall AS-GEN-SUM-3-Fall AS-GEN-SUM-4-Fall AS-GEN-SUM-5-Fall
</code>```

As seen, the order starts with the number -10- instead of -3-. R naturally order them by the first number even though 10 is larger than 3.

Is there a way to change the order without specifying each name?
Any ideas?

Thanks!

答:
Please, find below one possible solution using the mixedsort() function from the gtools library.

Reprex

Code

library(gtools)

factor(mixedsort(c("AS-GEN-SUM-10-Fall", "AS-GEN-SUM-3-Fall","AS-GEN-SUM-4-Fall","AS-GEN-SUM-5-Fall"), decreasing = TRUE))
```
<ul>
<li>Output</li>
</ul>
<pre class="lang-r prettyprint-override"><code>#> [1] AS-GEN-SUM-3-Fall  AS-GEN-SUM-4-Fall  AS-GEN-SUM-5-Fall  AS-GEN-SUM-10-Fall
#> 4 Levels: AS-GEN-SUM-10-Fall AS-GEN-SUM-3-Fall ... AS-GEN-SUM-5-Fall
</code>```

Created on 2022-02-11 by the reprex package (v2.0.1)

Body:
I have a character factor-leveled vector.

cat <- as.factor(c("AS-GEN-SUM-10-Fall", "AS-GEN-SUM-3-Fall","AS-GEN-SUM-4-Fall","AS-GEN-SUM-5-Fall"))

cat
[1] AS-GEN-SUM-10-Fall AS-GEN-SUM-3-Fall  AS-GEN-SUM-4-Fall  AS-GEN-SUM-5-Fall
Levels: AS-GEN-SUM-10-Fall AS-GEN-SUM-3-Fall AS-GEN-SUM-4-Fall AS-GEN-SUM-5-Fall

As seen, the order starts with the number -10- instead of -3-. R naturally order them by the first number even though 10 is larger than 3.

Is there a way to change the order without specifying each name?
Any ideas?

Thanks!

Body:
Please, find below one possible solution using the mixedsort() function from the gtools library.

Reprex

Code

library(gtools)

factor(mixedsort(c("AS-GEN-SUM-10-Fall", "AS-GEN-SUM-3-Fall","AS-GEN-SUM-4-Fall","AS-GEN-SUM-5-Fall"), decreasing = TRUE))

Output

#> [1] AS-GEN-SUM-3-Fall  AS-GEN-SUM-4-Fall  AS-GEN-SUM-5-Fall  AS-GEN-SUM-10-Fall
#> 4 Levels: AS-GEN-SUM-10-Fall AS-GEN-SUM-3-Fall ... AS-GEN-SUM-5-Fall

Created on 2022-02-11 by the reprex package (v2.0.1)


问:
AWS Cloudformation | Configure Lambda to Use Latest Version of Code in S3 Bucket
Im using codepipeline, codebuild and cloudformation on AWS.

My flow is:

Push a commit to github, this triggers the codepipeline

Codebuild uploads (zipped) lambda functions to S3 bucket

Cloudformation configure lambda functions

Cloudformation (simplified):

```<code>CreateDoctorLambda:
    Type: AWS::Lambda::Function
    Properties:
      Runtime: python3.6
      Handler: lambda_function.lambda_handler
      Role:
        Fn::GetAtt:
          - LambdaExecutionRole
          - Arn
      Code:
          S3Bucket: !Ref LambdaFunctionS3Bucket
          S3Key: CreateDoctor.zip
          S3ObjectVersion: Latest <-- This value is invalid
</code>```

Problem: When I update the code for lambda functions (this new code is zipped and uploaded to the S3 bucket during codebuild), the change is not deployed to the existing lambda functions.

According to AWS documentation:

To update a Lambda function whose source code is in an Amazon S3
  bucket, you must trigger an update by updating the S3Bucket, S3Key, or
  S3ObjectVersion property. Updating the source code alone doesn't
  update the function.

Question: Is there any way to tell Cloudformation to use the latest version of the code stored in S3? Using S3ObjectVersion: Latest will result in an error.

答:
My requirement was also similar but I didn't use aws-cloudformation.
I have configured AWS pipeline to deploy my latest nodeJS code as zip file to S3. Instead of going to AWS Lambda and manually choosing the "upload from Amazon S3 location" option, I needed my lambda function to take the latest code once it is written to S3, so that it will automatically update its function code when you update the zip file in S3 through AWS pipeline.

Solution that worked for me is in this link:-
https://stackoverflow.com/a/71079021/10049471

Body:
Im using codepipeline, codebuild and cloudformation on AWS.

My flow is:

Push a commit to github, this triggers the codepipeline

Codebuild uploads (zipped) lambda functions to S3 bucket

Cloudformation configure lambda functions

Cloudformation (simplified):

CreateDoctorLambda:
    Type: AWS::Lambda::Function
    Properties:
      Runtime: python3.6
      Handler: lambda_function.lambda_handler
      Role:
        Fn::GetAtt:
          - LambdaExecutionRole
          - Arn
      Code:
          S3Bucket: !Ref LambdaFunctionS3Bucket
          S3Key: CreateDoctor.zip
          S3ObjectVersion: Latest <-- This value is invalid

Problem: When I update the code for lambda functions (this new code is zipped and uploaded to the S3 bucket during codebuild), the change is not deployed to the existing lambda functions.

According to AWS documentation:

To update a Lambda function whose source code is in an Amazon S3
  bucket, you must trigger an update by updating the S3Bucket, S3Key, or
  S3ObjectVersion property. Updating the source code alone doesn't
  update the function.

Question: Is there any way to tell Cloudformation to use the latest version of the code stored in S3? Using S3ObjectVersion: Latest will result in an error.


问:
Reusable button for dropdown toggle (Vue and Laravel)
I'm learning vue and i'm trying to build a reusable dropdown component. After hours of work i finally got it together and now i'm stuck because all i want is to pass the button name to my vue component.

This is my dropdown:
https://imgur.com/StvEjyF

What I want is a way to pass the button name from my blade to the button.

My blade and only the string of the button name i'm trying to pass is not working:

            <Dropdown>

                <template slot="toggler">
                    <button>from blade</button>
                </template>

                <Dropdowncontent>
                    <Dropdownitems>Link1</Dropdownitems>
                    <Dropdownitems>Link2</Dropdownitems>
                </Dropdowncontent>

            </Dropdown>
```
<p>My dropdown component which contains the button:</p>
<pre class="lang-html prettyprint-override"><code><template>
    <div class="relative" v-click-outside="onClickOutside">
        <slot name="toggler">
            <button
                @click="showCategories"
                class="flex max-h-52 w-full overflow-auto py-2 pl-3 pr-9 text-sm font-semibold lg:inline-flex lg:w-32"
            >
                from vue
            </button>
        </slot>

        <slot />
    </div>
</template>
</code>```

I tried to accept it as a prop so I added props: [buttonName] to export default in my component and from the blade i added :buttonName="bla bla" to the dropdown tags but it doesn't update the {{buttonName}} in the component so this didn't work.

All i need is a way to pass only the button name from blade to vue because i don't want to create the button in the blade as it's my toggle for the dropdown content and items

答: I fixed it by simply passing title prop to the component</p>

Body:
I'm learning vue and i'm trying to build a reusable dropdown component. After hours of work i finally got it together and now i'm stuck because all i want is to pass the button name to my vue component.

This is my dropdown:
https://imgur.com/StvEjyF

What I want is a way to pass the button name from my blade to the button.

My blade and only the string of the button name i'm trying to pass is not working:

            <Dropdown>

                <template slot="toggler">
                    <button>from blade</button>
                </template>

                <Dropdowncontent>
                    <Dropdownitems>Link1</Dropdownitems>
                    <Dropdownitems>Link2</Dropdownitems>
                </Dropdowncontent>

            </Dropdown>

My dropdown component which contains the button:

<template>

        <slot name="toggler">
            <button
                @click="showCategories"
                class="flex max-h-52 w-full overflow-auto py-2 pl-3 pr-9 text-sm font-semibold lg:inline-flex lg:w-32"
            >
                from vue
            </button>
        </slot>

        <slot />

</template>

I tried to accept it as a prop so I added props: [buttonName] to export default in my component and from the blade i added :buttonName="bla bla" to the dropdown tags but it doesn't update the {{buttonName}} in the component so this didn't work.

All i need is a way to pass only the button name from blade to vue because i don't want to create the button in the blade as it's my toggle for the dropdown content and items


问:
Tool for exporting html as pdf
I have a html document which marks up a report. I have a button on this page "Export as pdf". However I am not sure how to export html into a pdf..Are there any tools out there that anyone recommends for such a task..

EDIT: In more detail:

I have the following php:

```<code><?php

function connect() {
  $dbh = mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
  mysql_select_db("PDS", $dbh);
  return $dbh;
}

session_start();

if(isset($_SESSION['username'])){
  if(isset($_POST['entryId'])){
    //do something
    $dbh = connect();
    $ide = $_POST['entryId'];
    $usertab = $_POST['usertable'];
    $answertable = $usertab . "Answers";
    $entrytable = $usertab . "Entries";
    $query = mysql_query("SELECT e.date, q.questionNumber, q.question, q.sectionId, a.answer FROM $answertable a, Questions q, $entrytable e WHERE a.entryId = '$ide' AND a.questionId = q.questionId AND e.entryId = '$ide' ORDER BY q.questionNumber ASC;") or die("Error: " . mysql_error());

    if($query){
      //set variables

      $sectionOne = array();
      $sectionTwo = array();
      $sectionThree = array();
      $sectionFour = array();
      $sectionFive = array();
      while($row=mysql_fetch_assoc($query)){
    $date = $row['date'];
    $section = $row['sectionId'];
    switch($section){
    case '1':
      $sectionOne[] = $row;
      break;
    case '2':
      $sectionTwo[] = $row;
      break;
    case '3':
      $sectionThree[] = $row;
      break;
        case '4':
      $sectionFour[] = $row;
      break;
        case '5':
      $sectionFive[] = $row;
      break;
        default:
      break;
    }
      }
    }else{
      //error - sql failed
    }
  }

?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
   <script src = "jQuery.js"></script>
   <script>
   $(document).ready(function(){

   });
  </script>
  <title>Personal Diary System - Entry Report - <?php echo($date); ?></title>
  </head>
  <body>
  <h1>Entry Report - <?php echo($date); ?></h1>
  <div id = "buttons">
  <a href = "http://dev.speechlink.co.uk">Export as PDF</a>
  </div>
  <h3>Biological Information</h3>
  <?php
      $i = 0;
      foreach($sectionOne as &$value){
    if($i == 1 || $i == 3){
      $image = "assets/urine".$i.".png";
      echo("<br/>");
      echo($value['question']." <br/> "."<img src = \"$image\"/>");
      echo("<br/>");
    }else{
      echo($value['question'].' : '.$value['answer']);
    }
    echo("<br/>");
    $i++;
      }
  ?>
  <h3>Fatigue and Recovery</h3>
  <?php
      foreach($sectionTwo as &$value){
    echo($value['question'].' : '.$value['answer']);
    echo("<br/>");
      }
  ?>
  <h3>Illness and Injury</h3>
  <?php
      foreach($sectionThree as &$value){
    echo($value['question'].' : '.$value['answer']);
    echo("<br/>");
      }
  ?>
  <h3>Training Sessions</h3>
  <?php
      foreach($sectionFour as &$value){
    echo($value['question'].' : '.$value['answer']);
    echo("<br/>");
      }
  ?>
  <h3>General Feedback</h3>
  <?php
     if(count($sectionFive)>0){
      foreach($sectionFive as &$value){
    echo($value['question'].' : '.$value['answer']);
      }
     }else{
       echo("User didn't leave any feedback");
     }
     echo("<br/>");
  ?>
  </body>
</html>
<?php
}
?>
</code>```

This displays the following:

So if I'm using fpdf, what is the best way to export the following as a pdf? Should I write a fpdf function in the same php file or is it best to write a separate php file which creates and displays the pdf (which means I would have to post all relevant data to this file)...

答:
I've found this software quite useful: http://code.google.com/p/wkhtmltopdf/

It is true that you'll have to exec() it from your code, but it works very good and uses webkit as the backend engine (allowing javascript also, and many other features to customize the pdf creation), saving a lot of code.

Hope it helps, we're using it here and it works like a charm.

EDIT: try the static binaries. untar and ready to go :)

Title: Tool for exporting html as pdf

Body:
I have a html document which marks up a report. I have a button on this page "Export as pdf". However I am not sure how to export html into a pdf..Are there any tools out there that anyone recommends for such a task..

EDIT: In more detail:

I have the following php:

<?php

function connect() {
  $dbh = mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
  mysql_select_db("PDS", $dbh);
  return $dbh;
}

session_start();

if(isset($_SESSION['username'])){
  if(isset($_POST['entryId'])){
    //do something
    $dbh = connect();
    $ide = $_POST['entryId'];
    $usertab = $_POST['usertable'];
    $answertable = $usertab . "Answers";
    $entrytable = $usertab . "Entries";
    $query = mysql_query("SELECT e.date, q.questionNumber, q.question, q.sectionId, a.answer FROM $answertable a, Questions q, $entrytable e WHERE a.entryId = '$ide' AND a.questionId = q.questionId AND e.entryId = '$ide' ORDER BY q.questionNumber ASC;") or die("Error: " . mysql_error());

    if($query){
      //set variables

      $sectionOne = array();
      $sectionTwo = array();
      $sectionThree = array();
      $sectionFour = array();
      $sectionFive = array();
      while($row=mysql_fetch_assoc($query)){
    $date = $row['date'];
    $section = $row['sectionId'];
    switch($section){
    case '1':
      $sectionOne[] = $row;
      break;
    case '2':
      $sectionTwo[] = $row;
      break;
    case '3':
      $sectionThree[] = $row;
      break;
        case '4':
      $sectionFour[] = $row;
      break;
        case '5':
      $sectionFive[] = $row;
      break;
        default:
      break;
    }
      }
    }else{
      //error - sql failed
    }
  }

?>

   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

  <title>Personal Diary System - Entry Report - <?php echo($date); ?></title>

Entry Report - <?php echo($date); ?>

  Export as PDF

Biological Information

  <?php
      $i = 0;
      foreach($sectionOne as &$value){
    if($i == 1 || $i == 3){
      $image = "assets/urine".$i.".png";
      echo("
");
      echo($value['question']."
 "."");
      echo("
");
    }else{
      echo($value['question'].' : '.$value['answer']);
    }
    echo("
");
    $i++;
      }
  ?>

Fatigue and Recovery

  <?php
      foreach($sectionTwo as &$value){
    echo($value['question'].' : '.$value['answer']);
    echo("
");
      }
  ?>

Illness and Injury

  <?php
      foreach($sectionThree as &$value){
    echo($value['question'].' : '.$value['answer']);
    echo("
");
      }
  ?>

Training Sessions

  <?php
      foreach($sectionFour as &$value){
    echo($value['question'].' : '.$value['answer']);
    echo("
");
      }
  ?>

General Feedback

  <?php
     if(count($sectionFive)>0){
      foreach($sectionFive as &$value){
    echo($value['question'].' : '.$value['answer']);
      }
     }else{
       echo("User didn't leave any feedback");
     }
     echo("
");
  ?>

<?php
}
?>

This displays the following:

So if I'm using fpdf, what is the best way to export the following as a pdf? Should I write a fpdf function in the same php file or is it best to write a separate php file which creates and displays the pdf (which means I would have to post all relevant data to this file)...


问:
How to fetch data in a variable in asp.net C#
I am trying to fetch the data in a decimal variable. I highly need your assistance to do so. if I test the query but put the fetched value in the label, it works without any problem. However, I want to get it in the decimal humidity as I want to compare this value with the threshold. Could you help me with this? Your help with being highly appreciated
below is the code

the output: I still get 20 which is the declared value in the code.

```<code>namespace IoTSmartFarming
{
    public partial class DataVisualization : System.Web.UI.Page
    {
        string strcon = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
            showHumidity();
        }

        private decimal getHumidity()
        {
            SqlConnection conn = new SqlConnection(strcon);
            if (conn.State == System.Data.ConnectionState.Closed)
            {
                conn.Open();
            }
            decimal humidity = 20;
            SqlCommand cmd = new SqlCommand("SELECT TOP 1 value from Humidity ORDER BY time desc", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                Label4.Text= dr.GetValue(0).ToString();
            }

            return humidity;
        }

        private void showHumidity()
        {
            decimal actHumidity = getHumidity();
            Label4.Text = actHumidity.ToString();

            if(actHumidity>100 || actHumidity < 10)
            {
                Label5.Visible = false;
                Label6.Visible = true;
            }

        }
    }
}
</code>```

答:
You forgot to assign your variable. All that you need is add an variable assignment:</p>
```<code>humidity = dr.GetDecimal(0);
</code>```

Body:
I am trying to fetch the data in a decimal variable. I highly need your assistance to do so. if I test the query but put the fetched value in the label, it works without any problem. However, I want to get it in the decimal humidity as I want to compare this value with the threshold. Could you help me with this? Your help with being highly appreciated
below is the code

the output: I still get 20 which is the declared value in the code.

namespace IoTSmartFarming
{
    public partial class DataVisualization : System.Web.UI.Page
    {
        string strcon = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
            showHumidity();
        }

        private decimal getHumidity()
        {
            SqlConnection conn = new SqlConnection(strcon);
            if (conn.State == System.Data.ConnectionState.Closed)
            {
                conn.Open();
            }
            decimal humidity = 20;
            SqlCommand cmd = new SqlCommand("SELECT TOP 1 value from Humidity ORDER BY time desc", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                Label4.Text= dr.GetValue(0).ToString();
            }

            return humidity;
        }

        private void showHumidity()
        {
            decimal actHumidity = getHumidity();
            Label4.Text = actHumidity.ToString();

            if(actHumidity>100 || actHumidity < 10)
            {
                Label5.Visible = false;
                Label6.Visible = true;
            }

        }
    }
}

Body:
You forgot to assign your variable. All that you need is add an variable assignment:

humidity = dr.GetDecimal(0);


问:
Silverlight Business Application - File Size
Looking at the silverlight business application, it seems to add a number of libraries specific to Input Forms and the like.

Am I right in saying that creating Complex classes results in these forms being generated automatically?

Looking at the file size of the basic Silverlight business application XAP file, it's around 412Kb. Is there a way to reduce that size?

Regards,
Jacques

答:
Here are some tips and tricks to try to make your XAP smaller. Like removing references you don't really use and re-zipping the XAP. Hope it helps!

http://forums.silverlight.net/t/21548.aspx