问:
Fit a DataFrame into a model using TFDS data
I have a dataset in a csv right now that contains data in this format:

text
class

text1
0

text2
1

I have an RNN that would like to test my dataset on to check its performance. The RNN can be found here.

In that case, the dataset is loading a dataset from TFDS by using tfds.load().

Which way should I use to be able to fit my .csv data (I guess my DataFrame) and bring it into an acceptable form to be used by the pre-defined model?

Please feel free to comment with any clarification questions if my question is not clear. Thank you very much in advance for your support.

答:
I would recommend using the tf.data.Dataset API. Check out this tutorial. Here is a working example based on your data structure:

```<code>import pandas as pd
import tensorflow as tf

df = pd.DataFrame(data= {'text': ['some text', 'some more text'], 'class': [0, 1]})
labels = df.pop('class')
dataset = tf.data.Dataset.from_tensor_slices((df, labels))

for x, y in dataset:
  print(x, y)
</code>```
```<code>tf.Tensor([b'some text'], shape=(1,), dtype=string) tf.Tensor(0, shape=(), dtype=int64)
tf.Tensor([b'some more text'], shape=(1,), dtype=string) tf.Tensor(1, shape=(), dtype=int64)
</code>```

Body:
I would recommend using the tf.data.Dataset API. Check out this tutorial. Here is a working example based on your data structure:

import pandas as pd
import tensorflow as tf

df = pd.DataFrame(data= {'text': ['some text', 'some more text'], 'class': [0, 1]})
labels = df.pop('class')
dataset = tf.data.Dataset.from_tensor_slices((df, labels))

for x, y in dataset:
  print(x, y)

tf.Tensor([b'some text'], shape=(1,), dtype=string) tf.Tensor(0, shape=(), dtype=int64)
tf.Tensor([b'some more text'], shape=(1,), dtype=string) tf.Tensor(1, shape=(), dtype=int64)


来源: stackexchange

问:
Grails and OAuth
I am using a REST JSON webservice which I want to secure. The service is secured with very basic Spring security and the session is stored on the server. So before the user can access the url "/api/resource" he/she needs to login first.

I want know how to:

Only allow registered users to access my rest api

Only allow registered clients with registered users to access my rest api(e.g. GWT, Android, iOS).  I dont want to let the users access my api if the client is not registered.

With a lot of googleing I saw the concept of OAuth which has the three way authentication method.

I am using grails in my project but I did not find any support for OAuth. Does anyone have experience using OAuth with grails? Is it easy to implement using Grails?

Thanks for help

答:
I've coded an OAuth library that is really simple and it's known to work with Groovy.

It's called scribe and you can give it a try here:

http://github.com/fernandezpablo85/scribe-java

EDIT

If you need to implement an OAuth provider yourself, the only library I know is the old oauth java lib.

It's not very well documented but it has some examples.

ContentLicense: CC BY-SA 3.0

Title: Grails and OAuth


问:
MySQL count number of user activities (table a) falling in two login session datetime (table b)
I have a table with all the users activities and another table with all the users login events. Each of them has a datatime field (creation).

I need to count for a specific user with one query how many activities he/she has done falling into the datetime range in between two consecutive logins (assuming that in between a logout or session expiration event has happened) and after the last one.

```<code>CREATE TABLE `STAGING_admin_activities` (
  `id` int(11) UNSIGNED NOT NULL,
  `admin_id` int(11) UNSIGNED DEFAULT NULL,
  `requested_URL_and_data` tinytext DEFAULT NULL,
  `post_data` text DEFAULT NULL,
  `result` tinytext DEFAULT NULL,
  `useragent_referred_URL` tinytext DEFAULT NULL,
  `useragent_browser` tinytext DEFAULT NULL,
  `useragent_browser_version` tinytext DEFAULT NULL,
  `useragent_robot` tinytext DEFAULT NULL,
  `useragent_mobile` tinytext DEFAULT NULL,
  `useragent_platform` tinytext DEFAULT NULL,
  `useragent_languages` tinytext DEFAULT NULL,
  `ip_country_code` varchar(2) DEFAULT NULL,
  `ip` varchar(255) DEFAULT NULL,
  `remarks` tinytext DEFAULT NULL,
  `creation` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `STAGING_admin_login_logout` (
  `id` int(11) UNSIGNED NOT NULL,
  `operation` enum('login','logout') NOT NULL,
  `result` tinyint(1) UNSIGNED DEFAULT NULL,
  `admin_id` int(11) UNSIGNED DEFAULT NULL,
  `ip` varchar(255) DEFAULT NULL,
  `ip_country_code` varchar(2) DEFAULT NULL,
  `creation` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
</code>```

To simplify the data example keeping just the meaningful fields

STAGING_admin_login_logout

id
admin_id
operation
creation

1
5
login
08/03/2021 17:19

2
5
login
08/03/2021 20:11

3
1
login
09/03/2021 09:09

4
4
login
09/03/2021 10:31

5
5
login
09/03/2021 15:08

6
5
login
09/03/2021 17:01

7
1
login
10/03/2021 14:01

8
5
login
10/03/2021 18:15

STAGING_admin_activities

id
admin_id
creation

1
5
08/03/2021 17:20

2
5
08/03/2021 17:23

3
5
08/03/2021 17:25

4
5
08/03/2021 20:13

5
5
08/03/2021 20:13

6
4
09/03/2021 10:33

7
5
09/03/2021 15:11

8
5
09/03/2021 15:11

9
5
09/03/2021 15:22

10
5
09/03/2021 17:01

11
1
10/03/2021 14:01

12
5
10/03/2021 18:18

13
5
10/03/2021 19:37

the expected result is something similar of this simplified table

expected results filtered on admin_id = 5

admin_id
login_time
last_activity_time
number_of_activities

5
08/03/2021 17:19
08/03/2021 17:25
3

5
08/03/2021 20:11
08/03/2021 20:13
2

5
09/03/2021 15:08
09/03/2021 15:22
3

5
09/03/2021 17:01
09/03/2021 17:01
1

5
10/03/2021 18:15
10/03/2021 19:37
2

As you can see the field last_activity_time come from the activties table "creation" field and is the higher datetime in between two login events. The last column number_of_activities is the desired result, the number of activities including the last one falling in the time range between login_time (originally coming from the 'creation' field of the login events table) and last_activity_time (originally coming from the 'creation' field of the activities table).

In the following image, it is shown the relations on the datetime field of the two tables and how they are considered on creating the resulting one.

Concerning the DB version on PhpMyAdmin I can read this: "Versione del server: 10.3.32-MariaDB - MariaDB Server".

UPDATE 1

Following D-Shih ideas I tryed this

```<code>SELECT *
FROM
( SELECT operation,result,admin_id,creation as login_creation, LEAD(creation) OVER(PARTITION BY admin_id ORDER BY creation) next_login_time
FROM STAGING_admin_login_logout
WHERE operation = "login" AND admin_id = 5 ) login_logout
INNER JOIN STAGING_admin_activities ON STAGING_admin_activities.admin_id = login_logout.admin_id
WHERE STAGING_admin_activities.creation BETWEEN login_logout.login_creation AND login_logout.next_login_time
ORDER BY STAGING_admin_activities.creation ASC
</code>```

that actually gives as many rows as the ativities of user with user_id = 5 and falling in the range of datetime of two consecutive logins. What is in common to all the activities rows in between two logins is the field login_creation that has the same datetime. Now I should count the activities that as the same login_creation field value; I tryed in this way

```<code>SELECT *, COUNT(*) as number_of_activities
FROM
( SELECT operation,result,admin_id,creation as login_creation, LEAD(creation) OVER(PARTITION BY admin_id ORDER BY creation) next_login_time
FROM STAGING_admin_login_logout
WHERE operation = "login" AND admin_id = 5 ) login_logout
INNER JOIN STAGING_admin_activities ON STAGING_admin_activities.admin_id = login_logout.admin_id
WHERE STAGING_admin_activities.creation BETWEEN login_logout.login_creation AND login_logout.next_login_time
GROUP BY login_logout.login_creation
ORDER BY STAGING_admin_activities.creation ASC
</code>```

now checking if it is correct.

UPDATE 2

The query closest to the desired result is the following one, I still have a couple of troubles for which I kind ask for an help

```<code>SELECT *, COUNT(*) as number_of_activities, MAX(STAGING_admin_activities.creation) as last_activity_creation, TIMESTAMPDIFF(MINUTE,login_creation,next_login_time) as time_lenght
FROM
    ( SELECT operation,result,admin_id,creation as login_creation, LEAD(creation) OVER(PARTITION BY admin_id ORDER BY creation) next_login_time
    FROM STAGING_admin_login_logout
    WHERE operation = "login" AND admin_id = 5 ) login_logout
INNER JOIN STAGING_admin_activities ON STAGING_admin_activities.admin_id = login_logout.admin_id
WHERE STAGING_admin_activities.creation BETWEEN login_logout.login_creation AND login_logout.next_login_time AND
      requested_URL_and_data = '/adminPanel/Products/addUpdate' AND
      login_logout.result = 1
GROUP BY login_logout.login_creation
ORDER BY STAGING_admin_activities.creation ASC
</code>```

The first problem is that the last group of activities have a time range equal in between the last login creation datatime and NULL since there is not a next login time that determines the end of the range. I need to extract some how the last/max activity creation datetime, lets call it 'max_activity_creation', and extend the condition on time as following

```<code>WHERE (STAGING_admin_activities.creation BETWEEN login_logout.login_creation AND login_logout.next_login_time **OR STAGING_admin_activities.creation >= max_activity_creation**) AND
      requested_URL_and_data = '/adminPanel/Products/addUpdate' AND
      login_logout.result = 1
</code>```

How can I extract this 'max_activity_creation' value?

The second issue is that I should calculate the time length of the activities as the datetime of the last activity before a new login and the datetime of the previous login. Let's call the dateime of this last activity as 'last_activity_creation' as in the initial SELECT.

```<code>SELECT *, COUNT(*) as number_of_activities, MAX(STAGING_admin_activities.creation) as last_activity_creation, TIMESTAMPDIFF(MINUTE,login_creation,next_login_time) as time_lenght
</code>```

actually 'last_activity_creation' is displayed correctly but if I use it in side the TIMESTAMPDIFF

```<code>TIMESTAMPDIFF(MINUTE,login_creation,last_activity_creation)
</code>```

I get an error. Any ideas?

答:
You can try to use LEAD window function in asubquery on STAGING_admin_activities table to get the next creation in every row.

then use BETWEEN to filter your expectation logic.

Query #1

```<code>SELECT a.admin_id,
       a.creation login_time,
       MAX(logout.creation) last_activity_time,
       count(*) number_of_activities

FROM (
  SELECT *, LEAD(creation) OVER(PARTITION BY admin_id ORDER BY creation) next_logout_time
  FROM STAGING_admin_activities
) a
INNER JOIN STAGING_admin_login_logout logout
ON a.admin_id = logout.admin_id AND
logout.creation BETWEEN  a.creation AND coalesce(next_logout_time,'9999/12/31') AND
coalesce(next_logout_time,'9999/12/31') <> logout.creation
WHERE  a.admin_id = 5
GROUP BY a.admin_id,
       a.creation;
</code>```

admin_id
login_time
last_activity_time
number_of_activities

5
2021-03-08 17:19:00
2021-03-08 17:25:00
3

5
2021-03-08 20:11:00
2021-03-08 20:13:00
2

5
2021-03-09 15:08:00
2021-03-09 15:22:00
3

5
2021-03-09 17:01:00
2021-03-09 17:01:00
1

5
2021-03-10 18:15:00
2021-03-10 19:37:00
2

View on DB Fiddle

LEAD window function will return the value from the nth row after the current row in a partition.

ContentLicense: CC BY-SA 4.0

Body:
I have a table with all the users activities and another table with all the users login events. Each of them has a datatime field (creation).

I need to count for a specific user with one query how many activities he/she has done falling into the datetime range in between two consecutive logins (assuming that in between a logout or session expiration event has happened) and after the last one.

CREATE TABLE `STAGING_admin_activities` (
  `id` int(11) UNSIGNED NOT NULL,
  `admin_id` int(11) UNSIGNED DEFAULT NULL,
  `requested_URL_and_data` tinytext DEFAULT NULL,
  `post_data` text DEFAULT NULL,
  `result` tinytext DEFAULT NULL,
  `useragent_referred_URL` tinytext DEFAULT NULL,
  `useragent_browser` tinytext DEFAULT NULL,
  `useragent_browser_version` tinytext DEFAULT NULL,
  `useragent_robot` tinytext DEFAULT NULL,
  `useragent_mobile` tinytext DEFAULT NULL,
  `useragent_platform` tinytext DEFAULT NULL,
  `useragent_languages` tinytext DEFAULT NULL,
  `ip_country_code` varchar(2) DEFAULT NULL,
  `ip` varchar(255) DEFAULT NULL,
  `remarks` tinytext DEFAULT NULL,
  `creation` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `STAGING_admin_login_logout` (
  `id` int(11) UNSIGNED NOT NULL,
  `operation` enum('login','logout') NOT NULL,
  `result` tinyint(1) UNSIGNED DEFAULT NULL,
  `admin_id` int(11) UNSIGNED DEFAULT NULL,
  `ip` varchar(255) DEFAULT NULL,
  `ip_country_code` varchar(2) DEFAULT NULL,
  `creation` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

To simplify the data example keeping just the meaningful fields

STAGING_admin_login_logout

id
admin_id
operation
creation

1
5
login
08/03/2021 17:19

2
5
login
08/03/2021 20:11

3
1
login
09/03/2021 09:09

4
4
login
09/03/2021 10:31

5
5
login
09/03/2021 15:08

6
5
login
09/03/2021 17:01

7
1
login
10/03/2021 14:01

8
5
login
10/03/2021 18:15

STAGING_admin_activities

id
admin_id
creation

1
5
08/03/2021 17:20

2
5
08/03/2021 17:23

3
5
08/03/2021 17:25

4
5
08/03/2021 20:13

5
5
08/03/2021 20:13

6
4
09/03/2021 10:33

7
5
09/03/2021 15:11

8
5
09/03/2021 15:11

9
5
09/03/2021 15:22

10
5
09/03/2021 17:01

11
1
10/03/2021 14:01

12
5
10/03/2021 18:18

13
5
10/03/2021 19:37

the expected result is something similar of this simplified table

expected results filtered on admin_id = 5

admin_id
login_time
last_activity_time
number_of_activities

5
08/03/2021 17:19
08/03/2021 17:25
3

5
08/03/2021 20:11
08/03/2021 20:13
2

5
09/03/2021 15:08
09/03/2021 15:22
3

5
09/03/2021 17:01
09/03/2021 17:01
1

5
10/03/2021 18:15
10/03/2021 19:37
2

As you can see the field last_activity_time come from the activties table "creation" field and is the higher datetime in between two login events. The last column number_of_activities is the desired result, the number of activities including the last one falling in the time range between login_time (originally coming from the 'creation' field of the login events table) and last_activity_time (originally coming from the 'creation' field of the activities table).

In the following image, it is shown the relations on the datetime field of the two tables and how they are considered on creating the resulting one.

Concerning the DB version on PhpMyAdmin I can read this: "Versione del server: 10.3.32-MariaDB - MariaDB Server".

UPDATE 1

Following D-Shih ideas I tryed this

SELECT *
FROM
( SELECT operation,result,admin_id,creation as login_creation, LEAD(creation) OVER(PARTITION BY admin_id ORDER BY creation) next_login_time
FROM STAGING_admin_login_logout
WHERE operation = "login" AND admin_id = 5 ) login_logout
INNER JOIN STAGING_admin_activities ON STAGING_admin_activities.admin_id = login_logout.admin_id
WHERE STAGING_admin_activities.creation BETWEEN login_logout.login_creation AND login_logout.next_login_time
ORDER BY STAGING_admin_activities.creation ASC

that actually gives as many rows as the ativities of user with user_id = 5 and falling in the range of datetime of two consecutive logins. What is in common to all the activities rows in between two logins is the field login_creation that has the same datetime. Now I should count the activities that as the same login_creation field value; I tryed in this way

SELECT *, COUNT(*) as number_of_activities
FROM
( SELECT operation,result,admin_id,creation as login_creation, LEAD(creation) OVER(PARTITION BY admin_id ORDER BY creation) next_login_time
FROM STAGING_admin_login_logout
WHERE operation = "login" AND admin_id = 5 ) login_logout
INNER JOIN STAGING_admin_activities ON STAGING_admin_activities.admin_id = login_logout.admin_id
WHERE STAGING_admin_activities.creation BETWEEN login_logout.login_creation AND login_logout.next_login_time
GROUP BY login_logout.login_creation
ORDER BY STAGING_admin_activities.creation ASC

now checking if it is correct.

UPDATE 2

The query closest to the desired result is the following one, I still have a couple of troubles for which I kind ask for an help

SELECT *, COUNT(*) as number_of_activities, MAX(STAGING_admin_activities.creation) as last_activity_creation, TIMESTAMPDIFF(MINUTE,login_creation,next_login_time) as time_lenght
FROM
    ( SELECT operation,result,admin_id,creation as login_creation, LEAD(creation) OVER(PARTITION BY admin_id ORDER BY creation) next_login_time
    FROM STAGING_admin_login_logout
    WHERE operation = "login" AND admin_id = 5 ) login_logout
INNER JOIN STAGING_admin_activities ON STAGING_admin_activities.admin_id = login_logout.admin_id
WHERE STAGING_admin_activities.creation BETWEEN login_logout.login_creation AND login_logout.next_login_time AND
      requested_URL_and_data = '/adminPanel/Products/addUpdate' AND
      login_logout.result = 1
GROUP BY login_logout.login_creation
ORDER BY STAGING_admin_activities.creation ASC

The first problem is that the last group of activities have a time range equal in between the last login creation datatime and NULL since there is not a next login time that determines the end of the range. I need to extract some how the last/max activity creation datetime, lets call it 'max_activity_creation', and extend the condition on time as following

WHERE (STAGING_admin_activities.creation BETWEEN login_logout.login_creation AND login_logout.next_login_time **OR STAGING_admin_activities.creation >= max_activity_creation**) AND
      requested_URL_and_data = '/adminPanel/Products/addUpdate' AND
      login_logout.result = 1

How can I extract this 'max_activity_creation' value?

The second issue is that I should calculate the time length of the activities as the datetime of the last activity before a new login and the datetime of the previous login. Let's call the dateime of this last activity as 'last_activity_creation' as in the initial SELECT.

SELECT *, COUNT(*) as number_of_activities, MAX(STAGING_admin_activities.creation) as last_activity_creation, TIMESTAMPDIFF(MINUTE,login_creation,next_login_time) as time_lenght

actually 'last_activity_creation' is displayed correctly but if I use it in side the TIMESTAMPDIFF

TIMESTAMPDIFF(MINUTE,login_creation,last_activity_creation)

I get an error. Any ideas?

Body:
You can try to use LEAD window function in asubquery on STAGING_admin_activities table to get the next creation in every row.

then use BETWEEN to filter your expectation logic.

Query #1

SELECT a.admin_id,
       a.creation login_time,
       MAX(logout.creation) last_activity_time,
       count(*) number_of_activities

FROM (
  SELECT *, LEAD(creation) OVER(PARTITION BY admin_id ORDER BY creation) next_logout_time
  FROM STAGING_admin_activities
) a
INNER JOIN STAGING_admin_login_logout logout
ON a.admin_id = logout.admin_id AND
logout.creation BETWEEN  a.creation AND coalesce(next_logout_time,'9999/12/31') AND
coalesce(next_logout_time,'9999/12/31') <> logout.creation
WHERE  a.admin_id = 5
GROUP BY a.admin_id,
       a.creation;

admin_id
login_time
last_activity_time
number_of_activities

5
2021-03-08 17:19:00
2021-03-08 17:25:00
3

5
2021-03-08 20:11:00
2021-03-08 20:13:00
2

5
2021-03-09 15:08:00
2021-03-09 15:22:00
3

5
2021-03-09 17:01:00
2021-03-09 17:01:00
1

5
2021-03-10 18:15:00
2021-03-10 19:37:00
2

View on DB Fiddle

LEAD window function will return the value from the nth row after the current row in a partition.


问:
How can I get rid of my "@types/react/index" can only be default-imported using 'esModuleInterp' flag lint in React/TypeScript
It's as simple as stated above: React 16.9.22 with TypeScript 3.8.2.  It doesn't affect anything, just crowds my warning window form actually useful things.

In my tsconfig I have:

```<code>{
  "compilerOptions": {
    "esModuleInterop": true
  }
}
</code>```

But every file have the line import React from 'react';

I get the linting error:

.../node_modules/@types/react/index"' can only be default-imported
  using the 'esModuleInterop' flag

possibly relevant deps:

```<code>  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.22.0",
    "@typescript-eslint/parser": "^2.22.0",
    "cross-env": "^5.2.0",
    "eslint": "^6.6.0",
    "eslint-config-react-app": "^4.0.1",
    "eslint-plugin-flowtype": "^2.0.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "eslint-plugin-react": "^7.18.3",
    "typescript": "^3.8.2"
  },
</code>```

答:
```<code>import * as React from "react";
import * as ReactDOM from "react-dom";
</code>```

This is the most futureproof way to import React. If you set --allowSyntheticDefaultImports (or add "allowSyntheticDefaultImports": true) in your tsconfig.json you can use more familiar imports:

```<code>import React from "react";
import ReactDOM from "react-dom";
</code>```

source: https://github.com/typescript-cheatsheets/react

Body:
It's as simple as stated above: React 16.9.22 with TypeScript 3.8.2.  It doesn't affect anything, just crowds my warning window form actually useful things.

In my tsconfig I have:

{
  "compilerOptions": {
    "esModuleInterop": true
  }
}

But every file have the line import React from 'react';

I get the linting error:

.../node_modules/@types/react/index"' can only be default-imported
  using the 'esModuleInterop' flag

possibly relevant deps:

  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.22.0",
    "@typescript-eslint/parser": "^2.22.0",
    "cross-env": "^5.2.0",
    "eslint": "^6.6.0",
    "eslint-config-react-app": "^4.0.1",
    "eslint-plugin-flowtype": "^2.0.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "eslint-plugin-react": "^7.18.3",
    "typescript": "^3.8.2"
  },

Body:
import * as React from "react";
import * as ReactDOM from "react-dom";

This is the most futureproof way to import React. If you set --allowSyntheticDefaultImports (or add "allowSyntheticDefaultImports": true) in your tsconfig.json you can use more familiar imports:

import React from "react";
import ReactDOM from "react-dom";

source: https://github.com/typescript-cheatsheets/react


问:
The Sql Database is not deleted
I'm getting an error deleting a database I created about a year ago. in the error, when I run these codes, it says:

```<code>USE MASTER;
GO
DROP DATABASE StoreDatabase;
GO
</code>```

Cannot drop the database 'StoreDatabase', because it does not exist or you do not have permission.

when I try to manually delete it manually

Right-click => Delete => Delete Backup and restore history information for database and Close Existing connections

in the error message it says:

The object of type "Database" named "StoreDatabase" does not exist on the server (SqlManagerUI)

how can I solve this error. thank you for your help.

答:
The Sql Database is not deleted

You do not delete a database but DROP it

Cannot drop the database 'StoreDatabase', because it does not exist or you do not have permission.

Error includes two parts: (1) database does not exist or (2) you do not have permission. Please connect the server using SSMS or Azure Data Studio

(1) Use SSMS and execute the following query in order to confirm that the database exists

```<code>select DatabaseName = [name] FROM sys.databases
where [name] = 'StoreDatabase'
GO
</code>```

(2) In order to DROP a database you need to have CONTROL permission on the database, or ALTER ANY DATABASE permission on the server, or to be membership in the db_owner fixed database role. Execute the following query to check that you have the permissions

```<code>USE StoreDatabase;
SELECT * FROM fn_my_permissions (NULL, 'DATABASE')
where permission_name = 'CONTROL'
GO

SELECT * FROM fn_my_permissions(NULL, 'SERVER')
where permission_name = 'ALTER ANY DATABASE'
GO

USE master;
select DatabaseName = [name], DatabaseOwner = suser_sname(owner_sid)
FROM sys.databases
where [name] = 'StoreDatabase'
GO
</code>```

Try to DROP the database when you are connected as sysadmin (for example the USER sa)

Title: The Sql Database is not deleted

Body:
I'm getting an error deleting a database I created about a year ago. in the error, when I run these codes, it says:

USE MASTER;
GO
DROP DATABASE StoreDatabase;
GO

Cannot drop the database 'StoreDatabase', because it does not exist or you do not have permission.

when I try to manually delete it manually

Right-click => Delete => Delete Backup and restore history information for database and Close Existing connections

in the error message it says:

The object of type "Database" named "StoreDatabase" does not exist on the server (SqlManagerUI)

how can I solve this error. thank you for your help.

Body:
The Sql Database is not deleted

You do not delete a database but DROP it

Cannot drop the database 'StoreDatabase', because it does not exist or you do not have permission.

Error includes two parts: (1) database does not exist or (2) you do not have permission. Please connect the server using SSMS or Azure Data Studio

(1) Use SSMS and execute the following query in order to confirm that the database exists

select DatabaseName = [name] FROM sys.databases
where [name] = 'StoreDatabase'
GO

(2) In order to DROP a database you need to have CONTROL permission on the database, or ALTER ANY DATABASE permission on the server, or to be membership in the db_owner fixed database role. Execute the following query to check that you have the permissions

USE StoreDatabase;
SELECT * FROM fn_my_permissions (NULL, 'DATABASE')
where permission_name = 'CONTROL'
GO

SELECT * FROM fn_my_permissions(NULL, 'SERVER')
where permission_name = 'ALTER ANY DATABASE'
GO

USE master;
select DatabaseName = [name], DatabaseOwner = suser_sname(owner_sid)
FROM sys.databases
where [name] = 'StoreDatabase'
GO

Try to DROP the database when you are connected as sysadmin (for example the USER sa)


问:
How to add the logged in user email in a field in the model directly without using a view in django
I have a field in my model as shown below

```<code>uploaded_by = models.CharField(max_length=255, blank=True, null=True, editable=False)

</code>```

This field will store the username (email in this case) of the user who has uploaded the data. As you can see that this is non editable so there is no way the user can edit it. The data has to be entered from the admin pannel. I wanted to know if there is any way to fill this field with the username of the loged in user who is uploading the data. I know if I use the view I can do some thing like

```<code>uploaded_by = request.user
</code>```

So is there a way to do the same directly in the model so that I can use the admin pannel directly to store the username without using a view.

答:
Why recreate when someone has already made a library

You can use django-currentuser
You just need to do this in your models.py

```<code>from django_currentuser.middleware import (
    get_current_user, get_current_authenticated_user)

# As model field:
from django_currentuser.db.models import CurrentUserField
class Foo(models.Model):
    created_by = CurrentUserField()
    updated_by = CurrentUserField(on_update=True)
</code>```

Also, don't forget to add the middleware in settings.py

```<code>MIDDLEWARE = (
    ...,
    'django_currentuser.middleware.ThreadLocalUserMiddleware',
)
</code>```

While this doesn't exactly save the user's email, it will save the user's reference, which is even better, you get all the user's details by doing created_by.email etc

Body:
I have a field in my model as shown below

uploaded_by = models.CharField(max_length=255, blank=True, null=True, editable=False)

This field will store the username (email in this case) of the user who has uploaded the data. As you can see that this is non editable so there is no way the user can edit it. The data has to be entered from the admin pannel. I wanted to know if there is any way to fill this field with the username of the loged in user who is uploading the data. I know if I use the view I can do some thing like

uploaded_by = request.user

So is there a way to do the same directly in the model so that I can use the admin pannel directly to store the username without using a view.

Body:
Why recreate when someone has already made a library

You can use django-currentuser
You just need to do this in your models.py

from django_currentuser.middleware import (
    get_current_user, get_current_authenticated_user)

# As model field:
from django_currentuser.db.models import CurrentUserField
class Foo(models.Model):
    created_by = CurrentUserField()
    updated_by = CurrentUserField(on_update=True)

Also, don't forget to add the middleware in settings.py

MIDDLEWARE = (
    ...,
    'django_currentuser.middleware.ThreadLocalUserMiddleware',
)

While this doesn't exactly save the user's email, it will save the user's reference, which is even better, you get all the user's details by doing created_by.email etc


问:
Create masked textbox but hide masked characters when empty
I want to validate text taken from a textbox and display it in a specific format.

I have tried using a MaskedTextBox, but when the textbox is empty it shows the empty blank lines (underscores) in the text box.

How can I avoid that and show the masked textbox like a simple empty (still masked) textbox?

Also, I want data like csc-(somenumber). Can I add some random number automatically after 'csc-' characters?

答:
For your textbox, use the MaskedTextBox class.

http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx

For getting a random number

```<code>Dim s = "csc-" & New Random().Next(1000, 10000).ToString
</code>```

Body:
For your textbox, use the MaskedTextBox class.

http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.aspx

For getting a random number

Dim s = "csc-" & New Random().Next(1000, 10000).ToString


问:
PowerBI snowflake connector incorrectly uses ',' as decimal separator
When using the SnowFlake connector for PowerBI, the Snowflake sql query is not correctly generated by PowerBI. It is generated with a ',' as decimal separator instead of '.'

I have a snowflake table which contains (among others):

Timestamps : ENQUEUEDTIMEUTC

Beer Temperatures : BEER_TEMPERATURE

I try to display the moment corresponding to the highest beer temperature. When more than one moment exists, I want the earliest moment.

What I do:

card visualization of ENQUEUEDTIME

Filter on visual : Top N filter --> top 1 of BEER_TEMPERATURE

What goes wrong:

When generating this query, PowerBI incorrectly passes a ',' to represent the value. The query becomes:

```<code>from "<my warehouse>"."<my schema>"."<my table>"
        where "BEER_TEMPERATURE" = CAST(15,826941 as DOUBLE) ...
</code>```

This query seems to fail on the ','. It produces the following error message:

SQL compilation error: syntax error line 19 at position 42 unexpected
','. syntax error line 19 at position 43 unexpected '826941'. syntax
error line 19 at position 59 unexpected ')'.

The value of 15.83 is the correct value for the beer temperature.

How can I change ',' to '.' in the query PowerBI sends to snowflake?

答:
In Power BI Desktop go to File -> Options and settings -> Options

Here you have two settings that affect what separator you have, the first is in CURRENT FILE -> Regional Settings:

and the second GLOBAL -> Regional Settings:

Body:
When using the SnowFlake connector for PowerBI, the Snowflake sql query is not correctly generated by PowerBI. It is generated with a ',' as decimal separator instead of '.'

I have a snowflake table which contains (among others):

Timestamps : ENQUEUEDTIMEUTC

Beer Temperatures : BEER_TEMPERATURE

I try to display the moment corresponding to the highest beer temperature. When more than one moment exists, I want the earliest moment.

What I do:

card visualization of ENQUEUEDTIME

Filter on visual : Top N filter --> top 1 of BEER_TEMPERATURE

What goes wrong:

When generating this query, PowerBI incorrectly passes a ',' to represent the value. The query becomes:

from "<my warehouse>"."<my schema>"."<my table>"
        where "BEER_TEMPERATURE" = CAST(15,826941 as DOUBLE) ...

This query seems to fail on the ','. It produces the following error message:

SQL compilation error: syntax error line 19 at position 42 unexpected
','. syntax error line 19 at position 43 unexpected '826941'. syntax
error line 19 at position 59 unexpected ')'.

The value of 15.83 is the correct value for the beer temperature.

How can I change ',' to '.' in the query PowerBI sends to snowflake?


问:
Getting "sslv3 alert handshake failure" when trying to connect to imap
i need to do a script for imap backup but when i'm trying to connect to the imap server with my script i'm getting that error:</p>
```<code>  File "c:\Users\Lenovo\Desktop\python\progettoscuola.py", line 5, in <module>
    imapSrc = imaplib.IMAP4_SSL('mail.safemail.it')
  File "C:\Program Files\Python310\lib\imaplib.py", line 1323, in __init__
    IMAP4.__init__(self, host, port, timeout)
  File "C:\Program Files\Python310\lib\imaplib.py", line 202, in __init__
    self.open(host, port, timeout)
  File "C:\Program Files\Python310\lib\imaplib.py", line 1336, in open
    IMAP4.open(self, host, port, timeout)
  File "C:\Program Files\Python310\lib\imaplib.py", line 312, in open
    self.sock = self._create_socket(timeout)
  File "C:\Program Files\Python310\lib\imaplib.py", line 1327, in _create_socket
    return self.ssl_context.wrap_socket(sock,
  File "C:\Program Files\Python310\lib\ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Program Files\Python310\lib\ssl.py", line 1070, in _create
    self.do_handshake()
  File "C:\Program Files\Python310\lib\ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)```
</code>```

答:
Python 3.10 increased the default security settings of the TLS stack by among other things prohibiting any ciphers which still use the RSA key exchange. RSA key exchange is long considered inferior since it does not provide forward secrecy and is therefore also no longer available in TLS 1.3. So in general the change in Python 3.10 can be considered an improvement.

But, some servers still require this obsolete key exchange and mail.safemail.it seems to be among these. Connecting to such servers with the newly hardened TLS settings will now fail, even if it succeeded with older versions of Python.

To make connections possible again it is necessary to use weaker security settings. For this specific server it can be done by falling back to the DEFAULT ciphers used by OpenSSL. The following code will create a new SSL context and use it for connecting to the host. The important part here is to use weaker settings using ctx.set_ciphers('DEFAULT') .

```<code>import imaplib
import ssl
ctx = ssl.create_default_context()
ctx.set_ciphers('DEFAULT')
imapSrc = imaplib.IMAP4_SSL('mail.safemail.it', ssl_context = ctx)
</code>```

Body:
i need to do a script for imap backup but when i'm trying to connect to the imap server with my script i'm getting that error:

  File "c:\Users\Lenovo\Desktop\python\progettoscuola.py", line 5, in <module>
    imapSrc = imaplib.IMAP4_SSL('mail.safemail.it')
  File "C:\Program Files\Python310\lib\imaplib.py", line 1323, in __init__
    IMAP4.__init__(self, host, port, timeout)
  File "C:\Program Files\Python310\lib\imaplib.py", line 202, in __init__
    self.open(host, port, timeout)
  File "C:\Program Files\Python310\lib\imaplib.py", line 1336, in open
    IMAP4.open(self, host, port, timeout)
  File "C:\Program Files\Python310\lib\imaplib.py", line 312, in open
    self.sock = self._create_socket(timeout)
  File "C:\Program Files\Python310\lib\imaplib.py", line 1327, in _create_socket
    return self.ssl_context.wrap_socket(sock,
  File "C:\Program Files\Python310\lib\ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Program Files\Python310\lib\ssl.py", line 1070, in _create
    self.do_handshake()
  File "C:\Program Files\Python310\lib\ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)```

Body:
Python 3.10 increased the default security settings of the TLS stack by among other things prohibiting any ciphers which still use the RSA key exchange. RSA key exchange is long considered inferior since it does not provide forward secrecy and is therefore also no longer available in TLS 1.3. So in general the change in Python 3.10 can be considered an improvement.

But, some servers still require this obsolete key exchange and mail.safemail.it seems to be among these. Connecting to such servers with the newly hardened TLS settings will now fail, even if it succeeded with older versions of Python.

To make connections possible again it is necessary to use weaker security settings. For this specific server it can be done by falling back to the DEFAULT ciphers used by OpenSSL. The following code will create a new SSL context and use it for connecting to the host. The important part here is to use weaker settings using ctx.set_ciphers('DEFAULT') .

import imaplib
import ssl
ctx = ssl.create_default_context()
ctx.set_ciphers('DEFAULT')
imapSrc = imaplib.IMAP4_SSL('mail.safemail.it', ssl_context = ctx)


问:
Latest updates cause auto print debug statements without requesting
I just updated my environment to be the newest and getting strange messages for normal usage. Utilizing packages results in debug statements being thrown without requesting this.

Google is not revealing anything.  Surely someone has seen this before. How can I prevent this?
I can try and post my package environment if that would help.  I am on python 3.9.10.

Example when using yahoo_fin:

```<code>from yahoo_fin import stock_info
df = stock_info.get_data('msft', interval='1d')

[D:urllib3.connectionpool] Starting new HTTPS connection (%d): %s:%s
[D:urllib3.connectionpool] %s://%s:%s "%s %s %s" %s %s
</code>```

Example when using matplotlib (if using negatives in a log plot, which an error is expected):

```<code>[D:matplotlib.ticker] vmin %s vmax %s
[D:matplotlib.ticker] ticklocs %r
</code>```

答:
So I decided to delete the entire python environment and start from scratch ensuring that every single package was the latest (I last updated about 1 month ago).

Looks like these random messages issue have entirely disappeared. I guess if anyone else has this problem, try redoing the entire environment.

Body:
I just updated my environment to be the newest and getting strange messages for normal usage. Utilizing packages results in debug statements being thrown without requesting this.

Google is not revealing anything.  Surely someone has seen this before. How can I prevent this?
I can try and post my package environment if that would help.  I am on python 3.9.10.

Example when using yahoo_fin:

from yahoo_fin import stock_info
df = stock_info.get_data('msft', interval='1d')

[D:urllib3.connectionpool] Starting new HTTPS connection (%d): %s:%s
[D:urllib3.connectionpool] %s://%s:%s "%s %s %s" %s %s

Example when using matplotlib (if using negatives in a log plot, which an error is expected):

[D:matplotlib.ticker] vmin %s vmax %s
[D:matplotlib.ticker] ticklocs %r


问:
Turning my desktop webpage into responsive design to fit for ipad + mobile
i have created a webpage initially for laptop view, and i try to use media queries to adjust the css styling and make it fit on ipad and mobile, as i set the width of the (.content) element to 100%, the content doesnt actually become 100%, there is a relatively big margin. i also want to say that i used position relative to adjust the position of the form, and paragraph elements in my initial laptop view, could it affect my media query ?
anyhelp would be appreciated, i have to submit this assignment tomorrow :D thank you

enter image description here

body{
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    background-color: rgb(250, 250, 250);
}

.content {
    max-width: 1400px;
    margin: auto;
    background: rgb(247, 246, 244);
    padding: 10px;
}

div.logo {
    width: 100%;
    height: 200px;
    background-color: rgb(147, 235, 238);
}

div.navi {

    background-color: rgb(228, 226, 217);
    width: 100%;
    height: 50px;
    margin-top: 15px;
    text-align: center;
    font-size: 19px;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    padding-top: 1px;
    margin-bottom: 1px;
}

p.nav {
    position: relative;
    bottom: 5px;
    border-style: solid;
}

a:link {
    text-decoration: none;
    color: rgb(97, 87, 226);
}

img {
    margin-left: 20px;
    width: 400px;

}

/* inner body styling */

div.inner-body {
    background-image: url(image/book2.png);
    margin-bottom: 20px;
    border-style: solid;
    margin-top: 20px;
    height: 1200px;
  position: relative;
}

.header {

    width: 700px;
    position: relative;
    left:1000px;
    left: 338px;
    font-size: 30px;

}

.para {

    width: 800px;
    position: relative;
    left:345px;
    top:74px;
    background-color: rgb(206, 200, 180);
    font-size: 25px;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    border-radius: 20px;
    padding: 5px;
}

form {
    padding: 20px;
    border-radius: 20px;
    width: fit-content;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    position: relative;
    left:350px;
    top:140px;
    background-color: rgb(240, 239, 228);
}

.navi2 {

    width: fit-content;
    width: 300px;
    height: 600px;
    position:absolute;
    bottom: 600px;
    background-color: cadetblue;
    font-size: 20px;
    border-radius: 20px;
    top:300px;
}

.user-links {
    position: relative;
    left:20px;
    bottom:30px;
}

.user-links:link{
    color: brown;
}

.userlogo {
    width: 200px;
    border-radius: 100px;
    position: relative;
    left: 30px;
    bottom: 100px;
}

.btn {
    width: 100px;
    border-radius: 5px;
    margin-top: 10px;
}

/* footer styling */

.emaillogo, .telelogo {
    width: 20px;
}
div.foot {

    background-color: brown;
}
footer{
    background-color: rgb(126, 226, 230);
    height: 200px;
}

.footimage {
    width: 400px;

    margin: 0;
}
div.contact{
    width: fit-content;
    height: 200px;

    position: relative;
    left: 400px;
    bottom: 185px;
    font-size: 12px;

}

.usefullinks {
    width: fit-content;
    font-size: 12px;
    position: relative;
    left:750px;
    bottom:400px;

}

.connect {
    width: fit-content;
    position: relative;
    left: 1000px ;
    bottom: 524px;
    font-size: 12px;
}

.fb, .tw, .yt, .ln {
    width: 50px;
    border-radius: 10px;

}

@media screen and (max-width:915px) {
    .content{
        width: 100%;
    }

    .inner-body {
        width: 100%;
    }
}

@media screen and (max-width:415px) {
    .content{
        width: 100%;
    }

    .inner-body {
        width: 100%;
    }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="log-it-reports.css">
    <script src="log-it-reports.js"></script>
    <title>Document</title>
</head>
<body>
    <div class= "content">
        <div class="logo">
        <img src="image/logo1.png" alt="Academy Logo" >
        </div>
        <div class="navi">
            <p id="nav">
                 Home |
                Academics |
                Services |
                Covid-19 |
                Students & Parents |
                Transcripts  |
                Staff |
                Career |
                Events |
                Student Account |

        </p>
        </div>

       <div class="inner-body">
           <div class = "header" >
            <h1>Steps For IT-Issues Logging:</h1>
           </div>

       <div class="para">
           <p>Please read the following instructions before submitting a report:</p>
           <ol>
               <li>Fill out all of the fields.</li>
               <li>Use a valid email.</li>
               <li>Select a problem type.</li>
               <li>Be as detailed as possible so that the IT staff could address the issue properly (100 characters minumum).</li>
               <li>Normally most issues get addressed within 2 hours, please be patient.</li>
           </ol>
       </div>
       <div class="form1">
        <form  method="GET" onsubmit=" return formValidations() " action="log-it-reports.html"><br>
          <div id= "errorMsg"></div>
          <div>
          <label for="subject"><b>Subject:</label>
          <input id="subject" type="text" placeholder="Subject Title"  >
          </div><br>
          <div class="error" id= "errorMsg2"></div>
          <div>
          <label for="email"><b>Email:</label>
          <input id="email" type="email" placeholder="staff@wearview.com">
          </div><br>

          <div>
            <select name="techtype" id="problemtypes">
                <option value="">Problem Type</option>
                <option value="Hardware">Hardware</option>
                <option value="Software">Software</option>
                <option value="Other">Other</option>
              </select>
          </div>
          <div class="error" id= "errorMsg3"></div><br>

          <div>
          <textarea id="description" placeholder="Description goes here" name="descript" rows="15" cols="50"></textarea>
          </div>

<div class="error" id= "errorMsg4"></div>

          <div>
            <button type="submit" class="btn">Submit</button>
            <input type="checkbox" id="notify" name="notify" value="">
            <label for="notify">Inform me by email when issue is resolved.</label>
        </div>

        </form>
       </div>
       <div class="navi2">
           <div class="userimage">
               <img class="userlogo" src="image/userlogo.png" alt="User Image">
           </div>
           <div class="user-links">
               <navi>
                Staff Name <br><br>
                Inbox <br><br>
                Notifications <br><br>
                Files <br><br>
                Settings <br><br>
                Help  <br><br>
                QR For Mobile <br><br>
                Log Out
               </navi>
           </div>
       </div>
    </div>
       <div class="foot">
           <footer id = "footy">
           <div>
            <img class="footimage" src="image/logo1.png" alt="Academy Logo"  width="400px">
           </div>
           <div class="contact">

               <h3>Contact Us</h3>
                <p><img class="emaillogo" src="image/email (2).png" alt="emaillogo"> :wearview_academy@wearview.com</p>
              <p><img class="telelogo" src="image/tele.png" alt="telelogo"> :+2499100000000</p>

           </div>
           <div class="usefullinks">
            <h3>Userful Links</h3>
            <ul>
                <li>Career</li>
                <li>Report A Website Issue</li>
                <li>About Us</li>
                <li>Covid-19</li>
                <li>Events</li>

            </ul>
           </div>
           <div class="connect">
            <h3>Connect With Us </h3><br>
                <img class="fb" src="image/fb.png" alt = "Facebook" />
                <img class="tw" src="image/tw.jpg" alt = "Twitter" />
                <img class="yt" src="image/you.png" alt = "Youtube" />
                <img class="ln" src="image/linkd.png" alt = "LinkedIn" />

           </div>
           </footer>
       </div>

    </div>

</body>
</html></code>```

答:
You should update your css to the following:

@media (max-width:415px) {
    .content{
        width: 100%;
        margin: 0;
        padding: 0;
    }
    body {
        margin: 0;
    }
    .inner-body {
        width: 100%;
    }
}
```

This will get rid of the space between the content and the screen border!

Body:
i have created a webpage initially for laptop view, and i try to use media queries to adjust the css styling and make it fit on ipad and mobile, as i set the width of the (.content) element to 100%, the content doesnt actually become 100%, there is a relatively big margin. i also want to say that i used position relative to adjust the position of the form, and paragraph elements in my initial laptop view, could it affect my media query ?
anyhelp would be appreciated, i have to submit this assignment tomorrow :D thank you

enter image description here

body{
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    background-color: rgb(250, 250, 250);
}

.content {
    max-width: 1400px;
    margin: auto;
    background: rgb(247, 246, 244);
    padding: 10px;
}

div.logo {
    width: 100%;
    height: 200px;
    background-color: rgb(147, 235, 238);
}

div.navi {

    background-color: rgb(228, 226, 217);
    width: 100%;
    height: 50px;
    margin-top: 15px;
    text-align: center;
    font-size: 19px;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    padding-top: 1px;
    margin-bottom: 1px;
}

p.nav {
    position: relative;
    bottom: 5px;
    border-style: solid;
}

a:link {
    text-decoration: none;
    color: rgb(97, 87, 226);
}

img {
    margin-left: 20px;
    width: 400px;

}

/* inner body styling */

div.inner-body {
    background-image: url(image/book2.png);
    margin-bottom: 20px;
    border-style: solid;
    margin-top: 20px;
    height: 1200px;
  position: relative;
}

.header {

    width: 700px;
    position: relative;
    left:1000px;
    left: 338px;
    font-size: 30px;

}

.para {

    width: 800px;
    position: relative;
    left:345px;
    top:74px;
    background-color: rgb(206, 200, 180);
    font-size: 25px;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    border-radius: 20px;
    padding: 5px;
}

form {
    padding: 20px;
    border-radius: 20px;
    width: fit-content;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    position: relative;
    left:350px;
    top:140px;
    background-color: rgb(240, 239, 228);
}

.navi2 {

    width: fit-content;
    width: 300px;
    height: 600px;
    position:absolute;
    bottom: 600px;
    background-color: cadetblue;
    font-size: 20px;
    border-radius: 20px;
    top:300px;
}

.user-links {
    position: relative;
    left:20px;
    bottom:30px;
}

.user-links:link{
    color: brown;
}

.userlogo {
    width: 200px;
    border-radius: 100px;
    position: relative;
    left: 30px;
    bottom: 100px;
}

.btn {
    width: 100px;
    border-radius: 5px;
    margin-top: 10px;
}

/* footer styling */

.emaillogo, .telelogo {
    width: 20px;
}
div.foot {

    background-color: brown;
}
footer{
    background-color: rgb(126, 226, 230);
    height: 200px;
}

.footimage {
    width: 400px;

    margin: 0;
}
div.contact{
    width: fit-content;
    height: 200px;

    position: relative;
    left: 400px;
    bottom: 185px;
    font-size: 12px;

}

.usefullinks {
    width: fit-content;
    font-size: 12px;
    position: relative;
    left:750px;
    bottom:400px;

}

.connect {
    width: fit-content;
    position: relative;
    left: 1000px ;
    bottom: 524px;
    font-size: 12px;
}

.fb, .tw, .yt, .ln {
    width: 50px;
    border-radius: 10px;

}

@media screen and (max-width:915px) {
    .content{
        width: 100%;
    }

    .inner-body {
        width: 100%;
    }
}

@media screen and (max-width:415px) {
    .content{
        width: 100%;
    }

    .inner-body {
        width: 100%;
    }
}

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="log-it-reports.css">

    <title>Document</title>

                 Home |
                Academics |
                Services |
                Covid-19 |
                Students & Parents |
                Transcripts  |
                Staff |
                Career |
                Events |
                Student Account |

Steps For IT-Issues Logging:

Please read the following instructions before submitting a report:

Fill out all of the fields.

Use a valid email.

Select a problem type.

Be as detailed as possible so that the IT staff could address the issue properly (100 characters minumum).

Normally most issues get addressed within 2 hours, please be patient.

        <form  method="GET" onsubmit=" return formValidations() " action="log-it-reports.html">

          Subject:
          <input id="subject" type="text" placeholder="Subject Title"  >

          Email:
          <input id="email" type="email" placeholder="staff@wearview.com">

            <select name="techtype" id="problemtypes">
                <option value="">Problem Type</option>
                <option value="Hardware">Hardware</option>
                <option value="Software">Software</option>
                <option value="Other">Other</option>
              </select>

          <textarea id="description" placeholder="Description goes here" name="descript" rows="15" cols="50"></textarea>

            <button type="submit" class="btn">Submit</button>
            <input type="checkbox" id="notify" name="notify" value="">
            Inform me by email when issue is resolved.

        </form>

               <navi>
                Staff Name

                Inbox

                Notifications

                Files

                Settings

                Help

                QR For Mobile

                Log Out
               </navi>

Contact Us

 :wearview_academy@wearview.com

 :+2499100000000

Userful Links

Career

Report A Website Issue

About Us

Covid-19

Events

Connect With Us

Body:
You should update your css to the following:

@media (max-width:415px) {
    .content{
        width: 100%;
        margin: 0;
        padding: 0;
    }
    body {
        margin: 0;
    }
    .inner-body {
        width: 100%;
    }
}

This will get rid of the space between the content and the screen border!


问:
What does "operator MyType () {}" mean in C++
I see a function member in a c++ class:

```<code>class bar{
//..
}

class foo{
public:
    foo(){};
    //...
    operator bar(){
       return bar();
    }
}
</code>```

it's not an operator overloading, can anyone explain it to me ?

答: It is a user-defined conversion operator which constructs a bar object from the foo object. The purpose is to enable type casting from foo to bar.

Body:
I see a function member in a c++ class:

class bar{
//..
}

class foo{
public:
    foo(){};
    //...
    operator bar(){
       return bar();
    }
}

it's not an operator overloading, can anyone explain it to me ?


问:
Hilt integration crashes application MainActivity_GeneratedInjector
Trying to integrate hilt using android Api Documentation but app crashed with following exception. https://developer.android.com/training/dependency-injection/hilt-android</p>
```<code>java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.package.application/com.package.application.MainActivity}:

java.lang.ClassCastException: com.package.application.DaggerAppApplication_HiltComponents_ApplicationC$ActivityRetainedCImpl$ActivityCImpl
cannot be cast to com.package.application.MainActivity_GeneratedInjector

</code>```

答:
I had the same problem and here are the steps I followed:

appModule starts with internal

In your app level build.gradle inside android section add the following line:

```<code>   enableExperimentalClasspathAggregation = true
}

</code>```

My dependencies are in this order:

```<code>
classpath "com.google.dagger:hilt-android-gradle-plugin:2.40.5"

    app-level build.gradle:
     top plugin section

 plugin{
  ...........
  id 'kotlin-kapt'
  id 'dagger.hilt.android.plugin'
 }

     dependencies section
     //dagger-hilt
 implementation 'com.google.dagger:hilt-android:2.40.5'
 kapt 'com.google.dagger:hilt-android-compiler:2.40.5'```
```

Body:
Trying to integrate hilt using android Api Documentation but app crashed with following exception. https://developer.android.com/training/dependency-injection/hilt-android

java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.package.application/com.package.application.MainActivity}:

java.lang.ClassCastException: com.package.application.DaggerAppApplication_HiltComponents_ApplicationC$ActivityRetainedCImpl$ActivityCImpl
cannot be cast to com.package.application.MainActivity_GeneratedInjector

Body:
I had the same problem and here are the steps I followed:

appModule starts with internal

In your app level build.gradle inside android section add the following line:

   enableExperimentalClasspathAggregation = true
}

My dependencies are in this order:

classpath "com.google.dagger:hilt-android-gradle-plugin:2.40.5"

    app-level build.gradle:
     top plugin section

 plugin{
  ...........
  id 'kotlin-kapt'
  id 'dagger.hilt.android.plugin'
 }

     dependencies section
     //dagger-hilt
 implementation 'com.google.dagger:hilt-android:2.40.5'
 kapt 'com.google.dagger:hilt-android-compiler:2.40.5'```


问:
IIS SSL Certificate for Intranet website (Not Trusted)
I have created a self-signed certificate on IIS and added it to Trusted Root Certificates using mmc.exe and when I launch my intranet using https://ipaddress shows secure. But when I go LAN and browse for the https://ipaddress shows me not trusted. I also used on IE, which I installed the certificate but still showing not trusted. Am I missing something, please help.</p>

答:
If you use subdomain, i.e. subdomain.domain.com, the domain administrator (IT) should provide you with a wildcard certificate.
The domain administrator generates and assign the certificate to your subdomain server, also should allow port 80 and 443 firewall rules so that users can visit the site in the intranet.

The above answered methods can be used to generate the certificate, preferably sha256 certificate. Once the certificate is provided to you, install it on your server to “Personal”, “Trusted Root Certification Authorities” and “Web Hosting”. Open the certificate to validate it installed successfully, and you can use the thumbprint to sign files, such as rdp files. To do this, on your keyboard, START + R  to open the run command and enter “certlm.msc” and once the window opens, navigate to “Trusted Root Certification Authorities” and there should be the certificate that was just being imported, i.e. *.domain.com, double click to open the certificate and click on Details tab. Drag the scroll bar until the Thumbprint is visible and then click on it to revel the code. Create an rdp file to your subdomain and save it to your desired location, such as desktop. Open CMD terminal and CD to the location and enter “rdpsign /sha256 thumbprint ‘./sumdomain.domain.com.rdp’”.  Done, now when you open the connection, the compute should be trusted to connect to RDP, this process is not necessary, but it is nice to see the publisher is recognized.

The benefit of having the *.domain.com certificate generated for your organisation is that users should have this certificate already installed on their PCs and when they visit your website, users would automatically see the HTTPS secure padlock for SSL certificate. The certificate would usually be generated to allow all subdomains, i.e. *.domain.com.

IIS, When setting up the HTTPS binding on your IIS settings, check the "Require Server Name Indication" and continue to browse for the certificate and select and save the settings. Also turn off Directory Browsing while you’re there. Go to SSL Settings and check on Require SSL and hit Apply and go back. To control the flow of HTTP to HTTPS when users visit your site, you can use “URL Rewrite”, install it from Microsoft and you can do the configuration, please check on https://www.ssl.com/how-to/redirect-http-to-https-with-windows-iis-10/ for the appropriate settings. Even though, this answer is out of the scope for the question, it may be helpful for anyone who look forward to configuring their intranet site. Next to checkout is the security for who accesses your site, check on AppPoolIdentity, more help on IIS7 Permissions Overview - ApplicationPoolIdentity.


问:
ModuleNotFoundError: No module named 'ncc'
I am trying to install 'ncc' package to use this method (ncc.normxcorr2D) to get correlation results from a template and an image. However, I am getting this error:

```<code>ModuleNotFoundError: No module named 'ncc'
</code>```

even though I installed ncc with this:

```<code>pip install ncc
</code>```

I think there are some other required packages to successfully install it but I don't know how to check. Would you please help me with this issue.

Thanks

答:
If you are using a virtual environment , use conda install -c biobuilds ncclient --user

For more information on User Installs

Body:
I am trying to install 'ncc' package to use this method (ncc.normxcorr2D) to get correlation results from a template and an image. However, I am getting this error:

ModuleNotFoundError: No module named 'ncc'

even though I installed ncc with this:

pip install ncc

I think there are some other required packages to successfully install it but I don't know how to check. Would you please help me with this issue.

Thanks


问:
CouchDB dump to file and load from file
I cannot replicate between two couchdb servers, so I would like to dump to file from one server and load from file into the other server.

I used this statement to dump and it worked fine:

```<code>curl -X GET http://localhost:5984/<DATABASE_NAME>/_all_docs?include_docs=true > FILE.txt
</code>```

But when I used this statement to load:

```<code>curl -d @FILE.txt -H “Content-Type: application/json” -X POST http://localhost:5984/<DATABASE_NAME>/_bulk_docs
</code>```

it failed like this:

```<code>curl: (6) Could not resolve host: application; Host not found {"error":"bad_content_type","reason":"Content-Type must be application/json"}
</code>```

Any ideas?

答:
There's also github.com/danielebailo/couchdb-dump , which might help to clean out old transients, the authors state:

We've seen 15GB database files, containing only 2.1GB of raw JSON, reduced to 2.5GB on disk after import!

There are also hints on how update_seq works if you want do sync clusters.

Title: CouchDB dump to file and load from file

Body:
I cannot replicate between two couchdb servers, so I would like to dump to file from one server and load from file into the other server.

I used this statement to dump and it worked fine:

curl -X GET http://localhost:5984/<DATABASE_NAME>/_all_docs?include_docs=true > FILE.txt

But when I used this statement to load:

curl -d @FILE.txt -H “Content-Type: application/json” -X POST http://localhost:5984/<DATABASE_NAME>/_bulk_docs

it failed like this:

curl: (6) Could not resolve host: application; Host not found {"error":"bad_content_type","reason":"Content-Type must be application/json"}

Any ideas?


问:
Difference between Tokenizer and TextVectorization layer in tensorflow
New to TensorFlow

I saw couple of small NLP projects where people use the 'tf.keras.preprocessing.Tokenizer' to pre-process their text (link: https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/text/Tokenizer )

In some cases, they directly add 'tf.keras.layers.TextVectorization' layer while making the model (link : https://www.tensorflow.org/api_docs/python/tf/keras/layers/TextVectorization)

May I know what's the difference between the two in terms of usage and when to choose which option?

答:
The Tokenizer, as the name suggests, tokenizes the text. Tokenization is the process of splitting text to individual elements (character, word, sentence, etc).

tf.keras.preprocessing.text.Tokenizer(
    num_words=None,
    filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n',
    lower=True, split=' ', char_level=False, oov_token=None,
    document_count=0, **kwargs
)
```
<p>The result of <code>tf.keras.preprocessing.text.Tokenizer</code> is then used to convert to integer sequences using <code>texts_to_sequences</code>.</p>
<p>On the other hand <code>tf.keras.layers.TextVectorization</code> converts the text to integer sequences.</p>
<pre class="lang-py prettyprint-override"><code>tf.keras.layers.TextVectorization(
    max_tokens=None, standardize='lower_and_strip_punctuation',
    split='whitespace', ngrams=None, output_mode='int',
    output_sequence_length=None, pad_to_max_tokens=False, vocabulary=None,
    idf_weights=None, sparse=False, ragged=False, **kwargs
)
</code>```

Body:
The Tokenizer, as the name suggests, tokenizes the text. Tokenization is the process of splitting text to individual elements (character, word, sentence, etc).

tf.keras.preprocessing.text.Tokenizer(
    num_words=None,
    filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n',
    lower=True, split=' ', char_level=False, oov_token=None,
    document_count=0, **kwargs
)

The result of tf.keras.preprocessing.text.Tokenizer is then used to convert to integer sequences using texts_to_sequences.

On the other hand tf.keras.layers.TextVectorization converts the text to integer sequences.

tf.keras.layers.TextVectorization(
    max_tokens=None, standardize='lower_and_strip_punctuation',
    split='whitespace', ngrams=None, output_mode='int',
    output_sequence_length=None, pad_to_max_tokens=False, vocabulary=None,
    idf_weights=None, sparse=False, ragged=False, **kwargs
)


问:
Multiple subnets in same VNet with Terrafrom
I'm completely new to terraform and I'm trying to learn and write a TF code to automate Azure VM deployment. I'm trying to cover each parts as modules (except rg) rather than keeping it in a single main.tf file.
My intention is to create 1 vnet (TESTVNET) and create multiple subnets in same Vnet, where I can define the subnet name and address in my tfvars file.

I'm able to reach till creation on VNet, but cant loop through the defined subnets

Please go through my code. File Main.tf

```<code>    resource "azurerm_resource_group" "resource_group" {
      name     = var.RGname
      location = var.RGlocation
    }

    module "VNET" {
      source              = "./Modules/NetworkConfig"
      name                = var.VNETname
      address_space       = var.address_space
      location            = var.RGlocation
      resource_group_name = azurerm_resource_group.resource_group.name
    }

    module "SUBNETS" {
      source               = "./Modules/SubnetConfig"
      Subnetlist = var.Subnetlist
      virtual_network_name = module.VNET.vnet_name
      resource_group_name  = azurerm_resource_group.resource_group.name
      depends_on           = [azurerm_resource_group.resource_group, module.VNET.vnet]

    }

Variables.tf (of main)

    variable "RGlocation" {
    }

    variable "RGname" {
    }

    variable "VNETname" {
    }

    variable "address_space" {
    }

    variable "Subnetlist" {
      type = map(object({
        name    = list(string)
        address = list(string)
    }))
    }
</code>```

File main.tfvars

```<code>    RGlocation = "westus"
    RGname     = "TEST-RG1"

    VNETname      = "TEST-VNET-01"
    address_space = "10.0.0.0/16"

    Subnetlist = {
      "list" = {
        name    = ["TESTSUBNET","TESTSUBNET1","TESTSUBNET2"]
        address = ["10.0.1.0/24","10.0.2.0/24","10.0.3.0/24"]
      }
    }
</code>```

File Subnets.tf (module)

```<code>    resource "azurerm_subnet" "SUBNETS" {
        for_each=var.Subnetlist
        name=each.value.name
        address_prefixes=each.value.address
          resource_group_name  = var.resource_group_name
          virtual_network_name = var.virtual_network_name

        }
</code>```

File variable.tf (subnet module)

```<code>    variable "resource_group_name" {
    }

    variable "virtual_network_name" {
    }

    variable "Subnetlist" {
      type = map(object({
        name    = list(string)
        address = list(string)
      }))
    }
</code>```

Below if the error that I'm getting

```<code>    ╷
    │ Error: Incorrect attribute value type
    │
    │   on Modules\SubnetConfig\Subnet.tf line 3, in resource "azurerm_subnet" "SUBNETS":
    │    3: name=each.value.name
    │     ├────────────────
    │     │ each.value.name is list of string with 3 elements
    │
    │ Inappropriate value for attribute "name": string required.
</code>```

Could anyone please tell me how to resolve it? Also, please do let me know if this is not the right approach.

答:
The way you iterate over Subnetlist is incorrect - you only get the value of "list" key, ending up with a bundle of subnets instead of individual items. Make it a map of individual subnet objects instead:

```<code>variable "Subnetlist" {
  type = map(object({
    name    = string
    address = string
  }))
}
</code>```

Then pass it in tfvars like:

```<code>Subnetlist = {
    "s1" = { name = "TESTSUBNET", address = "10.0.1.0/24" },
    "s2" = { name = "TESTSUBNET1", address = "10.0.2.0/24" },
    "s3" = { name = "TESTSUBNET2", address = "10.0.3.0/24" }
}
</code>```

Finally consume it in the module like this:

```<code>resource "azurerm_subnet" "SUBNETS" {
    for_each = var.Subnetlist
    name = each.value.name
    address_prefixes = each.value.address
    resource_group_name = var.resource_group_name
    virtual_network_name = var.virtual_network_name
}
</code>```

Body:
I'm completely new to terraform and I'm trying to learn and write a TF code to automate Azure VM deployment. I'm trying to cover each parts as modules (except rg) rather than keeping it in a single main.tf file.
My intention is to create 1 vnet (TESTVNET) and create multiple subnets in same Vnet, where I can define the subnet name and address in my tfvars file.

I'm able to reach till creation on VNet, but cant loop through the defined subnets

Please go through my code. File Main.tf

    resource "azurerm_resource_group" "resource_group" {
      name     = var.RGname
      location = var.RGlocation
    }

    module "VNET" {
      source              = "./Modules/NetworkConfig"
      name                = var.VNETname
      address_space       = var.address_space
      location            = var.RGlocation
      resource_group_name = azurerm_resource_group.resource_group.name
    }

    module "SUBNETS" {
      source               = "./Modules/SubnetConfig"
      Subnetlist = var.Subnetlist
      virtual_network_name = module.VNET.vnet_name
      resource_group_name  = azurerm_resource_group.resource_group.name
      depends_on           = [azurerm_resource_group.resource_group, module.VNET.vnet]

    }

Variables.tf (of main)

    variable "RGlocation" {
    }

    variable "RGname" {
    }

    variable "VNETname" {
    }

    variable "address_space" {
    }

    variable "Subnetlist" {
      type = map(object({
        name    = list(string)
        address = list(string)
    }))
    }

File main.tfvars

    RGlocation = "westus"
    RGname     = "TEST-RG1"

    VNETname      = "TEST-VNET-01"
    address_space = "10.0.0.0/16"

    Subnetlist = {
      "list" = {
        name    = ["TESTSUBNET","TESTSUBNET1","TESTSUBNET2"]
        address = ["10.0.1.0/24","10.0.2.0/24","10.0.3.0/24"]
      }
    }

File Subnets.tf (module)

    resource "azurerm_subnet" "SUBNETS" {
        for_each=var.Subnetlist
        name=each.value.name
        address_prefixes=each.value.address
          resource_group_name  = var.resource_group_name
          virtual_network_name = var.virtual_network_name

        }

File variable.tf (subnet module)

    variable "resource_group_name" {
    }

    variable "virtual_network_name" {
    }

    variable "Subnetlist" {
      type = map(object({
        name    = list(string)
        address = list(string)
      }))
    }

Below if the error that I'm getting

    ╷
    │ Error: Incorrect attribute value type
    │
    │   on Modules\SubnetConfig\Subnet.tf line 3, in resource "azurerm_subnet" "SUBNETS":
    │    3: name=each.value.name
    │     ├────────────────
    │     │ each.value.name is list of string with 3 elements
    │
    │ Inappropriate value for attribute "name": string required.

Could anyone please tell me how to resolve it? Also, please do let me know if this is not the right approach.

Body:
The way you iterate over Subnetlist is incorrect - you only get the value of "list" key, ending up with a bundle of subnets instead of individual items. Make it a map of individual subnet objects instead:

variable "Subnetlist" {
  type = map(object({
    name    = string
    address = string
  }))
}

Then pass it in tfvars like:

Subnetlist = {
    "s1" = { name = "TESTSUBNET", address = "10.0.1.0/24" },
    "s2" = { name = "TESTSUBNET1", address = "10.0.2.0/24" },
    "s3" = { name = "TESTSUBNET2", address = "10.0.3.0/24" }
}

Finally consume it in the module like this:

resource "azurerm_subnet" "SUBNETS" {
    for_each = var.Subnetlist
    name = each.value.name
    address_prefixes = each.value.address
    resource_group_name = var.resource_group_name
    virtual_network_name = var.virtual_network_name
}


问:
Not Able to Connect MongoDB server in Manjaro, Error with exit code 100
I installed Mongodb From AUR Pacman, I tried reinstalling the Mongo but it didn't work, I also tried Arch Troubleshooting methods but it didn't work either.

I get following when I try sudo mongod

[omr@auckwell ~]$ sudo mongo
[sudo] password for omr:
[omr@auckwell ~]$ sudo mongod
[sudo] password for omr:
{"t":{"$date":"2020-10-25T12:26:27.531+05:30"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-10-25T12:26:27.540+05:30"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-10-25T12:26:27.541+05:30"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2020-10-25T12:26:27.542+05:30"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":18541,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"auckwell"}}
{"t":{"$date":"2020-10-25T12:26:27.542+05:30"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.1","gitVersion":"ad91a93a5a31e175f5cbf8c69561e788bbc55ce1","openSSLVersion":"OpenSSL 1.1.1h  22 Sep 2020","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu1804","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-10-25T12:26:27.542+05:30"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"ManjaroLinux","version":"20.1.1"}}}
{"t":{"$date":"2020-10-25T12:26:27.542+05:30"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{}}}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"E",  "c":"STORAGE",  "id":20557,   "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file."}}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"REPL",     "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":10000}}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"COMMAND",  "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"NETWORK",  "id":20562,   "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"NETWORK",  "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"STORAGE",  "id":4784906, "ctx":"initandlisten","msg":"Shutting down the FlowControlTicketholder"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"-",        "id":20520,   "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"NETWORK",  "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"CONTROL",  "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"FTDC",     "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"STORAGE",  "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"STORAGE",  "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"-",        "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}
[omr@auckwell ~]$ ```
</div>
</div>
</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>[omr@auckwell ~]$ mongo
MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
[omr@auckwell ~]$ </code>```

and above result while trying mongo only!

答:
You need to create a folder /data/db

That's what it says in the terminal {"error":"Nonexistent path: data directory /data/db not found. Create the missing directory

You can do this with the command sudo mkdir -p /data/db

Body:
I installed Mongodb From AUR Pacman, I tried reinstalling the Mongo but it didn't work, I also tried Arch Troubleshooting methods but it didn't work either.

I get following when I try sudo mongod

[omr@auckwell ~]$ sudo mongo
[sudo] password for omr:
[omr@auckwell ~]$ sudo mongod
[sudo] password for omr:
{"t":{"$date":"2020-10-25T12:26:27.531+05:30"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-10-25T12:26:27.540+05:30"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-10-25T12:26:27.541+05:30"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2020-10-25T12:26:27.542+05:30"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":18541,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"auckwell"}}
{"t":{"$date":"2020-10-25T12:26:27.542+05:30"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.1","gitVersion":"ad91a93a5a31e175f5cbf8c69561e788bbc55ce1","openSSLVersion":"OpenSSL 1.1.1h  22 Sep 2020","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu1804","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-10-25T12:26:27.542+05:30"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"ManjaroLinux","version":"20.1.1"}}}
{"t":{"$date":"2020-10-25T12:26:27.542+05:30"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{}}}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"E",  "c":"STORAGE",  "id":20557,   "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file."}}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"REPL",     "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":10000}}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"COMMAND",  "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"NETWORK",  "id":20562,   "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"NETWORK",  "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"STORAGE",  "id":4784906, "ctx":"initandlisten","msg":"Shutting down the FlowControlTicketholder"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"-",        "id":20520,   "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"NETWORK",  "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"CONTROL",  "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"FTDC",     "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"STORAGE",  "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"STORAGE",  "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"-",        "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2020-10-25T12:26:27.544+05:30"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}
[omr@auckwell ~]$

[omr@auckwell ~]$ mongo
MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
[omr@auckwell ~]$

and above result while trying mongo only!


问:
jQuery next sibling that has a particular kind of child
My HTML has a container element with many sibling div elements, each of which contains a contenteditable p. These sibling div are "interrupted", however, by other div which do not contain an editable element.

What is challenging me at the moment is how to "hop over" these interrupting div when using the left and right arrow keys to move from C to D or from D back to C (see snippet). Navigation stops when it encounters these div lacking an editable element. How can I correct this?

$('#foo p[contenteditable = "true"]').bind("keydown", function(e) {
  switch (e.key) {
    case "ArrowLeft":
      var $P = $(this).parent().prev().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

    case "ArrowRight":
      var $P = $(this).parent().next().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;
  }
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#foo p[contenteditable="true"] {
  /* font-size: 22px;*/
  height: 22px;
  width: 22px;
  color: cyan;
  font-weight: bold;
  background-color: cyan;
}

#foo p.const {
  background-color: inherit;
  border: none;
  height: 22px;
  width: 22px;
}

#foo div {
  text-align: center;
  display: inline-block;
}</code>```

A

B

C

"

"

D

E

```

答:
Instead of prev() or next(), use .prevAll(":has(p[contenteditable])").first() and .nextAll(":has(p[contenteditable])").first():

$('#foo p[contenteditable = "true"]').bind("keydown", function(e) {

  switch (e.key) {
    case "ArrowLeft":
      var $P = $(this).parent().prevAll(":has(p[contenteditable])").first().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

    case "ArrowRight":
      var $P = $(this).parent().nextAll(":has(p[contenteditable])").first().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

  }

});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#foo p[contenteditable="true"] {
  /* font-size: 22px;*/
  height: 22px;
  width: 22px;
  color: cyan;
  font-weight: bold;
  background-color: cyan;
}

#foo p.const {
  background-color: inherit;
  border: none;
  height: 22px;
  width: 22px;
}

#foo div {
  text-align: center;
  display: inline-block;
}</code>```

A

B

C

"

"

D

E

```
</div>
</div>
</p>
<p><code>prevAll</code>/<code>nextAll</code> match all previous/following siblings that match the selector, returning a jQuery object <em>in order</em> (so the nearest sibling is first, then the second nearest, etc.); using <code>.first()</code> then reduces the set to just the nearest sibling.</p>
<p>I've used the <code>:has</code> pseudo-selector in that, but you might be better off giving the relevant elements a class instead, since <code>:has</code> is a jQuery-specific addition to CSS. Here I've used the class <code>stop</code> so it's <code>.xxxxAll(".stop").first()</code>:</p>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$('#foo p[contenteditable = "true"]').bind("keydown", function(e) {

  switch (e.key) {
    case "ArrowLeft":
      var $P = $(this).parent().prevAll(".stop").first().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

    case "ArrowRight":
      var $P = $(this).parent().nextAll(".stop").first().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

  }

});</code>```

#foo p[contenteditable="true"] {
  /* font-size: 22px;*/
  height: 22px;
  width: 22px;
  color: cyan;
  font-weight: bold;
  background-color: cyan;
}

#foo p.const {
  background-color: inherit;
  border: none;
  height: 22px;
  width: 22px;
}

#foo div {
  text-align: center;
  display: inline-block;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="foo">

  <div class="stop">
    <p contenteditable="true" tabindex="0"></p>
    <p>A</p>
  </div>
  <div class="stop">
    <p contenteditable="true" tabindex="1"></p>
    <p>B</p>
  </div>
  <div class="stop">
    <p contenteditable="true" tabindex="2"></p>
    <p>C</p>
  </div>
  <div>
    <p class="const"> </p>
    <p>
      <p>
  </div>
  <div>
    <p class="const">"</p>
    <p>"
      <p>
  </div>
  <div class="stop">
    <p contenteditable="true" tabindex="3"></p>
    <p>D</p>
  </div>
  <div class="stop">
    <p contenteditable="true" tabindex="4"></p>
    <p>E</p>
  </div>

</div></code>```

Body:
My HTML has a container element with many sibling div elements, each of which contains a contenteditable p. These sibling div are "interrupted", however, by other div which do not contain an editable element.

What is challenging me at the moment is how to "hop over" these interrupting div when using the left and right arrow keys to move from C to D or from D back to C (see snippet). Navigation stops when it encounters these div lacking an editable element. How can I correct this?

$('#foo p[contenteditable = "true"]').bind("keydown", function(e) {
  switch (e.key) {
    case "ArrowLeft":
      var $P = $(this).parent().prev().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

    case "ArrowRight":
      var $P = $(this).parent().next().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;
  }
});

#foo p[contenteditable="true"] {
  /* font-size: 22px;*/
  height: 22px;
  width: 22px;
  color: cyan;
  font-weight: bold;
  background-color: cyan;
}

#foo p.const {
  background-color: inherit;
  border: none;
  height: 22px;
  width: 22px;
}

#foo div {
  text-align: center;
  display: inline-block;
}

A

B

C

"

"

D

E

Body:
Instead of prev() or next(), use .prevAll(":has(p[contenteditable])").first() and .nextAll(":has(p[contenteditable])").first():

$('#foo p[contenteditable = "true"]').bind("keydown", function(e) {

  switch (e.key) {
    case "ArrowLeft":
      var $P = $(this).parent().prevAll(":has(p[contenteditable])").first().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

    case "ArrowRight":
      var $P = $(this).parent().nextAll(":has(p[contenteditable])").first().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

  }

});

#foo p[contenteditable="true"] {
  /* font-size: 22px;*/
  height: 22px;
  width: 22px;
  color: cyan;
  font-weight: bold;
  background-color: cyan;
}

#foo p.const {
  background-color: inherit;
  border: none;
  height: 22px;
  width: 22px;
}

#foo div {
  text-align: center;
  display: inline-block;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="foo">

  <div>
    <p contenteditable="true" tabindex="0"></p>
    <p>A</p>
  </div>
  <div>
    <p contenteditable="true" tabindex="1"></p>
    <p>B</p>
  </div>
  <div>
    <p contenteditable="true" tabindex="2"></p>
    <p>C</p>
  </div>
  <div>
    <p class="const">&nbsp;</p>
    <p>&nbsp;
      <p>
  </div>
  <div>
    <p class="const">"</p>
    <p>"
      <p>
  </div>
  <div>
    <p contenteditable="true" tabindex="3"></p>
    <p>D</p>
  </div>
  <div>
    <p contenteditable="true" tabindex="4"></p>
    <p>E</p>
  </div>

</div>

prevAll/nextAll match all previous/following siblings that match the selector, returning a jQuery object in order (so the nearest sibling is first, then the second nearest, etc.); using .first() then reduces the set to just the nearest sibling.

I've used the :has pseudo-selector in that, but you might be better off giving the relevant elements a class instead, since :has is a jQuery-specific addition to CSS. Here I've used the class stop so it's .xxxxAll(".stop").first():

$('#foo p[contenteditable = "true"]').bind("keydown", function(e) {

  switch (e.key) {
    case "ArrowLeft":
      var $P = $(this).parent().prevAll(".stop").first().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

    case "ArrowRight":
      var $P = $(this).parent().nextAll(".stop").first().children('p[contenteditable = "true"]');
      setTimeout(() => $P.focus(), 0);
      e.stopImmediatePropagation();
      e.preventDefault();
      break;

  }

});

#foo p[contenteditable="true"] {
  /* font-size: 22px;*/
  height: 22px;
  width: 22px;
  color: cyan;
  font-weight: bold;
  background-color: cyan;
}

#foo p.const {
  background-color: inherit;
  border: none;
  height: 22px;
  width: 22px;
}

#foo div {
  text-align: center;
  display: inline-block;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="foo">

  <div class="stop">
    <p contenteditable="true" tabindex="0"></p>
    <p>A</p>
  </div>
  <div class="stop">
    <p contenteditable="true" tabindex="1"></p>
    <p>B</p>
  </div>
  <div class="stop">
    <p contenteditable="true" tabindex="2"></p>
    <p>C</p>
  </div>
  <div>
    <p class="const">&nbsp;</p>
    <p>&nbsp;
      <p>
  </div>
  <div>
    <p class="const">"</p>
    <p>"
      <p>
  </div>
  <div class="stop">
    <p contenteditable="true" tabindex="3"></p>
    <p>D</p>
  </div>
  <div class="stop">
    <p contenteditable="true" tabindex="4"></p>
    <p>E</p>
  </div>

</div>


问:
How to remove Entitlement after refund a test order (in app purchase) in play console
Am testing in-app purchase in my app, i made a test order then while refund it I forgot to check on remove Entitlement box, now am stuck with this in-app purchase

I contact play console support in 11 Aug and they always reply ("we are investigating the issue")

How to remove the Entitlement ?

答:
In Flutter you can use

```<code>import 'package:in_app_purchase_android/billing_client_wrappers.dart';

BillingClient billingClient = BillingClient((wr){});
billingClient.consumeAsync('the_long_purchase_token');
</code>```

Purchase token you can get in billingClient.queryPurchaseHistory or in your Google Play dev console - Order Management - Order Details - Copy Purchase Token.

Body:
In Flutter you can use

import 'package:in_app_purchase_android/billing_client_wrappers.dart';

BillingClient billingClient = BillingClient((wr){});
billingClient.consumeAsync('the_long_purchase_token');

Purchase token you can get in billingClient.queryPurchaseHistory or in your Google Play dev console - Order Management - Order Details - Copy Purchase Token.