问:
How to pass data using React useState between Material UI components
I'm trying to find out how to work with Matherial UI library in React. So I downloaded the Dashboard free template. And I stuck with the following issue:

Dashboards.js (high order component):

```<code>...
import {mainListItems} from './listItems';
...
function DashboardContent() {
  ...

  return (
    ...
          <List component="nav">
            <ListSubheader component="div" >
              Выбрать технику
            </ListSubheader>
            {equipmentChoice}
            <ListSubheader component="div"  disableSticky={true}>
              Загрузить отчёты
            </ListSubheader>
            {mainListItems} // How to pass data in this component???
          </List>
        ...

export default function Dashboard() {
  return <DashboardContent />;
}
</code>```

Also, I have a file listItems.js. But it does not contain function component nor class component, just a constant with a list of JSX-tags instead. This is so unusual for me that I don't inderstand how to work with this file.

ListItems.js

```<code>import * as React from 'react';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import HourglassEmpty from '@mui/icons-material/HourglassEmpty';
import HourglassBottom from '@mui/icons-material/HourglassBottom';
import HourglassFull from '@mui/icons-material/HourglassFull';

export const mainListItems = (
  <React.Fragment>
    <ListItemButton>
      <ListItemIcon>
        <HourglassEmpty />
      </ListItemIcon>
      <ListItemText primary="Don't know how to change" /> // I need to change this from Dashboard.js component
    </ListItemButton>
  </React.Fragment>
);
</code>```

How to use Hook like useState in such situation?

答:
Ivan, welcome to Stackoverflow.
Your ListItems.js component can also be represented as shown below.

```<code>import * as React from 'react';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import HourglassEmpty from '@mui/icons-material/HourglassEmpty';
import HourglassBottom from '@mui/icons-material/HourglassBottom';
import HourglassFull from '@mui/icons-material/HourglassFull';

export function mainListItems(){
// You can use useState hook here

return (
  <React.Fragment>
    <ListItemButton>
      <ListItemIcon>
        <HourglassEmpty />
      </ListItemIcon>
      <ListItemText primary="Don't know how to change" /> // I need to change this
    </ListItemButton>
  </React.Fragment>
);
}
</code>```

You can use hooks inside this function.

Body:
I'm trying to find out how to work with Matherial UI library in React. So I downloaded the Dashboard free template. And I stuck with the following issue:

Dashboards.js (high order component):

...
import {mainListItems} from './listItems';
...
function DashboardContent() {
  ...

  return (
    ...
          <List component="nav">
            <ListSubheader component="div" >
              Выбрать технику
            </ListSubheader>
            {equipmentChoice}
            <ListSubheader component="div"  disableSticky={true}>
              Загрузить отчёты
            </ListSubheader>
            {mainListItems} // How to pass data in this component???
          </List>
        ...

export default function Dashboard() {
  return <DashboardContent />;
}

Also, I have a file listItems.js. But it does not contain function component nor class component, just a constant with a list of JSX-tags instead. This is so unusual for me that I don't inderstand how to work with this file.

ListItems.js

import * as React from 'react';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import HourglassEmpty from '@mui/icons-material/HourglassEmpty';
import HourglassBottom from '@mui/icons-material/HourglassBottom';
import HourglassFull from '@mui/icons-material/HourglassFull';

export const mainListItems = (
  <React.Fragment>
    <ListItemButton>
      <ListItemIcon>
        <HourglassEmpty />
      </ListItemIcon>
      <ListItemText primary="Don't know how to change" /> // I need to change this from Dashboard.js component
    </ListItemButton>
  </React.Fragment>
);

How to use Hook like useState in such situation?

Body:
Ivan, welcome to Stackoverflow.
Your ListItems.js component can also be represented as shown below.

import * as React from 'react';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import HourglassEmpty from '@mui/icons-material/HourglassEmpty';
import HourglassBottom from '@mui/icons-material/HourglassBottom';
import HourglassFull from '@mui/icons-material/HourglassFull';

export function mainListItems(){
// You can use useState hook here

return (
  <React.Fragment>
    <ListItemButton>
      <ListItemIcon>
        <HourglassEmpty />
      </ListItemIcon>
      <ListItemText primary="Don't know how to change" /> // I need to change this
    </ListItemButton>
  </React.Fragment>
);
}

You can use hooks inside this function.


来源: stackexchange

问:
Unable to set cookie in nestjs, TypeError: Cannot set properties of undefined (setting 'color')
Am trying to set property in session but getting undefined. Using NestJs + Fastify

app.module.ts

```<code>import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
// import fastifyCookie, { FastifyCookieOptions } from 'fastify-cookie'; --this was also not workin

const cookieSession = require( 'cookie-session' );

async function bootstrap() {
  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter( )
    );

  app.register( cookieSession( {
    keys: [ 'asdsds' ]
  } ) );

  lines...
}
bootstrap();
</code>```

users.controller.ts

```<code>imports...

export class UsersController {

    constructor( private usersService: UsersService, private authService: AuthService ) { }

    @Get( '/colors/:color' )
    setColor( @Param( 'color' ) color: string, @Session( ) session: any ) {
        // console.log( 'check ', session ); --> UNDEFINED
        session.color = color; --> Error HERE
        // session.set( color );
    }

    @Get( '/colors' )
    getColor( @Session( ) session: any ) {
        console.log( 'get session: ', session );
        return session.color;
    }
</code>```

Error is:

```<code>[Nest] 41229  - 13/02/2022, 9:51:06 pm   ERROR [ExceptionsHandler] Cannot set properties of undefined (setting 'color')
TypeError: Cannot set properties of undefined (setting 'color')
    at UsersController.setColor (/home/prabhat/Practice/Nest-Fastify/nestfastify/src/users/users.controller.ts:20:22)
    at /home/prabhat/Practice/Nest-Fastify/nestfastify/node_modules/@nestjs/core/router/router-execution-context.js:38:29
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
</code>```

I have also tried with

```<code>// app.register(fastifyCookie );
// app.register(fastifySession, {secret: 'a secret with minimum length of 32 characters'});
</code>```

答:
What worked for me is fastify-secure-session package, mentioned here

Now my main.ts looks like:

```<code>imports..
import secureSession from 'fastify-secure-session';

async function bootstrap() {
  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter( )
    );

  app.register(secureSession, {
    secret: 'averylogphrasebiggerthanthirtytwochars',
    salt: 'mq9hDxBVDbspDR6n',
  });

  lines..
}
bootstrap();
</code>```

And app.controller.ts is:

```<code>imports..
import * as secureSession from 'fastify-secure-session'

@Controller( 'auth' )
@MongooseClassSerializerInterceptor( UserDto )
export class UsersController {

    constructor( private usersService: UsersService, private authService: AuthService ) { }

    @Get( '/colors/:color' )
    setColor( @Param( 'color' ) color: string, @Session( ) session: secureSession.Session ) {
        console.log( 'check ', session );
        // session.color = color;
        session.set('color', color)
    }

    @Get( '/colors' )
    getColor( @Session( ) session: secureSession.Session ) {
        console.log( 'get session: ', session );
        // return session.color;
        return session.get( 'color' );
    }

}
</code>```

With this am able to set cookie, in NestJs with Fastify.

Still interested in knowing why previous approach is not working for me as mentioned by @Jay in their answer.

ContentLicense: CC BY-SA 4.0

Body:
Am trying to set property in session but getting undefined. Using NestJs + Fastify

app.module.ts

import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
// import fastifyCookie, { FastifyCookieOptions } from 'fastify-cookie'; --this was also not workin

const cookieSession = require( 'cookie-session' );

async function bootstrap() {
  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter( )
    );

  app.register( cookieSession( {
    keys: [ 'asdsds' ]
  } ) );

  lines...
}
bootstrap();

users.controller.ts

imports...

export class UsersController {

    constructor( private usersService: UsersService, private authService: AuthService ) { }

    @Get( '/colors/:color' )
    setColor( @Param( 'color' ) color: string, @Session( ) session: any ) {
        // console.log( 'check ', session ); --> UNDEFINED
        session.color = color; --> Error HERE
        // session.set( color );
    }

    @Get( '/colors' )
    getColor( @Session( ) session: any ) {
        console.log( 'get session: ', session );
        return session.color;
    }

Error is:

[Nest] 41229  - 13/02/2022, 9:51:06 pm   ERROR [ExceptionsHandler] Cannot set properties of undefined (setting 'color')
TypeError: Cannot set properties of undefined (setting 'color')
    at UsersController.setColor (/home/prabhat/Practice/Nest-Fastify/nestfastify/src/users/users.controller.ts:20:22)
    at /home/prabhat/Practice/Nest-Fastify/nestfastify/node_modules/@nestjs/core/router/router-execution-context.js:38:29
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I have also tried with

// app.register(fastifyCookie );
// app.register(fastifySession, {secret: 'a secret with minimum length of 32 characters'});

Body:
What worked for me is fastify-secure-session package, mentioned here

Now my main.ts looks like:

imports..
import secureSession from 'fastify-secure-session';

async function bootstrap() {
  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter( )
    );

  app.register(secureSession, {
    secret: 'averylogphrasebiggerthanthirtytwochars',
    salt: 'mq9hDxBVDbspDR6n',
  });

  lines..
}
bootstrap();

And app.controller.ts is:

imports..
import * as secureSession from 'fastify-secure-session'

@Controller( 'auth' )
@MongooseClassSerializerInterceptor( UserDto )
export class UsersController {

    constructor( private usersService: UsersService, private authService: AuthService ) { }

    @Get( '/colors/:color' )
    setColor( @Param( 'color' ) color: string, @Session( ) session: secureSession.Session ) {
        console.log( 'check ', session );
        // session.color = color;
        session.set('color', color)
    }

    @Get( '/colors' )
    getColor( @Session( ) session: secureSession.Session ) {
        console.log( 'get session: ', session );
        // return session.color;
        return session.get( 'color' );
    }

}

With this am able to set cookie, in NestJs with Fastify.

Still interested in knowing why previous approach is not working for me as mentioned by @Jay in their answer.


问:
Best algorithm for efficient collision detection between objects
I'm confused.  Well not confused, so much as not wanting to do 6 test programs to see which algorithm is the best. So I thought I'd ask my expert friends here at SO to give me the benefit of their experience.

The scenario is a 3d scene with potentially quite a large area compared to the sizes of the objects inside it.  There are potentially thousands of objects in the scene.  Objects vary in size from tenths of a unit to up to around 10 units, but no bigger (or smaller).  The objects tend to be clustered together, but those clusters can potentially appear anywhere in the scene.  All objects are dynamic and moving.  Clusters tend to move together, but when they do their velocities might not be the same all the time.  There's also static geometry to consider.  Although there are large numbers of dynamic objects, there's also some static objects in the scene (the static objects tend to be one or two orders of magnitude larger than the dynamic objects).

Now, what I want is a spatial data structure for efficiently performing collision detection for all items in the scene.  It would be great if the algorithm also supported visibility query too, for the rendering pipeline.  For the sake of simplicity, assume that collision detection here is broad-phase (i.e. all dynamic objects are just perfect spheres).

So, in my research I can use one of:

(1) Octree
(2) Loose Octree
(3) Linear Octree (+ loose)
(4) KD Tree
(5) BSP Tree
(6) Hashing

So far (6) is the only one I've tried.  It's actually totally superb in terms of speed (8192 items collision checked in under 1ms on my system) if objects in the scene are on average evenly spread out.  It's not such a good algorithm if all objects get couped up into a smaller area, which I suppose is possible.

Does anyone have some insight as to which one to use, or any tricks I can employ to speed things up?  I'm thinking that whatever happens I can just use a separate BSP tree for the static geometry.  I suppose the dynamic "spheres" are what concern me most here.  Note: no CUDA, this is CPU only :p.

Thanks

EDIT: Ok, thanks to Floris, I found more information about AABB Trees.  There's an old discussion on GameDev here: http://www.gamedev.net/topic/308665-aabb-tree---wheres-the-poly-o_o/.  Looks like a good compromise.

Final EDIT:  Decided not to reinvent the wheel.  It's possible the bullet physics library will do all of this for me (it has AABB tree in it, probably very well optimised too).

答:
Great question.

You basically have a complex trade-off between:

Speed of a complete collision detection phase

Overhead of updating / maintaining the data structure as objects move around

The bad news is that there is no "perfect" answer because of this - it will genuinely depend on lots of different factors unique to your situation. BSPs for example are blisteringly fast for 1. when they are pre-computed with a lot of static planar geometry, which explains why they were so prevalent in early FPS games.

My personal guess is that a loose AABB (Axis Aligned Bounding Box) tree with a reasonable number of objects (5-10?) in each bottom level bounding box will probably work best in your case. Reasons:

You have quite a large / sparse space with clusters of objects. AABB trees tend to be good for this, as you can cut out a lot of levels that you would otherwise need.

You are assuming perfect spheres. Sphere to sphere collision tests are very cheap so you can easily afford to do 10-45 tests for each bottom level-node. Basically N^2 is fine for small values of N :-)

Axis alignment makes updating the tree much simpler and intersection tests much cheaper than most alternatives. Since you are assuming roughly spherical objects, I don't think you would gain much from oriented bounding boxes (which only really give you an advantage if you have lots of long/thin shapes at funny angles).

By allowing the bounding boxes to be loose and contain a reasonable number of objects, you reduce the chance that the motion of any individual object will take it outside the AABB bounds. Unless this happens, you don't need to update the tree. This will save you a lot of tree-updating time. When it does happen, extend the bound with a bit of margin so that you don't immediately have to re-extend again next frame - remember that most motion tends to continue in the same direction for a few frames!

Sorry for the slightly woolly answer but I hope this gives you some useful ideas / things to consider!

ContentLicense: CC BY-SA 3.0


问:
Convert array in JSON file to string
Here's a snippet of my JSON object (EDITED) -

```<code>[{
    "traditional": "%",
    "simplified": "%",
    "referencedTraditional": [],
    "referencedSimplified": [],
    "pinyinNumeric": "pa1",
    "pinyinDiacritic": "pā",
    "definitions": [
        "percent (Tw)"
    ],
    "definitionsDiacritic": [
        "percent (Tw)"
    ]
},
{
"traditional":"龠","simplified":"龠","referencedTraditional":[{"cp":"9fa0","c":"龠"}],"referencedSimplified":[{"cp":"9fa0","c":"龠"}],"pinyinNumeric":"yue4","pinyinDiacritic":"yuè","definitions":["ancient unit of volume (half a 合[ge3], equivalent to 50ml)","ancient flute"],"definitionsDiacritic":["ancient unit of volume (half a 合[gě], equivalent to 50ml)","ancient flute"]},
    {"traditional":"龡","simplified":"龡","referencedTraditional":[{"cp":"9fa1","c":"龡"}],"referencedSimplified":[{"cp":"9fa1","c":"龡"}],"pinyinNumeric":"chui4","pinyinDiacritic":"chuì","definitions":["to blow (a flute)","archaic version of 吹"],"definitionsDiacritic":["to blow (a flute)","archaic version of 吹"]},
]
</code>```

I want to convert every key called definitions from an array into a string.

E.g. From ["percent (Tw)"] to "percent (Tw)". Basically, I don't want the array brackets.

So far, I've tried looping through the file and converting every "definitions" key with JSON.stringify() or toString() -

```<code>translations.forEach(key => JSON.stringify((key.definitions)))
</code>```

However, nothing changes in the outputted file.

答:
Issue with the code is the one below

```<code>translations.forEach(key => JSON.stringify((key.definitions)))
</code>```

Simply running this statement will not update the value for the key inside that object. You have to update the object for this.

Logic.

Loop through the keys in the object translations. I used Object.entries(translations).forEach for that.

Check each key, whether it includes "definitions" in that key.

If the key has "definitions" in that, run your stringification logic. I prefer Array.join() compared to JSON.stringify.

Update the key of that object.

Working Fiddle

const translations = {
    "traditional": "%",
    "simplified": "%",
    "referencedTraditional": [],
    "referencedSimplified": [],
    "pinyinNumeric": "pa1",
    "pinyinDiacritic": "pā",
    "definitions": [
        "percent (Tw)"
    ],
    "definitionsDiacritic": [
        "percent (Tw)"
    ]
}
Object.entries(translations).forEach(([key, value]) => key.includes('definitions') ? translations[key] = translations[key].join("") : null);
console.log(translations);```

Title: Convert array in JSON file to string

Body:
Here's a snippet of my JSON object (EDITED) -

[{
    "traditional": "%",
    "simplified": "%",
    "referencedTraditional": [],
    "referencedSimplified": [],
    "pinyinNumeric": "pa1",
    "pinyinDiacritic": "pā",
    "definitions": [
        "percent (Tw)"
    ],
    "definitionsDiacritic": [
        "percent (Tw)"
    ]
},
{
"traditional":"龠","simplified":"龠","referencedTraditional":[{"cp":"9fa0","c":"龠"}],"referencedSimplified":[{"cp":"9fa0","c":"龠"}],"pinyinNumeric":"yue4","pinyinDiacritic":"yuè","definitions":["ancient unit of volume (half a 合[ge3], equivalent to 50ml)","ancient flute"],"definitionsDiacritic":["ancient unit of volume (half a 合[gě], equivalent to 50ml)","ancient flute"]},
    {"traditional":"龡","simplified":"龡","referencedTraditional":[{"cp":"9fa1","c":"龡"}],"referencedSimplified":[{"cp":"9fa1","c":"龡"}],"pinyinNumeric":"chui4","pinyinDiacritic":"chuì","definitions":["to blow (a flute)","archaic version of 吹"],"definitionsDiacritic":["to blow (a flute)","archaic version of 吹"]},
]

I want to convert every key called definitions from an array into a string.

E.g. From ["percent (Tw)"] to "percent (Tw)". Basically, I don't want the array brackets.

So far, I've tried looping through the file and converting every "definitions" key with JSON.stringify() or toString() -

translations.forEach(key => JSON.stringify((key.definitions)))

However, nothing changes in the outputted file.

Body:
Issue with the code is the one below

translations.forEach(key => JSON.stringify((key.definitions)))

Simply running this statement will not update the value for the key inside that object. You have to update the object for this.

Logic.

Loop through the keys in the object translations. I used Object.entries(translations).forEach for that.

Check each key, whether it includes "definitions" in that key.

If the key has "definitions" in that, run your stringification logic. I prefer Array.join() compared to JSON.stringify.

Update the key of that object.

Working Fiddle

const translations = {
    "traditional": "%",
    "simplified": "%",
    "referencedTraditional": [],
    "referencedSimplified": [],
    "pinyinNumeric": "pa1",
    "pinyinDiacritic": "pā",
    "definitions": [
        "percent (Tw)"
    ],
    "definitionsDiacritic": [
        "percent (Tw)"
    ]
}
Object.entries(translations).forEach(([key, value]) => key.includes('definitions') ? translations[key] = translations[key].join("") : null);
console.log(translations);


问:
Creating a function that checks several files for NA values rows in R
I am creating a function that takes an argument which pathway of a bunch of CSV files and check each of them for the number of complete cases and at the end, it gives you a table that has the file number and the number of complete cases in it.

```<code>complete <- function(pathway, id=1:332){
  files_list <- list.files(path = pathway, pattern = ".csv", full.names = TRUE)
  final_result <- data.frame(id = numeric(), nobs = numeric())
  for(i in id){
    storefiles <- read.csv(files_list[i])
    data_vector <- numeric()
    data_vector <- c(i, complete.cases(storefiles))
    final_result <- rbind(final_result, data_vector)
  }
  table(final_result)
}
</code>```

so when I run the function it gives me this error (note the files' names are just numbers (001.csv, 002.csv, 003.csv ...)

```<code>> complete("specdata")
 Error in table(final_result) :
attempt to make a table with >= 2^31 elements
3.
stop("attempt to make a table with >= 2^31 elements")
2.
table(final_result)
1.
complete("specdata")
</code>```

when I remove the table function to show the full data frame.

```<code>> complete <- function(pathway, id=1:332){
+   files_list <- list.files(path = pathway, pattern = ".csv", full.names = TRUE)
+   final_result <- data.frame(id = numeric(), nobs = numeric())
+   for(i in id){
+     storefiles <- read.csv(files_list[i])
+     data_vector <- numeric()
+     data_vector <- c(i, complete.cases(storefiles))
+     final_result <- rbind(final_result, data_vector)
+   }
+ }
> complete("specdata")
> complete <- function(pathway, id=1:332){
+   files_list <- list.files(path = pathway, pattern = ".csv", full.names = TRUE)
+   final_result <- data.frame(id = numeric(), nobs = numeric())
+   for(i in id){
+     storefiles <- read.csv(files_list[i])
+     data_vector <- numeric()
+     data_vector <- c(i, complete.cases(storefiles))
+     final_result <- rbind(final_result, data_vector)
+   }
+   final_result
+ }
> complete("specdata")
     X1L X0L X0L.1 X0L.2 X0L.3 X0L.4 X0L.5 X0L.6 X0L.7 X0L.8 X0L.9 X0L.10 X0L.11
     X0L.12 X0L.13 X0L.14 X0L.15 X0L.16 X0L.17 X0L.18 X0L.19 X0L.20 X0L.21
     X0L.22 X0L.23 X0L.24 X0L.25 X0L.26 X0L.27 X0L.28 X0L.29 X0L.30 X0L.31
     X0L.32 X0L.33 X0L.34 X0L.35 X0L.36 X0L.37 X0L.38 X0L.39 X0L.40 X0L.41
     X0L.42 X0L.43 X0L.44 X0L.45 X0L.46 X0L.47 X0L.48 X0L.49 X0L.50 X0L.51
     X0L.52 X0L.53 X0L.54 X0L.55 X0L.56 X0L.57 X0L.58 X0L.59 X0L.60 X0L.61
     X0L.62 X0L.63 X0L.64 X0L.65 X0L.66 X0L.67 X0L.68 X0L.69 X0L.70 X0L.71
     X0L.72 X0L.73 X0L.74 X0L.75 X0L.76 X0L.77 X0L.78 X0L.79 X0L.80 X0L.81
     X0L.82 X0L.83 X0L.84 X0L.85 X0L.86 X0L.87 X0L.88 X0L.89 X0L.90 X0L.91
     X0L.92 X0L.93 X0L.94 X0L.95 X0L.96 X0L.97 X0L.98 X0L.99 X0L.100 X0L.101
     X0L.102 X0L.103 X0L.104 X0L.105 X0L.106 X0L.107 X0L.108 X0L.109 X0L.110
     X0L.111 X0L.112 X0L.113 X0L.114 X0L.115 X0L.116 X0L.117 X0L.118 X0L.119
     X0L.120 X0L.121 X0L.122 X0L.123 X0L.124 X0L.125 X0L.126 X0L.127 X0L.128
     X0L.129 X0L.130 X0L.131 X0L.132 X0L.133 X0L.134 X0L.135 X0L.136 X0L.137
     X0L.138 X0L.139 X0L.140 X0L.141 X0L.142 X0L.143 X0L.144 X0L.145 X0L.146
     X0L.147 X0L.148 X0L.149 X0L.150 X0L.151 X0L.152 X0L.153 X0L.154 X0L.155
     X0L.156 X0L.157 X0L.158 X0L.159 X0L.160 X0L.161 X0L.162 X0L.163 X0L.164
     X0L.165 X0L.166 X0L.167 X0L.168 X0L.169 X0L.170 X0L.171 X0L.172 X0L.173
     X0L.174 X0L.175 X0L.176 X0L.177 X0L.178 X0L.179 X0L.180 X0L.181 X0L.182
     X0L.183 X0L.184 X0L.185 X0L.186 X0L.187 X0L.188 X0L.189 X0L.190 X0L.191
     X0L.192 X0L.193 X0L.194 X0L.195 X0L.196 X0L.197 X0L.198 X0L.199 X0L.200
     X0L.201 X0L.202 X0L.203 X0L.204 X0L.205 X0L.206 X0L.207 X0L.208 X0L.209
     X0L.210 X0L.211 X0L.212 X0L.213 X0L.214 X0L.215 X0L.216 X0L.217 X0L.218
     X0L.219 X0L.220 X0L.221 X0L.222 X0L.223 X0L.224 X0L.225 X0L.226 X0L.227
     X0L.228 X0L.229 X0L.230 X0L.231 X0L.232 X0L.233 X0L.234 X0L.235 X0L.236
     X0L.237 X0L.238 X0L.239 X0L.240 X0L.241 X0L.242 X0L.243 X0L.244 X0L.245
     X0L.246 X0L.247 X0L.248 X0L.249 X0L.250 X0L.251 X0L.252 X0L.253 X0L.254
     X0L.255 X0L.256 X0L.257 X0L.258 X0L.259 X0L.260 X0L.261 X0L.262 X0L.263
     X0L.264 X0L.265 X0L.266 X0L.267 X0L.268 X0L.269 X0L.270 X0L.271 X0L.272
     X0L.273 X0L.274 X0L.275 X0L.276 X0L.277 X1L.1 X0L.278 X0L.279 X0L.280
     X0L.281 X0L.282 X1L.2 X0L.283 X0L.284 X0L.285 X0L.286 X0L.287 X1L.3 X0L.288
     X0L.289 X0L.290 X0L.291 X0L.292 X1L.4 X0L.293 X0L.294 X0L.295 X0L.296
     X0L.297 X1L.5 X0L.298 X0L.299 X0L.300 X0L.301 X0L.302 X0L.303 X0L.304
     X0L.305 X0L.306 X0L.307 X0L.308 X1L.6 X0L.309 X0L.310 X0L.311 X0L.312
     X0L.313 X1L.7 X0L.314 X0L.315 X0L.316 X0L.317 X0L.318 X1L.8 X0L.319 X0L.320
     X0L.321 X0L.322 X0L.323 X1L.9 X0L.324 X0L.325 X0L.326 X0L.327 X0L.328
     X1L.10 X0L.329 X0L.330 X0L.331 X0L.332 X0L.333 X1L.11 X0L.334 X0L.335
     X0L.336 X0L.337 X0L.338 X0L.339 X0L.340 X0L.341 X0L.342 X0L.343 X0L.344
     X1L.12 X0L.345 X0L.346 X0L.347 X0L.348 X0L.349 X1L.13 X0L.350 X0L.351
     X0L.352 X0L.353 X0L.354 X1L.14 X0L.355 X0L.356 X0L.357 X0L.358 X0L.359
     X1L.15 X0L.360 X0L.361 X0L.362 X0L.363 X0L.364 X0L.365 X0L.366 X0L.367
     X0L.368 X0L.369 X0L.370 X1L.16 X0L.371 X0L.372 X0L.373 X0L.374 X0L.375
     X1L.17 X0L.376 X0L.377 X0L.378 X0L.379 X0L.380 X1L.18 X0L.381 X0L.382
     X0L.383 X0L.384 X0L.385 X1L.19 X0L.386 X0L.387 X0L.388 X0L.389 X0L.390
     X0L.391 X0L.392 X0L.393 X0L.394 X0L.395 X0L.396 X1L.20 X0L.397 X0L.398
     X0L.399 X0L.400 X0L.401 X1L.21 X0L.402 X0L.403 X0L.404 X0L.405 X0L.406
     X1L.22 X0L.407 X0L.408 X0L.409 X0L.410 X0L.411 X1L.23 X0L.412 X0L.413
     X0L.414 X0L.415 X0L.416 X1L.24 X0L.417 X0L.418 X0L.419 X0L.420 X0L.421
     X1L.25 X0L.422 X0L.423 X0L.424 X0L.425 X0L.426 X1L.26 X0L.427 X0L.428
     X0L.429 X0L.430 X0L.431 X0L.432 X0L.433 X0L.434 X0L.435 X0L.436 X0L.437
     X0L.438 X0L.439 X0L.440 X0L.441 X0L.442 X0L.443 X0L.444 X0L.445 X0L.446
     X0L.447 X0L.448 X0L.449 X1L.27 X0L.450 X0L.451 X0L.452 X0L.453 X0L.454
     X0L.455 X0L.456 X0L.457 X0L.458 X0L.459 X0L.460 X0L.461 X0L.462 X0L.463
     X0L.464 X0L.465 X0L.466 X0L.467 X0L.468 X0L.469 X0L.470 X0L.471 X0L.472
     X1L.28 X0L.473 X0L.474 X0L.475 X0L.476 X0L.477 X0L.478 X0L.479 X0L.480
     X0L.481 X0L.482 X0L.483 X0L.484 X0L.485 X0L.486 X0L.487 X0L.488 X0L.489
     X0L.490 X0L.491 X0L.492 X0L.493 X0L.494 X0L.495 X0L.496 X0L.497 X0L.498
     X0L.499 X0L.500 X0L.501 X0L.502 X0L.503 X0L.504 X0L.505 X0L.506 X0L.507
     X0L.508 X0L.509 X0L.510 X0L.511 X0L.512 X0L.513 X0L.514 X0L.515 X0L.516
     X0L.517 X0L.518 X0L.519 X0L.520 X0L.521 X0L.522 X0L.523 X0L.524 X0L.525
     X1L.29 X0L.526 X0L.527 X0L.528 X0L.529 X0L.530 X1L.30 X0L.531 X0L.532
     X0L.533 X0L.534 X0L.535 X1L.31 X0L.536 X0L.537 X0L.538 X0L.539 X0L.540
     X1L.32 X0L.541 X0L.542 X0L.543 X0L.544 X0L.545 X1L.33 X0L.546 X0L.547
     X0L.548 X0L.549 X0L.550 X1L.34 X0L.551 X0L.552 X0L.553 X0L.554 X0L.555
     X1L.35 X0L.556 X0L.557 X0L.558 X0L.559 X0L.560 X1L.36 X0L.561 X0L.562
     X0L.563 X0L.564 X0L.565 X1L.37 X0L.566 X0L.567 X0L.568 X0L.569 X0L.570
     X1L.38 X0L.571 X0L.572 X0L.573 X0L.574 X0L.575 X1L.39 X0L.576 X0L.577
     X0L.578 X0L.579 X0L.580 X1L.40 X0L.581 X0L.582 X0L.583 X0L.584 X0L.585
     X1L.41 X0L.586 X0L.587 X0L.588 X0L.589 X0L.590 X0L.591 X0L.592 X0L.593
     X0L.594 X0L.595 X0L.596 X1L.42 X0L.597 X0L.598 X0L.599 X0L.600 X0L.601
     X1L.43 X0L.602 X0L.603 X0L.604 X0L.605 X0L.606 X1L.44 X0L.607 X0L.608
     X0L.609 X0L.610 X0L.611 X1L.45 X0L.612 X0L.613 X0L.614 X0L.615 X0L.616
     X1L.46 X0L.617 X0L.618 X0L.619 X0L.620 X0L.621 X1L.47 X0L.622 X0L.623
     X0L.624 X0L.625 X0L.626 X1L.48 X0L.627 X0L.628 X0L.629 X0L.630 X0L.631
     X0L.632 X0L.633 X0L.634 X0L.635 X0L.636 X0L.637 X1L.49 X0L.638 X0L.639
     X0L.640 X0L.641 X0L.642 X1L.50 X0L.643 X0L.644 X0L.645 X0L.646 X0L.647
     X1L.51 X0L.648 X0L.649 X0L.650 X0L.651 X0L.652 X1L.52 X0L.653 X0L.654
     X0L.655 X0L.656 X0L.657 X1L.53 X0L.658 X0L.659 X0L.660 X0L.661 X0L.662
     X1L.54 X0L.663 X0L.664 X0L.665 X0L.666 X0L.667 X1L.55 X0L.668 X0L.669
     X0L.670 X0L.671 X0L.672 X1L.56 X0L.673 X0L.674 X0L.675 X0L.676 X0L.677
     X0L.678 X0L.679 X0L.680 X0L.681 X0L.682 X0L.683 X1L.57 X0L.684 X0L.685
     X0L.686 X0L.687 X0L.688 X1L.58 X0L.689 X0L.690 X0L.691 X0L.692 X0L.693
     X1L.59 X0L.694 X0L.695 X0L.696 X0L.697 X0L.698 X1L.60 X0L.699 X0L.700
     X0L.701 X0L.702 X0L.703 X1L.61 X0L.704 X0L.705 X0L.706 X0L.707 X0L.708
     X1L.62 X0L.709 X0L.710 X0L.711 X0L.712 X0L.713 X0L.714 X0L.715 X0L.716
     X0L.717 X0L.718 X0L.719 X1L.63 X0L.720 X0L.721 X0L.722 X0L.723 X0L.724
     X1L.64 X0L.725 X0L.726 X0L.727 X0L.728 X0L.729 X1L.65 X0L.730 X0L.731
     X0L.732 X0L.733 X0L.734 X1L.66 X0L.735 X0L.736 X0L.737 X0L.738 X0L.739
     X1L.67 X0L.740 X0L.741 X0L.742 X0L.743 X0L.744 X1L.68 X0L.745 X0L.746
     X0L.747 X0L.748 X0L.749 X1L.69 X0L.750 X0L.751 X0L.752 X0L.753 X0L.754
     X1L.70 X0L.755 X0L.756 X0L.757 X0L.758 X0L.759 X1L.71 X0L.760 X0L.761
     X0L.762 X0L.763 X0L.764 X1L.72 X0L.765 X0L.766 X0L.767 X0L.768 X0L.769
     X1L.73 X0L.770 X0L.771 X0L.772 X0L.773 X0L.774 X1L.74 X0L.775 X0L.776
     X0L.777 X0L.778 X0L.779 X1L.75 X0L.780 X0L.781 X0L.782 X0L.783 X0L.784
     X1L.76 X0L.785 X0L.786 X0L.787 X0L.788 X0L.789 X1L.77 X0L.790 X0L.791
     X0L.792 X0L.793 X0L.794 X1L.78 X0L.795 X0L.796 X0L.797 X0L.798 X0L.799
     X1L.79 X0L.800 X0L.801 X0L.802 X0L.803 X0L.804 X1L.80 X0L.805 X0L.806
     X0L.807 X0L.808 X0L.809 X0L.810 X0L.811 X0L.812 X0L.813 X0L.814 X0L.815
     X1L.81 X0L.816 X0L.817 X0L.818 X0L.819 X0L.820 X1L.82 X0L.821 X0L.822
     X0L.823 X0L.824 X0L.825 X1L.83 X0L.826 X0L.827 X0L.828 X0L.829 X0L.830
     X1L.84 X0L.831 X0L.832 X0L.833 X0L.834 X0L.835 X1L.85 X0L.836 X0L.837
     X0L.838 X0L.839 X0L.840 X1L.86 X0L.841 X0L.842 X0L.843 X0L.844 X0L.845
     X1L.87 X0L.846 X0L.847 X0L.848 X0L.849 X0L.850 X1L.88 X0L.851 X0L.852
     X0L.853 X0L.854 X0L.855 X1L.89 X0L.856 X0L.857 X0L.858 X0L.859 X0L.860
     X1L.90 X0L.861 X0L.862 X0L.863 X0L.864 X0L.865 X1L.91 X0L.866 X0L.867
     X0L.868 X0L.869 X0L.870 X1L.92 X0L.871 X0L.872 X0L.873 X0L.874 X0L.875
     X1L.93 X0L.876 X0L.877 X0L.878 X0L.879 X0L.880 X1L.94 X0L.881 X0L.882
     X0L.883 X0L.884 X0L.885 X0L.886 X0L.887 X0L.888 X0L.889 X0L.890 X0L.891
     X1L.95 X0L.892 X0L.893 X0L.894 X0L.895 X0L.896 X1L.96 X0L.897 X0L.898
     X0L.899 X0L.900 X0L.901 X1L.97 X0L.902 X0L.903 X0L.904 X0L.905 X0L.906
     X1L.98 X0L.907 X0L.908 X0L.909 X0L.910 X0L.911 X1L.99 X0L.912 X0L.913
     X0L.914 X0L.915 X0L.916 X0L.917 X0L.918 X0L.919 X0L.920 X0L.921 X0L.922
     X1L.100 X0L.923 X0L.924 X0L.925 X0L.926 X0L.927 X1L.101 X0L.928 X0L.929
     X0L.930 X0L.931 X0L.932 X1L.102 X0L.933 X0L.934 X0L.935 X0L.936 X0L.937
     X1L.103 X0L.938 X0L.939 X0L.940 X0L.941 X0L.942 X0L.943 X0L.944 X0L.945
     X0L.946 X0L.947 X0L.948 X1L.104 X0L.949 X0L.950 X0L.951 X0L.952 X0L.953
     X1L.105 X0L.954 X0L.955 X0L.956 X0L.957 X0L.958 X1L.106 X0L.959 X0L.960
     X0L.961 X0L.962 X0L.963 X1L.107 X0L.964 X0L.965 X0L.966 X0L.967 X0L.968
     X1L.108 X0L.969 X0L.970 X0L.971 X0L.972 X0L.973 X1L.109 X0L.974 X0L.975
     X0L.976 X0L.977 X0L.978 X1L.110 X0L.979 X0L.980 X0L.981 X0L.982 X0L.983
     X1L.111 X0L.984 X0L.985 X0L.986 X0L.987 X0L.988 X1L.112 X0L.989 X0L.990
     X0L.991 X0L.992 X0L.993 X0L.994 X0L.995 X0L.996 X0L.997 X0L.998 X0L.999
     X0L.1000 X0L.1001 X0L.1002 X0L.1003 X0L.1004 X0L.1005 X0L.1006 X0L.1007
     X0L.1008 X0L.1009 X0L.1010 X0L.1011 X0L.1012 X0L.1013 X0L.1014 X0L.1015
     X0L.1016 X0L.1017 X0L.1018 X0L.1019 X0L.1020 X0L.1021 X0L.1022 X0L.1023
     X1L.113 X0L.1024 X0L.1025 X0L.1026 X0L.1027 X0L.1028 X1L.114 X0L.1029
     X0L.1030 X0L.1031 X0L.1032 X0L.1033 X1L.115 X0L.1034 X0L.1035 X0L.1036
     X0L.1037 X0L.1038 X1L.116 X0L.1039 X0L.1040 X0L.1041 X0L.1042 X0L.1043
     X1L.117 X0L.1044 X0L.1045 X0L.1046 X0L.1047 X0L.1048 X0L.1049 X0L.1050
     X0L.1051 X0L.1052 X0L.1053 X0L.1054 X0L.1055 X0L.1056 X0L.1057 X0L.1058
     X0L.1059 X0L.1060 X0L.1061 X0L.1062 X0L.1063 X0L.1064 X0L.1065 X0L.1066
     X0L.1067 X0L.1068 X0L.1069 X0L.1070 X0L.1071 X0L.1072 X0L.1073 X0L.1074
     X0L.1075 X0L.1076 X0L.1077 X0L.1078 X0L.1079 X0L.1080 X0L.1081 X0L.1082
     X0L.1083 X0L.1084 X0L.1085 X0L.1086 X0L.1087 X0L.1088 X0L.1089 X0L.1090
     X0L.1091 X0L.1092 X0L.1093 X0L.1094 X0L.1095 X0L.1096 X0L.1097 X0L.1098
     X0L.1099 X0L.1100 X0L.1101 X0L.1102 X0L.1103 X0L.1104 X0L.1105 X0L.1106
     X0L.1107 X0L.1108 X0L.1109 X0L.1110 X0L.1111 X0L.1112 X0L.1113 X0L.1114
     X0L.1115 X0L.1116 X0L.1117 X0L.1118 X0L.1119 X0L.1120 X0L.1121 X0L.1122
     X0L.1123 X0L.1124 X0L.1125 X0L.1126 X0L.1127 X0L.1128 X0L.1129 X0L.1130
     X0L.1131 X0L.1132 X0L.1133 X0L.1134 X0L.1135 X0L.1136 X0L.1137 X0L.1138
     X0L.1139 X0L.1140 X0L.1141 X0L.1142 X0L.1143 X0L.1144 X0L.1145 X0L.1146
     X0L.1147 X0L.1148 X0L.1149 X0L.1150 X0L.1151 X0L.1152 X0L.1153 X0L.1154
     X0L.1155 X0L.1156 X0L.1157 X0L.1158 X0L.1159 X0L.1160 X0L.1161 X0L.1162
     X0L.1163 X0L.1164 X0L.1165 X0L.1166 X0L.1167 X0L.1168 X0L.1169 X0L.1170
     X0L.1171 X0L.1172 X0L.1173 X0L.1174 X0L.1175 X0L.1176 X0L.1177 X0L.1178
     X0L.1179 X0L.1180 X0L.1181 X0L.1182 X0L.1183 X0L.1184 X0L.1185 X0L.1186
     X0L.1187 X0L.1188 X0L.1189 X0L.1190 X0L.1191 X0L.1192 X0L.1193 X0L.1194
     X0L.1195 X0L.1196 X0L.1197 X0L.1198 X0L.1199 X0L.1200 X0L.1201 X0L.1202
     X0L.1203 X0L.1204 X0L.1205 X0L.1206 X0L.1207 X0L.1208 X0L.1209 X0L.1210
     X0L.1211 X0L.1212 X0L.1213 X0L.1214 X0L.1215 X0L.1216 X0L.1217 X0L.1218
     X0L.1219 X0L.1220 X0L.1221 X0L.1222 X0L.1223 X0L.1224 X0L.1225 X0L.1226
     X0L.1227 X0L.1228 X0L.1229 X0L.1230 X0L.1231 X0L.1232 X0L.1233 X0L.1234
     X0L.1235 X0L.1236 X0L.1237 X0L.1238 X0L.1239 X0L.1240 X0L.1241 X0L.1242
     X0L.1243 X0L.1244 X0L.1245 X0L.1246 X0L.1247 X0L.1248 X0L.1249 X0L.1250
     X0L.1251 X0L.1252 X0L.1253 X0L.1254 X0L.1255 X0L.1256 X0L.1257 X0L.1258
     X0L.1259 X0L.1260 X0L.1261 X0L.1262 X0L.1263 X0L.1264 X0L.1265 X0L.1266
     X0L.1267 X0L.1268 X0L.1269 X0L.1270 X0L.1271 X0L.1272 X0L.1273 X0L.1274
     X0L.1275 X0L.1276 X0L.1277 X0L.1278 X0L.1279 X0L.1280 X0L.1281 X0L.1282
     X0L.1283 X0L.1284 X0L.1285 X0L.1286 X0L.1287 X0L.1288 X0L.1289 X0L.1290
     X0L.1291 X0L.1292 X0L.1293 X0L.1294 X0L.1295 X0L.1296 X0L.1297 X0L.1298
     X0L.1299 X0L.1300 X0L.1301 X0L.1302 X0L.1303 X0L.1304 X0L.1305 X0L.1306
     X0L.1307 X0L.1308 X0L.1309 X0L.1310 X0L.1311 X0L.1312 X0L.1313 X0L.1314
     X0L.1315 X0L.1316 X0L.1317 X0L.1318 X0L.1319 X0L.1320 X0L.1321 X0L.1322
     X0L.1323 X0L.1324 X0L.1325 X0L.1326 X0L.1327 X0L.1328 X0L.1329 X0L.1330
     X0L.1331 X0L.1332 X0L.1333 X0L.1334 X0L.1335 X0L.1336 X0L.1337 X0L.1338
     X0L.1339 X0L.1340 X0L.1341 X0L.1342 X0L.1343
 [ reached 'max' / getOption("max.print") -- omitted 332 rows ]
</code>```

答:
It's difficult to diagnose the issue without having access to your files. However, the main problem could be your use of complete.cases. This returns a logical vector with length equal to the number of rows in a data frame. TRUE values are complete cases, FALSE are incomplete. In your code, you seem to be concatenating the entire vector together for every file, while per your description, you really just want a single number for every file.

Viewed this way, I think your use of table here is unnecessary, since you can create your summary simply by summing the result of complete.cases. Moreover, one should not grow a data frame the way you are doing. It is better to preallocate the data frame and fill in the elements as you go.

Putting all of this together, I would rewrite your function in the following way:

```<code>complete <- function(pathway, id=1:332){
  files_list <- list.files(path = pathway, pattern = ".csv", full.names = TRUE)
  final_result <- data.frame(id = id, nobs = as.numeric(NA))
  for(i in id){
    storefiles <- read.csv(files_list[i])
    final_result$nobs[i] <- sum(complete.cases(storefiles))
  }
  return(final_result)
}
</code>```

To further illustrate the problem, consider this simple example:

```<code>df.example <- data.frame(a = 1:3, b = c(NA, 5, 6))

  a  b
1 1 NA
2 2  5
3 3  6

# for a 3-row data set, the function returns a vector of length 3
complete.cases(df.example)
[1] FALSE  TRUE  TRUE

# a count of the 2 complete rows
sum(complete.cases(df.example))
[1] 2
</code>```

Body:
I am creating a function that takes an argument which pathway of a bunch of CSV files and check each of them for the number of complete cases and at the end, it gives you a table that has the file number and the number of complete cases in it.

complete <- function(pathway, id=1:332){
  files_list <- list.files(path = pathway, pattern = ".csv", full.names = TRUE)
  final_result <- data.frame(id = numeric(), nobs = numeric())
  for(i in id){
    storefiles <- read.csv(files_list[i])
    data_vector <- numeric()
    data_vector <- c(i, complete.cases(storefiles))
    final_result <- rbind(final_result, data_vector)
  }
  table(final_result)
}

so when I run the function it gives me this error (note the files' names are just numbers (001.csv, 002.csv, 003.csv ...)

> complete("specdata")
 Error in table(final_result) :
attempt to make a table with >= 2^31 elements
3.
stop("attempt to make a table with >= 2^31 elements")
2.
table(final_result)
1.
complete("specdata")

when I remove the table function to show the full data frame.

> complete <- function(pathway, id=1:332){
+   files_list <- list.files(path = pathway, pattern = ".csv", full.names = TRUE)
+   final_result <- data.frame(id = numeric(), nobs = numeric())
+   for(i in id){
+     storefiles <- read.csv(files_list[i])
+     data_vector <- numeric()
+     data_vector <- c(i, complete.cases(storefiles))
+     final_result <- rbind(final_result, data_vector)
+   }
+ }
> complete("specdata")
> complete <- function(pathway, id=1:332){
+   files_list <- list.files(path = pathway, pattern = ".csv", full.names = TRUE)
+   final_result <- data.frame(id = numeric(), nobs = numeric())
+   for(i in id){
+     storefiles <- read.csv(files_list[i])
+     data_vector <- numeric()
+     data_vector <- c(i, complete.cases(storefiles))
+     final_result <- rbind(final_result, data_vector)
+   }
+   final_result
+ }
> complete("specdata")
     X1L X0L X0L.1 X0L.2 X0L.3 X0L.4 X0L.5 X0L.6 X0L.7 X0L.8 X0L.9 X0L.10 X0L.11
     X0L.12 X0L.13 X0L.14 X0L.15 X0L.16 X0L.17 X0L.18 X0L.19 X0L.20 X0L.21
     X0L.22 X0L.23 X0L.24 X0L.25 X0L.26 X0L.27 X0L.28 X0L.29 X0L.30 X0L.31
     X0L.32 X0L.33 X0L.34 X0L.35 X0L.36 X0L.37 X0L.38 X0L.39 X0L.40 X0L.41
     X0L.42 X0L.43 X0L.44 X0L.45 X0L.46 X0L.47 X0L.48 X0L.49 X0L.50 X0L.51
     X0L.52 X0L.53 X0L.54 X0L.55 X0L.56 X0L.57 X0L.58 X0L.59 X0L.60 X0L.61
     X0L.62 X0L.63 X0L.64 X0L.65 X0L.66 X0L.67 X0L.68 X0L.69 X0L.70 X0L.71
     X0L.72 X0L.73 X0L.74 X0L.75 X0L.76 X0L.77 X0L.78 X0L.79 X0L.80 X0L.81
     X0L.82 X0L.83 X0L.84 X0L.85 X0L.86 X0L.87 X0L.88 X0L.89 X0L.90 X0L.91
     X0L.92 X0L.93 X0L.94 X0L.95 X0L.96 X0L.97 X0L.98 X0L.99 X0L.100 X0L.101
     X0L.102 X0L.103 X0L.104 X0L.105 X0L.106 X0L.107 X0L.108 X0L.109 X0L.110
     X0L.111 X0L.112 X0L.113 X0L.114 X0L.115 X0L.116 X0L.117 X0L.118 X0L.119
     X0L.120 X0L.121 X0L.122 X0L.123 X0L.124 X0L.125 X0L.126 X0L.127 X0L.128
     X0L.129 X0L.130 X0L.131 X0L.132 X0L.133 X0L.134 X0L.135 X0L.136 X0L.137
     X0L.138 X0L.139 X0L.140 X0L.141 X0L.142 X0L.143 X0L.144 X0L.145 X0L.146
     X0L.147 X0L.148 X0L.149 X0L.150 X0L.151 X0L.152 X0L.153 X0L.154 X0L.155
     X0L.156 X0L.157 X0L.158 X0L.159 X0L.160 X0L.161 X0L.162 X0L.163 X0L.164
     X0L.165 X0L.166 X0L.167 X0L.168 X0L.169 X0L.170 X0L.171 X0L.172 X0L.173
     X0L.174 X0L.175 X0L.176 X0L.177 X0L.178 X0L.179 X0L.180 X0L.181 X0L.182
     X0L.183 X0L.184 X0L.185 X0L.186 X0L.187 X0L.188 X0L.189 X0L.190 X0L.191
     X0L.192 X0L.193 X0L.194 X0L.195 X0L.196 X0L.197 X0L.198 X0L.199 X0L.200
     X0L.201 X0L.202 X0L.203 X0L.204 X0L.205 X0L.206 X0L.207 X0L.208 X0L.209
     X0L.210 X0L.211 X0L.212 X0L.213 X0L.214 X0L.215 X0L.216 X0L.217 X0L.218
     X0L.219 X0L.220 X0L.221 X0L.222 X0L.223 X0L.224 X0L.225 X0L.226 X0L.227
     X0L.228 X0L.229 X0L.230 X0L.231 X0L.232 X0L.233 X0L.234 X0L.235 X0L.236
     X0L.237 X0L.238 X0L.239 X0L.240 X0L.241 X0L.242 X0L.243 X0L.244 X0L.245
     X0L.246 X0L.247 X0L.248 X0L.249 X0L.250 X0L.251 X0L.252 X0L.253 X0L.254
     X0L.255 X0L.256 X0L.257 X0L.258 X0L.259 X0L.260 X0L.261 X0L.262 X0L.263
     X0L.264 X0L.265 X0L.266 X0L.267 X0L.268 X0L.269 X0L.270 X0L.271 X0L.272
     X0L.273 X0L.274 X0L.275 X0L.276 X0L.277 X1L.1 X0L.278 X0L.279 X0L.280
     X0L.281 X0L.282 X1L.2 X0L.283 X0L.284 X0L.285 X0L.286 X0L.287 X1L.3 X0L.288
     X0L.289 X0L.290 X0L.291 X0L.292 X1L.4 X0L.293 X0L.294 X0L.295 X0L.296
     X0L.297 X1L.5 X0L.298 X0L.299 X0L.300 X0L.301 X0L.302 X0L.303 X0L.304
     X0L.305 X0L.306 X0L.307 X0L.308 X1L.6 X0L.309 X0L.310 X0L.311 X0L.312
     X0L.313 X1L.7 X0L.314 X0L.315 X0L.316 X0L.317 X0L.318 X1L.8 X0L.319 X0L.320
     X0L.321 X0L.322 X0L.323 X1L.9 X0L.324 X0L.325 X0L.326 X0L.327 X0L.328
     X1L.10 X0L.329 X0L.330 X0L.331 X0L.332 X0L.333 X1L.11 X0L.334 X0L.335
     X0L.336 X0L.337 X0L.338 X0L.339 X0L.340 X0L.341 X0L.342 X0L.343 X0L.344
     X1L.12 X0L.345 X0L.346 X0L.347 X0L.348 X0L.349 X1L.13 X0L.350 X0L.351
     X0L.352 X0L.353 X0L.354 X1L.14 X0L.355 X0L.356 X0L.357 X0L.358 X0L.359
     X1L.15 X0L.360 X0L.361 X0L.362 X0L.363 X0L.364 X0L.365 X0L.366 X0L.367
     X0L.368 X0L.369 X0L.370 X1L.16 X0L.371 X0L.372 X0L.373 X0L.374 X0L.375
     X1L.17 X0L.376 X0L.377 X0L.378 X0L.379 X0L.380 X1L.18 X0L.381 X0L.382
     X0L.383 X0L.384 X0L.385 X1L.19 X0L.386 X0L.387 X0L.388 X0L.389 X0L.390
     X0L.391 X0L.392 X0L.393 X0L.394 X0L.395 X0L.396 X1L.20 X0L.397 X0L.398
     X0L.399 X0L.400 X0L.401 X1L.21 X0L.402 X0L.403 X0L.404 X0L.405 X0L.406
     X1L.22 X0L.407 X0L.408 X0L.409 X0L.410 X0L.411 X1L.23 X0L.412 X0L.413
     X0L.414 X0L.415 X0L.416 X1L.24 X0L.417 X0L.418 X0L.419 X0L.420 X0L.421
     X1L.25 X0L.422 X0L.423 X0L.424 X0L.425 X0L.426 X1L.26 X0L.427 X0L.428
     X0L.429 X0L.430 X0L.431 X0L.432 X0L.433 X0L.434 X0L.435 X0L.436 X0L.437
     X0L.438 X0L.439 X0L.440 X0L.441 X0L.442 X0L.443 X0L.444 X0L.445 X0L.446
     X0L.447 X0L.448 X0L.449 X1L.27 X0L.450 X0L.451 X0L.452 X0L.453 X0L.454
     X0L.455 X0L.456 X0L.457 X0L.458 X0L.459 X0L.460 X0L.461 X0L.462 X0L.463
     X0L.464 X0L.465 X0L.466 X0L.467 X0L.468 X0L.469 X0L.470 X0L.471 X0L.472
     X1L.28 X0L.473 X0L.474 X0L.475 X0L.476 X0L.477 X0L.478 X0L.479 X0L.480
     X0L.481 X0L.482 X0L.483 X0L.484 X0L.485 X0L.486 X0L.487 X0L.488 X0L.489
     X0L.490 X0L.491 X0L.492 X0L.493 X0L.494 X0L.495 X0L.496 X0L.497 X0L.498
     X0L.499 X0L.500 X0L.501 X0L.502 X0L.503 X0L.504 X0L.505 X0L.506 X0L.507
     X0L.508 X0L.509 X0L.510 X0L.511 X0L.512 X0L.513 X0L.514 X0L.515 X0L.516
     X0L.517 X0L.518 X0L.519 X0L.520 X0L.521 X0L.522 X0L.523 X0L.524 X0L.525
     X1L.29 X0L.526 X0L.527 X0L.528 X0L.529 X0L.530 X1L.30 X0L.531 X0L.532
     X0L.533 X0L.534 X0L.535 X1L.31 X0L.536 X0L.537 X0L.538 X0L.539 X0L.540
     X1L.32 X0L.541 X0L.542 X0L.543 X0L.544 X0L.545 X1L.33 X0L.546 X0L.547
     X0L.548 X0L.549 X0L.550 X1L.34 X0L.551 X0L.552 X0L.553 X0L.554 X0L.555
     X1L.35 X0L.556 X0L.557 X0L.558 X0L.559 X0L.560 X1L.36 X0L.561 X0L.562
     X0L.563 X0L.564 X0L.565 X1L.37 X0L.566 X0L.567 X0L.568 X0L.569 X0L.570
     X1L.38 X0L.571 X0L.572 X0L.573 X0L.574 X0L.575 X1L.39 X0L.576 X0L.577
     X0L.578 X0L.579 X0L.580 X1L.40 X0L.581 X0L.582 X0L.583 X0L.584 X0L.585
     X1L.41 X0L.586 X0L.587 X0L.588 X0L.589 X0L.590 X0L.591 X0L.592 X0L.593
     X0L.594 X0L.595 X0L.596 X1L.42 X0L.597 X0L.598 X0L.599 X0L.600 X0L.601
     X1L.43 X0L.602 X0L.603 X0L.604 X0L.605 X0L.606 X1L.44 X0L.607 X0L.608
     X0L.609 X0L.610 X0L.611 X1L.45 X0L.612 X0L.613 X0L.614 X0L.615 X0L.616
     X1L.46 X0L.617 X0L.618 X0L.619 X0L.620 X0L.621 X1L.47 X0L.622 X0L.623
     X0L.624 X0L.625 X0L.626 X1L.48 X0L.627 X0L.628 X0L.629 X0L.630 X0L.631
     X0L.632 X0L.633 X0L.634 X0L.635 X0L.636 X0L.637 X1L.49 X0L.638 X0L.639
     X0L.640 X0L.641 X0L.642 X1L.50 X0L.643 X0L.644 X0L.645 X0L.646 X0L.647
     X1L.51 X0L.648 X0L.649 X0L.650 X0L.651 X0L.652 X1L.52 X0L.653 X0L.654
     X0L.655 X0L.656 X0L.657 X1L.53 X0L.658 X0L.659 X0L.660 X0L.661 X0L.662
     X1L.54 X0L.663 X0L.664 X0L.665 X0L.666 X0L.667 X1L.55 X0L.668 X0L.669
     X0L.670 X0L.671 X0L.672 X1L.56 X0L.673 X0L.674 X0L.675 X0L.676 X0L.677
     X0L.678 X0L.679 X0L.680 X0L.681 X0L.682 X0L.683 X1L.57 X0L.684 X0L.685
     X0L.686 X0L.687 X0L.688 X1L.58 X0L.689 X0L.690 X0L.691 X0L.692 X0L.693
     X1L.59 X0L.694 X0L.695 X0L.696 X0L.697 X0L.698 X1L.60 X0L.699 X0L.700
     X0L.701 X0L.702 X0L.703 X1L.61 X0L.704 X0L.705 X0L.706 X0L.707 X0L.708
     X1L.62 X0L.709 X0L.710 X0L.711 X0L.712 X0L.713 X0L.714 X0L.715 X0L.716
     X0L.717 X0L.718 X0L.719 X1L.63 X0L.720 X0L.721 X0L.722 X0L.723 X0L.724
     X1L.64 X0L.725 X0L.726 X0L.727 X0L.728 X0L.729 X1L.65 X0L.730 X0L.731
     X0L.732 X0L.733 X0L.734 X1L.66 X0L.735 X0L.736 X0L.737 X0L.738 X0L.739
     X1L.67 X0L.740 X0L.741 X0L.742 X0L.743 X0L.744 X1L.68 X0L.745 X0L.746
     X0L.747 X0L.748 X0L.749 X1L.69 X0L.750 X0L.751 X0L.752 X0L.753 X0L.754
     X1L.70 X0L.755 X0L.756 X0L.757 X0L.758 X0L.759 X1L.71 X0L.760 X0L.761
     X0L.762 X0L.763 X0L.764 X1L.72 X0L.765 X0L.766 X0L.767 X0L.768 X0L.769
     X1L.73 X0L.770 X0L.771 X0L.772 X0L.773 X0L.774 X1L.74 X0L.775 X0L.776
     X0L.777 X0L.778 X0L.779 X1L.75 X0L.780 X0L.781 X0L.782 X0L.783 X0L.784
     X1L.76 X0L.785 X0L.786 X0L.787 X0L.788 X0L.789 X1L.77 X0L.790 X0L.791
     X0L.792 X0L.793 X0L.794 X1L.78 X0L.795 X0L.796 X0L.797 X0L.798 X0L.799
     X1L.79 X0L.800 X0L.801 X0L.802 X0L.803 X0L.804 X1L.80 X0L.805 X0L.806
     X0L.807 X0L.808 X0L.809 X0L.810 X0L.811 X0L.812 X0L.813 X0L.814 X0L.815
     X1L.81 X0L.816 X0L.817 X0L.818 X0L.819 X0L.820 X1L.82 X0L.821 X0L.822
     X0L.823 X0L.824 X0L.825 X1L.83 X0L.826 X0L.827 X0L.828 X0L.829 X0L.830
     X1L.84 X0L.831 X0L.832 X0L.833 X0L.834 X0L.835 X1L.85 X0L.836 X0L.837
     X0L.838 X0L.839 X0L.840 X1L.86 X0L.841 X0L.842 X0L.843 X0L.844 X0L.845
     X1L.87 X0L.846 X0L.847 X0L.848 X0L.849 X0L.850 X1L.88 X0L.851 X0L.852
     X0L.853 X0L.854 X0L.855 X1L.89 X0L.856 X0L.857 X0L.858 X0L.859 X0L.860
     X1L.90 X0L.861 X0L.862 X0L.863 X0L.864 X0L.865 X1L.91 X0L.866 X0L.867
     X0L.868 X0L.869 X0L.870 X1L.92 X0L.871 X0L.872 X0L.873 X0L.874 X0L.875
     X1L.93 X0L.876 X0L.877 X0L.878 X0L.879 X0L.880 X1L.94 X0L.881 X0L.882
     X0L.883 X0L.884 X0L.885 X0L.886 X0L.887 X0L.888 X0L.889 X0L.890 X0L.891
     X1L.95 X0L.892 X0L.893 X0L.894 X0L.895 X0L.896 X1L.96 X0L.897 X0L.898
     X0L.899 X0L.900 X0L.901 X1L.97 X0L.902 X0L.903 X0L.904 X0L.905 X0L.906
     X1L.98 X0L.907 X0L.908 X0L.909 X0L.910 X0L.911 X1L.99 X0L.912 X0L.913
     X0L.914 X0L.915 X0L.916 X0L.917 X0L.918 X0L.919 X0L.920 X0L.921 X0L.922
     X1L.100 X0L.923 X0L.924 X0L.925 X0L.926 X0L.927 X1L.101 X0L.928 X0L.929
     X0L.930 X0L.931 X0L.932 X1L.102 X0L.933 X0L.934 X0L.935 X0L.936 X0L.937
     X1L.103 X0L.938 X0L.939 X0L.940 X0L.941 X0L.942 X0L.943 X0L.944 X0L.945
     X0L.946 X0L.947 X0L.948 X1L.104 X0L.949 X0L.950 X0L.951 X0L.952 X0L.953
     X1L.105 X0L.954 X0L.955 X0L.956 X0L.957 X0L.958 X1L.106 X0L.959 X0L.960
     X0L.961 X0L.962 X0L.963 X1L.107 X0L.964 X0L.965 X0L.966 X0L.967 X0L.968
     X1L.108 X0L.969 X0L.970 X0L.971 X0L.972 X0L.973 X1L.109 X0L.974 X0L.975
     X0L.976 X0L.977 X0L.978 X1L.110 X0L.979 X0L.980 X0L.981 X0L.982 X0L.983
     X1L.111 X0L.984 X0L.985 X0L.986 X0L.987 X0L.988 X1L.112 X0L.989 X0L.990
     X0L.991 X0L.992 X0L.993 X0L.994 X0L.995 X0L.996 X0L.997 X0L.998 X0L.999
     X0L.1000 X0L.1001 X0L.1002 X0L.1003 X0L.1004 X0L.1005 X0L.1006 X0L.1007
     X0L.1008 X0L.1009 X0L.1010 X0L.1011 X0L.1012 X0L.1013 X0L.1014 X0L.1015
     X0L.1016 X0L.1017 X0L.1018 X0L.1019 X0L.1020 X0L.1021 X0L.1022 X0L.1023
     X1L.113 X0L.1024 X0L.1025 X0L.1026 X0L.1027 X0L.1028 X1L.114 X0L.1029
     X0L.1030 X0L.1031 X0L.1032 X0L.1033 X1L.115 X0L.1034 X0L.1035 X0L.1036
     X0L.1037 X0L.1038 X1L.116 X0L.1039 X0L.1040 X0L.1041 X0L.1042 X0L.1043
     X1L.117 X0L.1044 X0L.1045 X0L.1046 X0L.1047 X0L.1048 X0L.1049 X0L.1050
     X0L.1051 X0L.1052 X0L.1053 X0L.1054 X0L.1055 X0L.1056 X0L.1057 X0L.1058
     X0L.1059 X0L.1060 X0L.1061 X0L.1062 X0L.1063 X0L.1064 X0L.1065 X0L.1066
     X0L.1067 X0L.1068 X0L.1069 X0L.1070 X0L.1071 X0L.1072 X0L.1073 X0L.1074
     X0L.1075 X0L.1076 X0L.1077 X0L.1078 X0L.1079 X0L.1080 X0L.1081 X0L.1082
     X0L.1083 X0L.1084 X0L.1085 X0L.1086 X0L.1087 X0L.1088 X0L.1089 X0L.1090
     X0L.1091 X0L.1092 X0L.1093 X0L.1094 X0L.1095 X0L.1096 X0L.1097 X0L.1098
     X0L.1099 X0L.1100 X0L.1101 X0L.1102 X0L.1103 X0L.1104 X0L.1105 X0L.1106
     X0L.1107 X0L.1108 X0L.1109 X0L.1110 X0L.1111 X0L.1112 X0L.1113 X0L.1114
     X0L.1115 X0L.1116 X0L.1117 X0L.1118 X0L.1119 X0L.1120 X0L.1121 X0L.1122
     X0L.1123 X0L.1124 X0L.1125 X0L.1126 X0L.1127 X0L.1128 X0L.1129 X0L.1130
     X0L.1131 X0L.1132 X0L.1133 X0L.1134 X0L.1135 X0L.1136 X0L.1137 X0L.1138
     X0L.1139 X0L.1140 X0L.1141 X0L.1142 X0L.1143 X0L.1144 X0L.1145 X0L.1146
     X0L.1147 X0L.1148 X0L.1149 X0L.1150 X0L.1151 X0L.1152 X0L.1153 X0L.1154
     X0L.1155 X0L.1156 X0L.1157 X0L.1158 X0L.1159 X0L.1160 X0L.1161 X0L.1162
     X0L.1163 X0L.1164 X0L.1165 X0L.1166 X0L.1167 X0L.1168 X0L.1169 X0L.1170
     X0L.1171 X0L.1172 X0L.1173 X0L.1174 X0L.1175 X0L.1176 X0L.1177 X0L.1178
     X0L.1179 X0L.1180 X0L.1181 X0L.1182 X0L.1183 X0L.1184 X0L.1185 X0L.1186
     X0L.1187 X0L.1188 X0L.1189 X0L.1190 X0L.1191 X0L.1192 X0L.1193 X0L.1194
     X0L.1195 X0L.1196 X0L.1197 X0L.1198 X0L.1199 X0L.1200 X0L.1201 X0L.1202
     X0L.1203 X0L.1204 X0L.1205 X0L.1206 X0L.1207 X0L.1208 X0L.1209 X0L.1210
     X0L.1211 X0L.1212 X0L.1213 X0L.1214 X0L.1215 X0L.1216 X0L.1217 X0L.1218
     X0L.1219 X0L.1220 X0L.1221 X0L.1222 X0L.1223 X0L.1224 X0L.1225 X0L.1226
     X0L.1227 X0L.1228 X0L.1229 X0L.1230 X0L.1231 X0L.1232 X0L.1233 X0L.1234
     X0L.1235 X0L.1236 X0L.1237 X0L.1238 X0L.1239 X0L.1240 X0L.1241 X0L.1242
     X0L.1243 X0L.1244 X0L.1245 X0L.1246 X0L.1247 X0L.1248 X0L.1249 X0L.1250
     X0L.1251 X0L.1252 X0L.1253 X0L.1254 X0L.1255 X0L.1256 X0L.1257 X0L.1258
     X0L.1259 X0L.1260 X0L.1261 X0L.1262 X0L.1263 X0L.1264 X0L.1265 X0L.1266
     X0L.1267 X0L.1268 X0L.1269 X0L.1270 X0L.1271 X0L.1272 X0L.1273 X0L.1274
     X0L.1275 X0L.1276 X0L.1277 X0L.1278 X0L.1279 X0L.1280 X0L.1281 X0L.1282
     X0L.1283 X0L.1284 X0L.1285 X0L.1286 X0L.1287 X0L.1288 X0L.1289 X0L.1290
     X0L.1291 X0L.1292 X0L.1293 X0L.1294 X0L.1295 X0L.1296 X0L.1297 X0L.1298
     X0L.1299 X0L.1300 X0L.1301 X0L.1302 X0L.1303 X0L.1304 X0L.1305 X0L.1306
     X0L.1307 X0L.1308 X0L.1309 X0L.1310 X0L.1311 X0L.1312 X0L.1313 X0L.1314
     X0L.1315 X0L.1316 X0L.1317 X0L.1318 X0L.1319 X0L.1320 X0L.1321 X0L.1322
     X0L.1323 X0L.1324 X0L.1325 X0L.1326 X0L.1327 X0L.1328 X0L.1329 X0L.1330
     X0L.1331 X0L.1332 X0L.1333 X0L.1334 X0L.1335 X0L.1336 X0L.1337 X0L.1338
     X0L.1339 X0L.1340 X0L.1341 X0L.1342 X0L.1343
 [ reached 'max' / getOption("max.print") -- omitted 332 rows ]

Body:
It's difficult to diagnose the issue without having access to your files. However, the main problem could be your use of complete.cases. This returns a logical vector with length equal to the number of rows in a data frame. TRUE values are complete cases, FALSE are incomplete. In your code, you seem to be concatenating the entire vector together for every file, while per your description, you really just want a single number for every file.

Viewed this way, I think your use of table here is unnecessary, since you can create your summary simply by summing the result of complete.cases. Moreover, one should not grow a data frame the way you are doing. It is better to preallocate the data frame and fill in the elements as you go.

Putting all of this together, I would rewrite your function in the following way:

complete <- function(pathway, id=1:332){
  files_list <- list.files(path = pathway, pattern = ".csv", full.names = TRUE)
  final_result <- data.frame(id = id, nobs = as.numeric(NA))
  for(i in id){
    storefiles <- read.csv(files_list[i])
    final_result$nobs[i] <- sum(complete.cases(storefiles))
  }
  return(final_result)
}

To further illustrate the problem, consider this simple example:

df.example <- data.frame(a = 1:3, b = c(NA, 5, 6))

  a  b
1 1 NA
2 2  5
3 3  6

# for a 3-row data set, the function returns a vector of length 3
complete.cases(df.example)
[1] FALSE  TRUE  TRUE

# a count of the 2 complete rows
sum(complete.cases(df.example))
[1] 2


问:
Jupyter-Flex on Databricks
I am using python Jupyter-Flex to replicate a R flexdashboard. I am able to create a html dashboard in my local in jupyterlab. Can I create the same in Databricks. Is it possible?</p>

答: Yes, I have done this before in the databricks you can use ipywidgets==7.6.5 in the databricks library section. I was running the 6.4 Spark version in the databricks so I specify version number you can go without the version number.</p>

Title: Jupyter-Flex on Databricks


问:
Can I connect to my .Net 6 web app running in Azure with VS Code to set breakpoints and debug?
I've pushed my .Net6 web app (Angular front end) to Azure and I can connect to the url and see and run the website.

Question - I want to know if there is a way to test the instance running in Azure and set a breakpoint on one of my controllers and debug it? Is this possible from VS Code? If so how would I do it and is there a link somewhere with a tutorial to get me started?

FYI - I currently have the Azure extension installed in VS Code. I used it to push/publish the app to Azure. I can see when I right click on the app service there is a option called "start remote debugging". I clicked it, but VS shows a error message in the bottom left corner saying "Azure Remote Debugging is currently only supported for Node.js apps on Linux." I'm not using Linux. I believe my server running the app is a Win server and I because it's a .Net 6 app, it's using .Net on the server side, not Node.

It seems like this is what I want but it's for Visual Studio, not Visual Studio Code.
link

I've also set the 'Remote Debugging' to 'On' in the configuration section of the app service. But it only shows a Visual Studio version, nothing for VS Code. Does this mean no go for VS Code?

答:
I want to know if there is a way to test the instance running in
Azure and set a breakpoint on one of my controllers and debug it? Is
this possible from VS Code? If so how would I do it and is there a
link somewhere with a tutorial to get me started

As Per the visual studio code documentation currently, vscode supports remote debugging only Node.js applications. It doesn't support remote debugging: this is a feature of the debug extension.

If you want to debug a .Net 6 app, we suggest you to use Visual studio instead of visual studio code.

You can refer to this documentation for more information about Remote debug ASP.net core on Azure or this SO thread

I've also set the 'Remote Debugging' to 'On' in the configuration
section of the app service. But it only shows a Visual Studio version,
nothing for VS Code. Does this mean no go for VS Code?

Yes, Currently remote debugging is supported in Visual studio only.


问:
how to get images from a directory using glob - previous post not working
I'm new to php and I'm trying to get a directory listing of images.

I saw this post: How to get random image from directory using PHP

I am trying to do nearly the same thing- choosing a random image and drawing it to the page via an  tag.

For some reason, the specification to the directory that I am using doesn't work, but I'm not sure why.  I've tried the following:

```<code>$localdir = $_SERVER['DOCUMENT_ROOT'] . '/wp_content/themes/overlandconsulting_2010/images/headers/*.{jpg,gif,png}';
$images = glob($localdir, GLOB_BRACE);

$httpdir = $_SERVER['SERVER_NAME'] . '/wp_content/themes/overlandconsulting_2010/images/headers/*.{jpg,gif,png}';
$images = glob($httpdir, GLOB_BRACE);
</code>```

Neither seems to find any images.  :s
FWIW, I can navigate to the directory explicitly and see the contents, like
this

It seems like the server won't let me access the images, but honestly I have no idea.

Thanks for any help!
jml

答: the url in the code has wp_content with an underscore while the link to the directory has wp-content with a hyphen.

Body:
I'm new to php and I'm trying to get a directory listing of images.

I saw this post: How to get random image from directory using PHP

I am trying to do nearly the same thing- choosing a random image and drawing it to the page via an  tag.

For some reason, the specification to the directory that I am using doesn't work, but I'm not sure why.  I've tried the following:

$localdir = $_SERVER['DOCUMENT_ROOT'] . '/wp_content/themes/overlandconsulting_2010/images/headers/*.{jpg,gif,png}';
$images = glob($localdir, GLOB_BRACE);

$httpdir = $_SERVER['SERVER_NAME'] . '/wp_content/themes/overlandconsulting_2010/images/headers/*.{jpg,gif,png}';
$images = glob($httpdir, GLOB_BRACE);

Neither seems to find any images.  :s
FWIW, I can navigate to the directory explicitly and see the contents, like
this

It seems like the server won't let me access the images, but honestly I have no idea.

Thanks for any help!
jml


问:
Cannot reach service in docker container despite port mapping with docker-compose
I have these file to start a webserver inside a docker container. I can see the service running in the container at port 8000, but I cannot access it via the web browser.

Dockerfile

```<code>FROM continuumio/miniconda3
ENV PYTHONUNBUFFERED=1
RUN mkdir /static
SHELL ["/bin/bash", "-c"]
RUN apt update && apt install -y build-essential time libgraphviz-dev graphviz
RUN conda create -n env -c conda-forge python==3.10 django==4 pip #&& conda init bash
COPY backend/requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY ./backend /backend
WORKDIR /backend/
</code>```

docker-compose file

```<code>version: "3.3"

services:
  backend:
    container_name: backend
    restart: always
    user: ${UID}
    build:
      context: .
      dockerfile: dockerfiles/Dockerfile-backend
    env_file:
        - ./.env
    command: ./manage.py runserver
    volumes:
      - ./backend/:/backend/
      - ${STATIC}:/static/
    ports:
      - "127.0.0.1:8000:8000"
    depends_on:
      - db

  db:
    container_name: db
    restart: always
    image: postgres:13.4
    volumes:
      - ${DB}:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
</code>```

I am running docker on an Ubuntu 20.04 VM and I have a port forwarding to that VM. I used commands like docker network prune before, so I am not sure, whether I deleted a requirement. I also tried stopping the container and run docker container prune and docker-compose up, but it does not work as it should.

```<code>curl localhost:8000
>>> curl: (56) Recv failure: Connection reset by peer
</code>```

答:
The service inside the container should be served at IP address: 0.0.0.0
For some strange reason 127.0.0.1 does not work.</p>

Body:
I have these file to start a webserver inside a docker container. I can see the service running in the container at port 8000, but I cannot access it via the web browser.

Dockerfile

FROM continuumio/miniconda3
ENV PYTHONUNBUFFERED=1
RUN mkdir /static
SHELL ["/bin/bash", "-c"]
RUN apt update && apt install -y build-essential time libgraphviz-dev graphviz
RUN conda create -n env -c conda-forge python==3.10 django==4 pip #&& conda init bash
COPY backend/requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY ./backend /backend
WORKDIR /backend/

docker-compose file

version: "3.3"

services:
  backend:
    container_name: backend
    restart: always
    user: ${UID}
    build:
      context: .
      dockerfile: dockerfiles/Dockerfile-backend
    env_file:
        - ./.env
    command: ./manage.py runserver
    volumes:
      - ./backend/:/backend/
      - ${STATIC}:/static/
    ports:
      - "127.0.0.1:8000:8000"
    depends_on:
      - db

  db:
    container_name: db
    restart: always
    image: postgres:13.4
    volumes:
      - ${DB}:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres

I am running docker on an Ubuntu 20.04 VM and I have a port forwarding to that VM. I used commands like docker network prune before, so I am not sure, whether I deleted a requirement. I also tried stopping the container and run docker container prune and docker-compose up, but it does not work as it should.

curl localhost:8000
>>> curl: (56) Recv failure: Connection reset by peer


问:
How to delete a blank row with all empty cell and keep others row that have some empty cell?
I have a mircosoft office excel file like that,

when I use the method: Find special-> blank it search all row, but I only want to delete all blank row, how to realize it?

答:
Throw this into a module in VBA, select your range of cells you want to process and then run the macro ...

```<code>Public Sub DeleteBlankRows()
    Dim objRow As Range

    Application.ScreenUpdating = False
    Application.EnableEvents = False

    On Error GoTo ExitGracefully

    With Selection
        For lngRow = .Rows.Count To 1 Step -1
            For Each objRow In .Rows(lngRow)
                If WorksheetFunction.CountBlank(objRow) = objRow.Cells.Count Then
                    objRow.Delete xlShiftUp
                End If
            Next
        Next
    End With

ExitGracefully:
    Application.ScreenUpdating = True
    Application.EnableEvents = True
End Sub
</code>```

... it will process each row individually and determine if the amount of cells that are blank match the total amount of cells in the row that you have selected.  If they match, it will shift all cells up.

If you want to delete the entire row across the worksheet, change this line ..

```<code>objRow.Delete xlShiftUp
</code>```

... to this ...

```<code>objRow.EntireRow.Delete xlShiftUp
</code>```

Body:
Throw this into a module in VBA, select your range of cells you want to process and then run the macro ...

Public Sub DeleteBlankRows()
    Dim objRow As Range

    Application.ScreenUpdating = False
    Application.EnableEvents = False

    On Error GoTo ExitGracefully

    With Selection
        For lngRow = .Rows.Count To 1 Step -1
            For Each objRow In .Rows(lngRow)
                If WorksheetFunction.CountBlank(objRow) = objRow.Cells.Count Then
                    objRow.Delete xlShiftUp
                End If
            Next
        Next
    End With

ExitGracefully:
    Application.ScreenUpdating = True
    Application.EnableEvents = True
End Sub

... it will process each row individually and determine if the amount of cells that are blank match the total amount of cells in the row that you have selected.  If they match, it will shift all cells up.

If you want to delete the entire row across the worksheet, change this line ..

objRow.Delete xlShiftUp

... to this ...

objRow.EntireRow.Delete xlShiftUp


问:
How do I solve the AWSSecurityTokenServiceException error in Databricks?
I have been trying to read some data from an AWS S3 bucket to Databricks.  The S3 bucket is development/team/user.  I am using the Scala statement:

```<code>val test = spark.read.format("team").load("/mnt/development/team/user/data.txt")
</code>```

and I get the following:

com.amazonaws.services.securitytoken.model.AWSSecurityTokenServiceException: User [user] is not authorized to perform sts:AssumeRole on resource: [resource]

How do I resolve this error?  Is there a problem with the Databricks cluster I am running?  Is there a way to allow my Databricks role to perform sts:AssumeRole in AWS?  I am not sure if or how I can do either.

答:
Yes, I have done this before.
Here you are getting this error because STS assumes a role you can set up by selecting STS policy in the role while creating policy and you can update the trust relationship also.

This link will help you https://forums.aws.amazon.com/thread.jspa?threadID=266814

Body:
I have been trying to read some data from an AWS S3 bucket to Databricks.  The S3 bucket is development/team/user.  I am using the Scala statement:

val test = spark.read.format("team").load("/mnt/development/team/user/data.txt")

and I get the following:

com.amazonaws.services.securitytoken.model.AWSSecurityTokenServiceException: User [user] is not authorized to perform sts:AssumeRole on resource: [resource]

How do I resolve this error?  Is there a problem with the Databricks cluster I am running?  Is there a way to allow my Databricks role to perform sts:AssumeRole in AWS?  I am not sure if or how I can do either.


问:
Stripping the leading zeros but leave a single 0
So let me start of by saying that I'm new to bash so I would appreciate a simple explanation on the answers you give.

I've got the following block of code:

name="Chapter 0000 (sub s2).cbz "

s=$(echo $name | grep -Eo '[0-9]+([.][0-9]+)?' | tr '\n' ' ' | sed 's/^0*//')

echo $s

readarray -d " " -t myarr <<< "$s"

if [[ $(echo "${myarr[0]} < 100 && ${myarr[0]} >= 10" | bc) -ne 0 ]]; then
    myarr[0]="0${myarr[0]}"
elif [[ $(echo "${myarr[0]} < 10" | bc) -ne 0 ]]; then
    myarr[0]="00${myarr[0]}"
fi

newName="Chapter ${myarr[0]}.cbz"

echo $newName
```
<p>which (in this case) would end up spitting out:</p>
``` 2
(standard_in) 1: syntax error
(standard_in) 1: syntax error
Chapter .cbz
```
<p>(I'm fairly certain that the syntax errors are because <code>${myarr[0]}</code> is null when doing the comparisons)</p>
<p>This is not the output I want. I want the code to strip leading 0's but leave a single 0 if its all 0.</p>
<p>So the code to really change would be <code>sed 's/^0*//')</code> but I'm not sure how to change it.</p>
<p>(expected outputs:</p>
```              in   --->   out
1) chapter 8.cbz   ---> Chapter 008.cbz
2) chapter 1.3.cbz   ---> Chapter 001.3.cbz
3) _23 (sec 2).cbz   ---> Chapter 023.cbz
4) chapter 00009.cbz   ---> Chapter 009.cbz
5) chap 0000112.5.cbz   ---> Chapter 112.5.cbz
6) Chapter 0000 (sub s2).cbz   ---> Chapter 000.cbz
```

so far the code I got works for 1- 3 but not the leading 0 cases (4-6))

答:
Using sed

```<code>$ sed 's/[^0-9]*0\+\?\([0-9]\{1,\}\)[^.]*\(\..*\)/Chapter 00\1\2/;s/0\+\([0-9]\{3,\}\)/\1/' file
Chapter 008.cbz
Chapter 001.3.cbz
Chapter 023.cbz
Chapter 009.cbz
Chapter 112.5.cbz
</code>```

s/[^0-9]*0\+\?\([0-9]\{1,\}\)[^.]*\(\..*\)/Chapter 00\1\2/ - Strip everything up to a digit that is not zero, then add Chapter at the beginning as well as 2 zero after stripping the initial zeros.

s/0\+\([0-9]\{3,\}\)/\1/ - Once again, strip excess zeros ensuring only three digits before the period remain.

Body:
So let me start of by saying that I'm new to bash so I would appreciate a simple explanation on the answers you give.

I've got the following block of code:

name="Chapter 0000 (sub s2).cbz "

s=$(echo $name | grep -Eo '[0-9]+([.][0-9]+)?' | tr '\n' ' ' | sed 's/^0*//')

echo $s

readarray -d " " -t myarr <<< "$s"

if [[ $(echo "${myarr[0]} < 100 && ${myarr[0]} >= 10" | bc) -ne 0 ]]; then
    myarr[0]="0${myarr[0]}"
elif [[ $(echo "${myarr[0]} < 10" | bc) -ne 0 ]]; then
    myarr[0]="00${myarr[0]}"
fi

newName="Chapter ${myarr[0]}.cbz"

echo $newName

which (in this case) would end up spitting out:

 2
(standard_in) 1: syntax error
(standard_in) 1: syntax error
Chapter .cbz

(I'm fairly certain that the syntax errors are because ${myarr[0]} is null when doing the comparisons)

This is not the output I want. I want the code to strip leading 0's but leave a single 0 if its all 0.

So the code to really change would be sed 's/^0*//') but I'm not sure how to change it.

(expected outputs:

              in   --->   out
1) chapter 8.cbz   ---> Chapter 008.cbz
2) chapter 1.3.cbz   ---> Chapter 001.3.cbz
3) _23 (sec 2).cbz   ---> Chapter 023.cbz
4) chapter 00009.cbz   ---> Chapter 009.cbz
5) chap 0000112.5.cbz   ---> Chapter 112.5.cbz
6) Chapter 0000 (sub s2).cbz   ---> Chapter 000.cbz

so far the code I got works for 1- 3 but not the leading 0 cases (4-6))

Body:
Using sed

$ sed 's/[^0-9]*0\+\?\([0-9]\{1,\}\)[^.]*\(\..*\)/Chapter 00\1\2/;s/0\+\([0-9]\{3,\}\)/\1/' file
Chapter 008.cbz
Chapter 001.3.cbz
Chapter 023.cbz
Chapter 009.cbz
Chapter 112.5.cbz

s/[^0-9]*0\+\?\([0-9]\{1,\}\)[^.]*\(\..*\)/Chapter 00\1\2/ - Strip everything up to a digit that is not zero, then add Chapter at the beginning as well as 2 zero after stripping the initial zeros.

s/0\+\([0-9]\{3,\}\)/\1/ - Once again, strip excess zeros ensuring only three digits before the period remain.


问:
iPhone app launching tips?
I just finished my first iPhone app. It's a little game and I want to launch it for 99 cents.

So my concerns is, how long usually does an app stay on the new released list. ALso, is there any launching tips on timing etc?

Thank you

答: ASAP - why wait, right?  In reality, your true launch date is going to be determined by Apple anyways depending on how long it takes them to review and approve your app.</p>

OwnerDisplayName: ivanTheTerrible

ContentLicense: CC BY-SA 2.5

Title: iPhone app launching tips?

LastEditorDisplayName: ivanTheTerrible

OwnerDisplayName: Eric P


问:
How to run more than one scenario in a given feature file
I'm able to find how to run single scenario under a given feature file. But not able to find any option to run multiple scenarios.</p>
```<code>mvn test "-Dkarate.options=src/test/features/covid19-data.feature:7" -DargLine='-Dkarate.env=E1' -Dtest=ToolRunner
</code>```

答:
I think multiple feature paths are supported delimited by the space character, but please contribute code or documentation if needed.

The standard answer is to use tags: https://github.com/karatelabs/karate#tags

```<code>@one
Scenario:
* print 'first'

@one
Scenario:
* print 'second'
</code>```

And in the command:

```<code>"-Dkarate.options=--tags @one src/test/features/covid19-data.feature"
</code>```

Body:
I'm able to find how to run single scenario under a given feature file. But not able to find any option to run multiple scenarios.

mvn test "-Dkarate.options=src/test/features/covid19-data.feature:7" -DargLine='-Dkarate.env=E1' -Dtest=ToolRunner

Body:
I think multiple feature paths are supported delimited by the space character, but please contribute code or documentation if needed.

The standard answer is to use tags: https://github.com/karatelabs/karate#tags

@one
Scenario:
* print 'first'

@one
Scenario:
* print 'second'

And in the command:

"-Dkarate.options=--tags @one src/test/features/covid19-data.feature"


问:
Understanding jq JOIN()
I'm trying to understand JOIN() builtin of jq.

From the jq manual (https://stedolan.github.io/jq/manual):

```<code>JOIN($idx; stream; idx_expr; join_expr):

This builtin joins the values from the given stream to the given index.
The index's keys are computed by applying the given index expression to each value from the given stream.
An array of the value in the stream and the corresponding value from the index is fed to the given join expression to produce each result.
</code>```

I find this hard to understand without examples.

Could you give some examples of its usage demonstrating how it works?

答:
This function should resemble a JOIN clause in SQL. It is used to combine rows from two (or more in SQL) tables, based on a related column between them.

Let's build some "tables".

The first one should be a list of orders with an ID, and ID references to the ordering Customer and the ordered Product:

```<code>[
  {
    "OrderID": "10",
    "CustomerIDRef": "2",
    "ProductIDRef": "7"
  },
  {
    "OrderID": "11",
    "CustomerIDRef": "1",
    "ProductIDRef": "7"
  },
  {
    "OrderID": "12",
    "CustomerIDRef": "2",
    "ProductIDRef": "14"
  },
  {
    "OrderID": "13",
    "CustomerIDRef": "2",
    "ProductIDRef": "7"
  }
]
as $orders
</code>```

Let the second one be the list of customers mapped to their name:

```<code>[
  {
    "CustomerID": "1",
    "CustomerName": "Alfred"
  },
  {
    "CustomerID": "2",
    "CustomerName": "Bill"
  },
  {
    "CustomerID": "3",
    "CustomerName": "Caroline"
  }
]
as $customers
</code>```

As jq's JOIN only handles two tables at once (for more, you need to cascade), let's ignore the missing Products table.

Before we can get to JOIN we need to look at INDEX first, which turns an array like our tables from above into an object with the table's "primary keys" as field names. This is reasonable as field names are unique, rendering a lookup to always return not more than one record.

```<code>INDEX($customers[]; .CustomerID)
</code>```

{
  "1": {
    "CustomerID": "1",
    "CustomerName": "Alfred"
  },
  "2": {
    "CustomerID": "2",
    "CustomerName": "Bill"
  },
  "3": {
    "CustomerID": "3",
    "CustomerName": "Caroline"
  }
}
```
<p>Demo</p>
<p>Now, we can easily perform a <code>JOIN</code> operation between Orders (as the "left table") and their Customers (as the "right table"). Providing the "right table" as an <code>INDEX</code>ed object, the "left table" as a stream <code>.[]</code>, and the "related column" as field in the left table's objects that is matched with the right table's primary key (field name in the lookup object), we get: (let the last parameter be just <code>.</code> for now)</p>
```JOIN(INDEX($customers[]; .CustomerID); $orders[]; .CustomerIDRef; .)
```
<pre class="lang-json prettyprint-override"><code>[
  {
    "OrderID": "10",
    "CustomerIDRef": "2",
    "ProductIDRef": "7"
  },
  {
    "CustomerID": "2",
    "CustomerName": "Bill"
  }
]
[
  {
    "OrderID": "11",
    "CustomerIDRef": "1",
    "ProductIDRef": "7"
  },
  {
    "CustomerID": "1",
    "CustomerName": "Alfred"
  }
]
[
  {
    "OrderID": "12",
    "CustomerIDRef": "2",
    "ProductIDRef": "14"
  },
  {
    "CustomerID": "2",
    "CustomerName": "Bill"
  }
]
[
  {
    "OrderID": "13",
    "CustomerIDRef": "2",
    "ProductIDRef": "7"
  },
  {
    "CustomerID": "2",
    "CustomerName": "Bill"
  }
]
</code>```

Demo

As you can see, we get a stream of arrays, one for each order. Each array has two elements: the record from the left table and the one from the right. An unsuccessful lookup would yield null on the right side.

Finally, the fourth parameter being the "join expression" describes how to join the two matching records, which esentially acts as a map.

```<code>JOIN(INDEX($customers[]; .CustomerID); $orders[]; .CustomerIDRef;
  "\(.[0].OrderID): \(.[1].CustomerName) ordered Product #\(.[0].ProductIDRef)."
)
</code>```

10: Bill ordered Product #7.
11: Alfred ordered Product #7.
12: Bill ordered Product #14.
13: Bill ordered Product #7.
```

Demo

Title: Understanding jq JOIN()

Body:
I'm trying to understand JOIN() builtin of jq.

From the jq manual (https://stedolan.github.io/jq/manual):

JOIN($idx; stream; idx_expr; join_expr):

This builtin joins the values from the given stream to the given index.
The index's keys are computed by applying the given index expression to each value from the given stream.
An array of the value in the stream and the corresponding value from the index is fed to the given join expression to produce each result.

I find this hard to understand without examples.

Could you give some examples of its usage demonstrating how it works?

Body:
This function should resemble a JOIN clause in SQL. It is used to combine rows from two (or more in SQL) tables, based on a related column between them.

Let's build some "tables".

The first one should be a list of orders with an ID, and ID references to the ordering Customer and the ordered Product:

[
  {
    "OrderID": "10",
    "CustomerIDRef": "2",
    "ProductIDRef": "7"
  },
  {
    "OrderID": "11",
    "CustomerIDRef": "1",
    "ProductIDRef": "7"
  },
  {
    "OrderID": "12",
    "CustomerIDRef": "2",
    "ProductIDRef": "14"
  },
  {
    "OrderID": "13",
    "CustomerIDRef": "2",
    "ProductIDRef": "7"
  }
]
as $orders

Let the second one be the list of customers mapped to their name:

[
  {
    "CustomerID": "1",
    "CustomerName": "Alfred"
  },
  {
    "CustomerID": "2",
    "CustomerName": "Bill"
  },
  {
    "CustomerID": "3",
    "CustomerName": "Caroline"
  }
]
as $customers

As jq's JOIN only handles two tables at once (for more, you need to cascade), let's ignore the missing Products table.

Before we can get to JOIN we need to look at INDEX first, which turns an array like our tables from above into an object with the table's "primary keys" as field names. This is reasonable as field names are unique, rendering a lookup to always return not more than one record.

INDEX($customers[]; .CustomerID)

{
  "1": {
    "CustomerID": "1",
    "CustomerName": "Alfred"
  },
  "2": {
    "CustomerID": "2",
    "CustomerName": "Bill"
  },
  "3": {
    "CustomerID": "3",
    "CustomerName": "Caroline"
  }
}

Demo

Now, we can easily perform a JOIN operation between Orders (as the "left table") and their Customers (as the "right table"). Providing the "right table" as an INDEXed object, the "left table" as a stream .[], and the "related column" as field in the left table's objects that is matched with the right table's primary key (field name in the lookup object), we get: (let the last parameter be just . for now)

JOIN(INDEX($customers[]; .CustomerID); $orders[]; .CustomerIDRef; .)

[
  {
    "OrderID": "10",
    "CustomerIDRef": "2",
    "ProductIDRef": "7"
  },
  {
    "CustomerID": "2",
    "CustomerName": "Bill"
  }
]
[
  {
    "OrderID": "11",
    "CustomerIDRef": "1",
    "ProductIDRef": "7"
  },
  {
    "CustomerID": "1",
    "CustomerName": "Alfred"
  }
]
[
  {
    "OrderID": "12",
    "CustomerIDRef": "2",
    "ProductIDRef": "14"
  },
  {
    "CustomerID": "2",
    "CustomerName": "Bill"
  }
]
[
  {
    "OrderID": "13",
    "CustomerIDRef": "2",
    "ProductIDRef": "7"
  },
  {
    "CustomerID": "2",
    "CustomerName": "Bill"
  }
]

Demo

As you can see, we get a stream of arrays, one for each order. Each array has two elements: the record from the left table and the one from the right. An unsuccessful lookup would yield null on the right side.

Finally, the fourth parameter being the "join expression" describes how to join the two matching records, which esentially acts as a map.

JOIN(INDEX($customers[]; .CustomerID); $orders[]; .CustomerIDRef;
  "\(.[0].OrderID): \(.[1].CustomerName) ordered Product #\(.[0].ProductIDRef)."
)

10: Bill ordered Product #7.
11: Alfred ordered Product #7.
12: Bill ordered Product #14.
13: Bill ordered Product #7.

Demo


问:
How to unpickle part of a pickled dictionary?
Basically; I messed up. I have pickled some data, a pretty massive dictionary, and while my computer was able to create and pickle that dictionary in the first place, it crashes from running out of memory when I try to unpickle it. I need to unpickle it somehow, to get the data back, and then I can write each entry of the dictionary to a separate file that can actually fit in memory. My best guess for how to do that is to unpickle the dictionary entry by entry and then pickle each entry into it's own file, or failing that to unpickle it but somehow leave it as an on-disk object. I can't seem to find any information on how pickled data is actually stored to start writing a program to recover the data.</p>

答:
pickle is a serialization format unique to Python, and there is no user-level documentation for it.

However, there are extensive comments in a standard distribution's "Lib/pickletools.py" module, and with enough effort you should be able to use that module's dis() function to produce output you can parse yourself, or modify the source itself. dis() does not execute a pickle (meaning it doesn't build any Python objects from the pickle). Instead it reads the pickle file a few bytes at a time, and prints (to stdout, by default) a more human-readable form of what those bytes "mean".


问:
Navigating to a page on load in react JS
I am working on user registration setup and stuck on a problem where I am not able to redirect from a page 'localhost:3000/activate/tokenNo.'(Activation.jsx file) on load to my main page (App.jsx file) .

Here is my activation.jsx file :

```<code>import React, { useEffect } from 'react';
import { useNavigate } from "react-router-dom";

const Activate = () => {
    const navigate = useNavigate();

    useEffect(() => {
        navigate('/')
    }, [navigate])

    return (
        <div>Activation Page</div>
    )
}

export default Activate;
</code>```

Here is my App.jsx file :

```<code>import React from 'react';

export const App = () => {
  return <div>Dashboard</div>;
};
export default App ;
</code>```

My activationController.js file :

```<code>exports.activationController = (req,res) => {
    const {token} = req.body
    if(token){
        //Verify the token is valid or not or expired
    jwt.verify(token , process.env.JWT_ACCOUNT_ACTIVATION ,
        (err , decoded) => {
            if(err){
                return res.status(401).json({
                    error: "Expired Token , Signup again"
                })
            }
            else{
                //if valid save to database
                //Get name email password from token
                const {name , email , password} = jwt.decode(token)

                const user = new User({
                    name ,
                    email ,
                    passsword
                })

                user.save((err,user) => {
                    if(err){
                        return res.status(401).json({
                            error: errorHandler(err)
                        })
                    }
                    else{
                        return res.json({
                            success: true ,
                            message: "Signup successful",
                            user
                        })
                    }
                })

            }
        })

    }
    else{
        return res.json({
            message: "error happening please try again"
        })
    }

}
</code>```

In my auth.routes.js

```<code>router.post('/activation', activationController)
</code>```

I recieved an error in my console --> index.tsx:25 No routes matched location "/activate/tokenNo."

My reference folder --> https://github.com/Mohammed-Abdelhady/FULL-MERN-AUTH-Boilerplate

答:
You may need "Navigate( to="where to go") instead. Leaving the dependencies open in useEffect will make the code run only once at load time. If you include [navigate] it will run every time. Not sure what you are trying to achieve, but Router/Routes/Route may be a better mechanism. If you are doing login/registration, in your login you would have a Link to your registration page. Then you could setup 2 routes, one for Login and one for Registration.</p>
```<code>import React, { useEffect } from 'react';
import { Navigate } from "react-router-dom";

const Activate = () => {

    useEffect(() => {
        Navigate( to='/');
    }, [])

    return (
        <div>Activation Page</div>
    )
}

export default Activate;
</code>```

Body:
I am working on user registration setup and stuck on a problem where I am not able to redirect from a page 'localhost:3000/activate/tokenNo.'(Activation.jsx file) on load to my main page (App.jsx file) .

Here is my activation.jsx file :

import React, { useEffect } from 'react';
import { useNavigate } from "react-router-dom";

const Activate = () => {
    const navigate = useNavigate();

    useEffect(() => {
        navigate('/')
    }, [navigate])

    return (

Activation Page

    )
}

export default Activate;

Here is my App.jsx file :

import React from 'react';

export const App = () => {
  return
Dashboard
;
};
export default App ;

My activationController.js file :

exports.activationController = (req,res) => {
    const {token} = req.body
    if(token){
        //Verify the token is valid or not or expired
    jwt.verify(token , process.env.JWT_ACCOUNT_ACTIVATION ,
        (err , decoded) => {
            if(err){
                return res.status(401).json({
                    error: "Expired Token , Signup again"
                })
            }
            else{
                //if valid save to database
                //Get name email password from token
                const {name , email , password} = jwt.decode(token)

                const user = new User({
                    name ,
                    email ,
                    passsword
                })

                user.save((err,user) => {
                    if(err){
                        return res.status(401).json({
                            error: errorHandler(err)
                        })
                    }
                    else{
                        return res.json({
                            success: true ,
                            message: "Signup successful",
                            user
                        })
                    }
                })

            }
        })

    }
    else{
        return res.json({
            message: "error happening please try again"
        })
    }

}

In my auth.routes.js

router.post('/activation', activationController)

I recieved an error in my console --> index.tsx:25 No routes matched location "/activate/tokenNo."

My reference folder --> https://github.com/Mohammed-Abdelhady/FULL-MERN-AUTH-Boilerplate

Body:
You may need "Navigate( to="where to go") instead. Leaving the dependencies open in useEffect will make the code run only once at load time. If you include [navigate] it will run every time. Not sure what you are trying to achieve, but Router/Routes/Route may be a better mechanism. If you are doing login/registration, in your login you would have a Link to your registration page. Then you could setup 2 routes, one for Login and one for Registration.

import React, { useEffect } from 'react';
import { Navigate } from "react-router-dom";

const Activate = () => {

    useEffect(() => {
        Navigate( to='/');
    }, [])

    return (
        <div>Activation Page</div>
    )
}

export default Activate;


问:
Does "new char[]" need to be release resources manually?
For this:
m_sFilename = new char [len+1];

Should I call delete[] m_sFilename; sometime?

And:

should I use delete[] m_sFilename or delete m_sFilename;?

答: Yes, but use std::string to store m_sFilename instead - it's better in just about every way.


问:
How to select multiple idexed ids using Javascript?
i have 6 divs with id wrapperX (X is number 1 till 6)

when I want to change its background color with for loop
 error show on the log which says Uncaught TypeError: Cannot read property 'style' of null

when I'm not use template literal it works but I must write the code one by one

```<code>// show error
for (let i = 0; i < 6; i++) {
  let eleSelect = document.getElementById(`wrapper${i}`);
  eleSelect.style.setProperty('background-color', 'green');
  console.log(eleSelect);
}
// it works
for (let i = 0; i < 6; i++) {
  let eleSelect = document.getElementById('wrapper0');
  // i must repeat the code till 5
  eleSelect.style.setProperty('background-color', 'green');
  console.log(eleSelect);
}
</code>```

css code (i think it's necessary to include here) :

```<code>#wrapper0, #wrapper1, #wrapper2, #wrapper3, #wrapper4, #wrapper5{
  width: 100px; height: 100px; background-color: black;
}
</code>```

html:

```<code><div id="wrapper0"></div><div id="wrapper1"></div><div id="wrapper2"></div><div id="wrapper3"></div><div id="wrapper4"></div><div id="wrapper5"></div>
</code>```

答:
Your code does not have a wrapper0 element but your loop counter is set to 0

solution:

```<code>for (let i = 1; i <= 6; i++) {
  let eleSelect = document.getElementById(`wrapper${i}`);
  tempEleSelect.style.setProperty('background-color', 'green');
  console.log(tempEleSelect);
}
</code>```

Body:
i have 6 divs with id wrapperX (X is number 1 till 6)

when I want to change its background color with for loop
 error show on the log which says Uncaught TypeError: Cannot read property 'style' of null

when I'm not use template literal it works but I must write the code one by one

// show error
for (let i = 0; i < 6; i++) {
  let eleSelect = document.getElementById(`wrapper${i}`);
  eleSelect.style.setProperty('background-color', 'green');
  console.log(eleSelect);
}
// it works
for (let i = 0; i < 6; i++) {
  let eleSelect = document.getElementById('wrapper0');
  // i must repeat the code till 5
  eleSelect.style.setProperty('background-color', 'green');
  console.log(eleSelect);
}

css code (i think it's necessary to include here) :

#wrapper0, #wrapper1, #wrapper2, #wrapper3, #wrapper4, #wrapper5{
  width: 100px; height: 100px; background-color: black;
}

html:

Body:
Your code does not have a wrapper0 element but your loop counter is set to 0

solution:

for (let i = 1; i <= 6; i++) {
  let eleSelect = document.getElementById(`wrapper${i}`);
  tempEleSelect.style.setProperty('background-color', 'green');
  console.log(tempEleSelect);
}


问:
How to get all maximum repeated items in a python list of strings?
I have python list. I want to get all the items that are repeated maximum in it. The example list below has two items repeated twice and I want to get both. Applying max() to list, I could get only one item (either the first or last occurrence) that is repeated maximum.

```<code>cool = ['similar', 'neutral', 'contradict', 'similar', 'neutral']
print(max(cool, key=cool.count))
</code>```

I tried Counter() and still can only return one maximum item from list. How to get both the items repeated maximum from a python list?

答:
Using Counter class,

```<code>from collections import Counter

cool = ['similar', 'neutral', 'contradict', 'similar', 'neutral']

result = []
counter = Counter(cool)
max_value = counter.most_common(1)[0][1]

for key, value in dict(counter).items():
    if(value == max_value):
        result.append(key)

print(result)
</code>```

Body:
I have python list. I want to get all the items that are repeated maximum in it. The example list below has two items repeated twice and I want to get both. Applying max() to list, I could get only one item (either the first or last occurrence) that is repeated maximum.

cool = ['similar', 'neutral', 'contradict', 'similar', 'neutral']
print(max(cool, key=cool.count))

I tried Counter() and still can only return one maximum item from list. How to get both the items repeated maximum from a python list?

Body:
Using Counter class,

from collections import Counter

cool = ['similar', 'neutral', 'contradict', 'similar', 'neutral']

result = []
counter = Counter(cool)
max_value = counter.most_common(1)[0][1]

for key, value in dict(counter).items():
    if(value == max_value):
        result.append(key)

print(result)


问:
DAX Duplicate Count in measure with Previous Date
I Need a DAX measure where date wise only duplicate values will return. The date will search always previous + Current Date. Ex: on date 2/2/2022, it will check both 2/1/2022 and 2/2/2022 and return only duplicate count.

Below Data set Count of on 2/2/2022 Duplicate will return 4. which is highlighted in

Total Output will be:

I already write a DAX but it just return unique count not only duplicate:

```<code>CALCULATE(DISTINCTCOUNT(data[Wrap-up]),DATESINPERIOD(data[Date],MAX(data[Date]),-2,DAY))
</code>```

答:
Date    Wrap-up
2/1/2022    Subscription_ACCBalance_QFTR
2/1/2022    Package_AKASH Lite Plus_RFTR
2/1/2022    Package_AKASH LITE_RFTR
2/1/2022    Subscription_Service Act_QFTR
2/1/2022    Package_AKASH Lite Plus_RFTR
2/1/2022    Camp Offer_Referral Offer_RFTR
2/2/2022    Content_Specefic Channel_CFTR
2/2/2022    Subscription_ACCBalance_QFTR
2/2/2022    Package_AKASH STANDARD_RFTR
2/2/2022    Camp Offer_Referral Offer_QFTR
2/2/2022    Error Code_E17-0_CFTR
2/3/2022    Package_AKASH STANDARD_RFTR
2/3/2022    Package_AKASH STANDARD_QFTR
2/3/2022    Package_Package Info_QFTR
2/3/2022    Package_AKASH LITE_QFTR
2/4/2022    Subscription_ACCBalance_QFTR
2/4/2022    Content_Specefic Channel_QFTR
2/4/2022    Info Update_HelpPage_CFTR
2/4/2022    Purchase_General Process_QFTR
2/4/2022    Package_AKASH STANDARD_RFTR
2/4/2022    Recharge_bKash_QFTR
2/4/2022    Camp Offer_Feb Recharge_QFTR
2/4/2022    Subscription_Classific_QFTR```

Date        Wrap-up
2/1/2022    Subscription_ACCBalance_QFTR
2/1/2022    Package_AKASH Lite Plus_RFTR
2/1/2022    Package_AKASH LITE_RFTR
2/1/2022    Subscription_Service Act_QFTR
2/1/2022    Package_AKASH Lite Plus_RFTR
2/1/2022    Camp Offer_Referral Offer_RFTR
2/2/2022    Content_Specefic Channel_CFTR
2/2/2022    Subscription_ACCBalance_QFTR
2/2/2022    Package_AKASH STANDARD_RFTR
2/2/2022    Camp Offer_Referral Offer_QFTR
2/2/2022    Error Code_E17-0_CFTR
2/3/2022    Package_AKASH STANDARD_RFTR
2/3/2022    Package_AKASH STANDARD_QFTR
2/3/2022    Package_Package Info_QFTR
2/3/2022    Package_AKASH LITE_QFTR
2/4/2022    Subscription_ACCBalance_QFTR
2/4/2022    Content_Specefic Channel_QFTR
2/4/2022    Info Update_HelpPage_CFTR
2/4/2022    Purchase_General Process_QFTR
2/4/2022    Package_AKASH STANDARD_RFTR
2/4/2022    Recharge_bKash_QFTR
2/4/2022    Camp Offer_Feb Recharge_QFTR
2/4/2022    Subscription_Classific_QFTR

Body:
I Need a DAX measure where date wise only duplicate values will return. The date will search always previous + Current Date. Ex: on date 2/2/2022, it will check both 2/1/2022 and 2/2/2022 and return only duplicate count.

Below Data set Count of on 2/2/2022 Duplicate will return 4. which is highlighted in

Total Output will be:

I already write a DAX but it just return unique count not only duplicate:

CALCULATE(DISTINCTCOUNT(data[Wrap-up]),DATESINPERIOD(data[Date],MAX(data[Date]),-2,DAY))

Body:
Date    Wrap-up
2/1/2022    Subscription_ACCBalance_QFTR
2/1/2022    Package_AKASH Lite Plus_RFTR
2/1/2022    Package_AKASH LITE_RFTR
2/1/2022    Subscription_Service Act_QFTR
2/1/2022    Package_AKASH Lite Plus_RFTR
2/1/2022    Camp Offer_Referral Offer_RFTR
2/2/2022    Content_Specefic Channel_CFTR
2/2/2022    Subscription_ACCBalance_QFTR
2/2/2022    Package_AKASH STANDARD_RFTR
2/2/2022    Camp Offer_Referral Offer_QFTR
2/2/2022    Error Code_E17-0_CFTR
2/3/2022    Package_AKASH STANDARD_RFTR
2/3/2022    Package_AKASH STANDARD_QFTR
2/3/2022    Package_Package Info_QFTR
2/3/2022    Package_AKASH LITE_QFTR
2/4/2022    Subscription_ACCBalance_QFTR
2/4/2022    Content_Specefic Channel_QFTR
2/4/2022    Info Update_HelpPage_CFTR
2/4/2022    Purchase_General Process_QFTR
2/4/2022    Package_AKASH STANDARD_RFTR
2/4/2022    Recharge_bKash_QFTR
2/4/2022    Camp Offer_Feb Recharge_QFTR
2/4/2022    Subscription_Classific_QFTR

Date        Wrap-up
2/1/2022    Subscription_ACCBalance_QFTR
2/1/2022    Package_AKASH Lite Plus_RFTR
2/1/2022    Package_AKASH LITE_RFTR
2/1/2022    Subscription_Service Act_QFTR
2/1/2022    Package_AKASH Lite Plus_RFTR
2/1/2022    Camp Offer_Referral Offer_RFTR
2/2/2022    Content_Specefic Channel_CFTR
2/2/2022    Subscription_ACCBalance_QFTR
2/2/2022    Package_AKASH STANDARD_RFTR
2/2/2022    Camp Offer_Referral Offer_QFTR
2/2/2022    Error Code_E17-0_CFTR
2/3/2022    Package_AKASH STANDARD_RFTR
2/3/2022    Package_AKASH STANDARD_QFTR
2/3/2022    Package_Package Info_QFTR
2/3/2022    Package_AKASH LITE_QFTR
2/4/2022    Subscription_ACCBalance_QFTR
2/4/2022    Content_Specefic Channel_QFTR
2/4/2022    Info Update_HelpPage_CFTR
2/4/2022    Purchase_General Process_QFTR
2/4/2022    Package_AKASH STANDARD_RFTR
2/4/2022    Recharge_bKash_QFTR
2/4/2022    Camp Offer_Feb Recharge_QFTR
2/4/2022    Subscription_Classific_QFTR