指尖上的星空

文章 评论 浏览 34

指尖上的星空 2025-02-20 23:56:43

我想知道的是,每个注册用户如何在个人资料中添加他们的个人信息,只有他们才能被允许删除或更改它,而其他用户只能看到该信息。

您需要的是 firestore安全规则

Firestore规则是一项功能,允许您如刚刚描述的那样在Firestore数据上设置权限。 rules tab位于数据旁边 firestore数据库中的选项卡 firebase Console的部分

在您的情况下,只有给定的签名用户才能管理其数据,并且所有签名的用户都可以查看其他用户的数据;您可以拥有以下Firestore规则:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false;
    }

    match /users/{userId} {
      allow create, update, delete: if request.auth != null && request.auth.uid == userId;
      allow read: if request.auth != null;
    }
  }
}

request.auth!= null 告诉Firebase必须对用户进行身份验证。此外,从Firebase身份验证中将用户文档的 id 设置为 uid 的常见习惯。因此,Firestore规则将允许用户集合上的签名用户匹配 request.auth.uid

因此,考虑到这一点,您可以舒适地用firestore 也读取数据

关于版本的注释

我正在使用firebase版本5.6.0,我感谢您的想法或建议,谢谢你们!

前端JavaScript的Firebase目前在版本9中。我建议您升级到最新版本,原因有两个。

  1. 不确定旧版本的维护。

  2. Firebase引入了使用V9的JavaScript SDK的重大破坏变化。在版本9中,Firebase现在是模块化的,可摇摆的。您必须使用npm安装firebase,并仅使用访问所需的访问。 在此处阅读以获取更多信息

What I would like to know is how every registered user can add their personal information in their profile and only they should be allowed to delete or change it and other users can only see that information.

What you need is Firestore Security Rules.

Firestore Rules is a feature that permits you to set permissions on Firestore data as you have just described. The Rules tab is next to the Data tab in the Firestore Database section of the Firebase Console.

In your case, where only a given signed-in user can manage their data and all signed-in users can view other users' data; you could have the following firestore rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false;
    }

    match /users/{userId} {
      allow create, update, delete: if request.auth != null && request.auth.uid == userId;
      allow read: if request.auth != null;
    }
  }
}

request.auth != null tells Firebase that the user must be authenticated. Also, it is common practice to set the id of a user's document as the uid of the given user from Firebase Authentication. So that, the Firestore rule will allow signed-in users on the users collection to match request.auth.uid.

So with this in mind, you can comfortably manage user data with Firestore and read the data as well.

Note on version

I'm using firebase version 5.6.0, I'll appreciate any idea or advise, thank you guys!

Firebase for front-end JavaScript is currently in version 9. I advise you to upgrade to the latest version for two reasons.

  1. Maintenance of the old versions is not sure.

  2. Firebase introduced a major breaking change in the JavaScript SDK with v9. In version 9, Firebase is now modular and tree-shakeable. You must use npm to install firebase and use access only what you need. Read here for more info.

如何为firebase中的每个注册用户创建和查看不同的信息?

指尖上的星空 2025-02-20 13:38:01

删除 hixontalAlignment =“ Center”

然后, combobox 默认情况下将拉伸以适合单元格的宽度。

Remove HorizontalAlignment="Center".

Then the ComboBox will stretch to fit the width of the cell by default.

WPF DataGridCell中的Combobox全宽度

指尖上的星空 2025-02-19 19:33:35

ASP.NET MVC已经对此进行了处理。将模型作为对操作方法的参数。

例如,创建模型包含您有兴趣接收与JSON字段匹配的属性的数据:

public class MyData {
    public string request_id {get;set;}
}

以及控制器

public class MyController {
    public Result MyActionMethod(MyData myData) {
        // now myData.request_id contains 5nRJwCgt95yfmq9qVPrzei16568823342584
        // you can use it/assign it to whatever you want
        var ReqID = myData.request_id;
    }
}

编辑:

如果您已经将JSON作为字符串作为字符串,则可以将其手动验证为对象,如下所示:

var myData = Newtonsoft.Json.JsonConvert.DeserializeObject<MyData>(json);
// now myData.request_id will be the value you expect.
var ReqID = myData.request_id;

ASP.NET MVC already handles this. Put the model as a param to the action method.

For example, create a model the includes the data you are interested in receiving with properties matching the JSON fields:

public class MyData {
    public string request_id {get;set;}
}

And the controller

public class MyController {
    public Result MyActionMethod(MyData myData) {
        // now myData.request_id contains 5nRJwCgt95yfmq9qVPrzei16568823342584
        // you can use it/assign it to whatever you want
        var ReqID = myData.request_id;
    }
}

Edit:

If you already have the JSON as a string, you can manually deserialize it into an object as follows:

var myData = Newtonsoft.Json.JsonConvert.DeserializeObject<MyData>(json);
// now myData.request_id will be the value you expect.
var ReqID = myData.request_id;

如何在ASP.NET核心控制器中读取JSON值?

指尖上的星空 2025-02-19 13:38:10

从评论中,您对互斥X的看法似乎是它可以保护A 单个代码块,因此没有两个线程可以同时执行它。但这太狭窄了。

MUTEX的真正作用是确保没有两个线程可以同时锁定它。因此,您可以使用同一静音的多个代码“保护”的代码;然后,每当一个线程执行其中一个块时,任何其他线程都无法执行该块或其他任何受保护的块。

这导致了具有保护变量(或一组变量)的静音的成语;意思是,您为自己设置了一个规则,即必须使用MUTEX锁定执行每个变量的每个代码块。

一个简单的示例(未经测试)可能是:

class foo {
public:
    void f1();
    void f2();
private:
    int a, e;
    std::mutex m;
};

void foo::f1() {
    m.lock();
    this->a = b / c;
    if( this->a < d) {
        this->e = 7;
    }
    m.unlock();
}

void foo::f2() {
    m.lock();
    int j = 7 / 2;
    this->a *= j;
    m.unlock();
}

现在其他线程可以安全地执行 f1 f2 的任何组合,而不会导致数据竞争或冒着数据不一致的视图而危险。

实际上,通过使用 std :: scoped_lock 而不是:

void foo::f1() {
    std::scoped_lock sl(m);
    this->a = b / c;
    if( this->a < d) {
        this->e = 7;
    }
}

除其他好处(这将在更复杂的代码中变得相关),它会自动为您解锁您的Mutex。块,因此您不必记住手动进行。

From the comments, it seems your view of a mutex is that it serves to protect a single block of code, so that no two threads can execute it simultaneously. But that is too narrow a view.

What a mutex really does is ensure that no two threads can have it locked simultaneously. So you can have multiple blocks of code "protected" by the same mutex; then, whenever one thread is executing one of those blocks, no other thread can execute that block nor any of the other protected blocks.

This leads to the idiom of having a mutex that protects a variable (or set of variables); meaning, you set a rule for yourself that every block of code accessing those variables must be executed with the mutex locked.

A simple example (untested) could be:

class foo {
public:
    void f1();
    void f2();
private:
    int a, e;
    std::mutex m;
};

void foo::f1() {
    m.lock();
    this->a = b / c;
    if( this->a < d) {
        this->e = 7;
    }
    m.unlock();
}

void foo::f2() {
    m.lock();
    int j = 7 / 2;
    this->a *= j;
    m.unlock();
}

Now other threads can safely execute any combination of f1 and f2 in parallel without causing a data race or risking an inconsistent view of the data.

In practice, take advantage of RAII by using something like std::scoped_lock instead:

void foo::f1() {
    std::scoped_lock sl(m);
    this->a = b / c;
    if( this->a < d) {
        this->e = 7;
    }
}

Among other benefits (that would become relevant in more complex code), it automatically unlocks the mutex for you at the end of the block, so you don't have to remember to do it manually.

C&#x2B;&#x2B;如何制作一系列原子陈述?

指尖上的星空 2025-02-19 12:26:38

您可以在网站root .htaccess中尝试这些规则:

RewriteEngine On

# show /view.php for /view/88 provided .php file exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]+)(?:/|$) $1.php [L]

# rewrite all non-files, non-directories to /index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

You can try these rules in your site root .htaccess:

RewriteEngine On

# show /view.php for /view/88 provided .php file exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]+)(?:/|$) $1.php [L]

# rewrite all non-files, non-directories to /index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

如果找不到LastPart ID /页面,如何显示上一页?

指尖上的星空 2025-02-19 09:59:21

使用 tf.data.dataset.zip 结合功能和标签。

ds_all = tf.data.Dataset.from_tensor_slices(*tf.data.Dataset.zip(
                                               (ds_x.batch(BATCH_SIZE),
                                                ds_y.batch(BATCH_SIZE))
                                            ))

Use tf.data.Dataset.zip to combine features and labels.

ds_all = tf.data.Dataset.from_tensor_slices(*tf.data.Dataset.zip(
                                               (ds_x.batch(BATCH_SIZE),
                                                ds_y.batch(BATCH_SIZE))
                                            ))

结合两个张量流数据集

指尖上的星空 2025-02-19 00:18:52

过去,我在线程中创建PYQT5对象时遇到了问题,而您的一个选项是使用计时器。

class Ui_MainWindow(object):
    def __init__(self):
        self.timer = QtCore.QBasicTimer()
        self.timer.start(250, self)
        self.i = 0
        
    def timerEvent(self, event):
        if self.i < 2500:
            self.i+=1
            top_layout = QtWidgets.QVBoxLayout()
            group_box = QtWidgets.QGroupBox()
            group_box.setTitle('box {0}'.format(i))
            label = QtWidgets.QLabel()
            label.setText('label {0}'.format(i))
            layout = QtWidgets.QHBoxLayout(group_box)
            layout.addWidget(label)
            top_layout.addWidget(group_box)
            self.my_signal.emit(top_layout)
    
    def setupUi(self, MainWindow):
        ...

这样,您将每250msec中断一次主循环以一次更新一个循环迭代,并且您不会冻结GUI。

I've had problems with creating PyQt5 objects in threads in the past, and one option for you would be to use a timer instead.

class Ui_MainWindow(object):
    def __init__(self):
        self.timer = QtCore.QBasicTimer()
        self.timer.start(250, self)
        self.i = 0
        
    def timerEvent(self, event):
        if self.i < 2500:
            self.i+=1
            top_layout = QtWidgets.QVBoxLayout()
            group_box = QtWidgets.QGroupBox()
            group_box.setTitle('box {0}'.format(i))
            label = QtWidgets.QLabel()
            label.setText('label {0}'.format(i))
            layout = QtWidgets.QHBoxLayout(group_box)
            layout.addWidget(label)
            top_layout.addWidget(group_box)
            self.my_signal.emit(top_layout)
    
    def setupUi(self, MainWindow):
        ...

This way you will interrupt the main loop once every 250msec to update one loop iteration at a time and you will not freeze up the GUI.

python螺纹 - 无法设置父,新父在其他线程中

指尖上的星空 2025-02-18 06:40:59

为了改善该查询的性能,您需要先查看执行计划。大多数SQL Server版本都提供提示来创建索引。创建这些已经会导致相当大的加速,尤其是在子征服中。执行计划项目上的数字将告诉您关键路径在哪里:重新安排查询部分,或更改进行昂贵的连接和比较的位置,将加快速度。

valuesyuta ... 表格组需要使用适当的加入语法( innine join )。然后可以从 wend符合他们各自表的联合标准。

此外,还存在完全摆脱子征服的技术,例如,以 cte ,或a 实现的视图

To improve on the performance of that query, you'll want to have a look at the execution plan first. Most SQL server editions offer hints to create indexes. Creating those will already result in a considerable speed-up, in particular in the subqueries. The numbers on the execution plan items will tell you where the critical path is: rearranging parts of the query, or changing the location where expensive joins and comparisons are made, will speed things up.

The valuyuta... group of tables needs to use the proper join syntax (INNER JOIN). The fragments and g.id = g1.id and and g.id = g2.id can then be removed from the WHERE clause and go to the join criteria of their respective table.

Furthermore, techniques exist to get rid of the subqueries altogether, for example pre-computing as a CTE, or a materialized view.

优化SQL查询。我该怎么办?

指尖上的星空 2025-02-17 23:28:09

当您跟踪y时,您没有列出新列表,您指的是与X相同的对象。因此,当您更新x时,y现在指向x

edit的“新”版本 - @s3dev指出,这个答案不是那么精确,列表(x)已经制作了x的副本(新对象);尽管是浅副本。因此,它制作了X的副本,但不是列表Witch的第二个元素是另一个列表。 Y [1]指向X [1]指向的相同对象。

When you assing y you are not making a new list, you are pointing to the same object as x. So when you update x, y is now pointing to the "new" version of x

edit-- @S3DEV pointed out that this answer is is not that precise, list(x) has made a copy (new object) of x; albeit, a shallow copy. So it has made a copy of x, but not the second element of the list witch is an other list. y[1] is pointing to the same object that x[1] is pointing to.

请说明为什么给定的Python代码的输出是[1,[ - 1]而不是[1,[2]]?

指尖上的星空 2025-02-17 19:49:03

我们可以手工做: p 是您的情节:

p +  theme(legend.justification = "center",
        legend.margin = margin(t = 0.2, r = 24.4, b = 0.2, l = 24.4, unit = "cm"))

”在此处输入图像描述”

We could do it by hand: p is your plot:

p +  theme(legend.justification = "center",
        legend.margin = margin(t = 0.2, r = 24.4, b = 0.2, l = 24.4, unit = "cm"))

enter image description here

中心传奇,边缘带有情节面板

指尖上的星空 2025-02-17 17:15:57

首先,您需要将整个内容与()分组,并以/g 结尾,以便与多个组匹配。

如果您要先数字,则需要一个数字,则需要在数字之后放置字母块:([0-9] [A-ZA-Z]))

如果要匹配多个数字,则需要一个+在数字块之后: [0-9]+

一起:/([0-9]+[A-ZA-Z]) /g

供参考, \ d 做与 [0-9] 的事情,因此您可以做/(\ d+[a-- za-z])/g 而不是

lpt:使用 regex101 构建和测试REGEX查询

First, you need to group the whole thing with (), and end with /g so it matches multiple groups.

If you want digits first then a number, you need to put the letter block after the numbers: ([0-9][A-Za-z])

If you want multiple digits to match, you need a + after the numbers block: [0-9]+

All together: /([0-9]+[A-Za-z])/g

For reference, \d does the same thing as [0-9], so you could do /(\d+[A-Za-z])/g instead

LPT: use regex101 to build and test regex queries

Regex-JavaScript无法找到模式

指尖上的星空 2025-02-17 09:45:24

使用以下代码检查,具有特征重要性的属性:

import pandas as pd
import random 
from sklearn.ensemble import AdaBoostRegressor

df = pd.DataFrame({'x1':random.choices(range(0, 100), k=10), 'x2':random.choices(range(0, 100), k=10)})

df['y'] = df['x2'] * .5

X = df[['x1','x2']].values
y = df['y'].values

regr = AdaBoostRegressor(random_state=0, n_estimators=100)
regr.fit(X, y)

regr.feature_importances_

输出:您可以看到功能2更重要,因为Y不过是其中的一半(因为数据是以这种方式创建的)。

Checked with below code, there is an attribute for feature importance:

import pandas as pd
import random 
from sklearn.ensemble import AdaBoostRegressor

df = pd.DataFrame({'x1':random.choices(range(0, 100), k=10), 'x2':random.choices(range(0, 100), k=10)})

df['y'] = df['x2'] * .5

X = df[['x1','x2']].values
y = df['y'].values

regr = AdaBoostRegressor(random_state=0, n_estimators=100)
regr.fit(X, y)

regr.feature_importances_

Output: You can see feature 2 is more important as Y is nothing but half of it (as the data is created in such way).

enter image description here

从Adaboost的线性回归中获得特征的重要性

指尖上的星空 2025-02-17 08:29:28

这似乎是已知的 with pyodbc。在GitHub问题中,作者说:“您没有计算机上所需的ODBC标头文件。”

对于Ubuntu,他建议 sudo apt install unixoDBC-dev ,我认为这也可以在Kali Linux上使用。

This seems to be a known issue with pyodbc. In the github issue, the author says "You don't have the required ODBC header files on your machine."

For Ubuntu, he suggests sudo apt install unixodbc-dev, which I think would also work on Kali Linux.

尝试从Kali Linux中的VSCODE终端安装PYODBC,遇到错误

指尖上的星空 2025-02-16 21:34:18
  • 删除相对布局,使用framelayout

  • 另一个问题是您提供的200 ddp paddingtop到scrollview,即使在滚动视图并引起问题

    时仍保留下来

  • 您可以参考

希望这个答案对您有帮助!

  • Remove Relative layout, use FrameLayout instead

  • Another issue is you are providing 200dp paddingTop to Scrollview which stays even when you scroll the view and cause the issue

  • You can refer to this too!

     <FrameLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         xmlns:tools="http://schemas.android.com/tools"
         android:id="@+id/nestedScrollView"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:orientation="vertical"
         android:background="@color/light_grey"
         tools:context=".fragments.FFSFragment">
         <ImageView
             android:layout_width="match_parent"
             android:layout_height="200dp"
             android:scaleType="fitXY"
             android:src="@drawable/sea_bg" />
         <ScrollView
             android:id="@+id/scroll_view"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:scrollbars="vertical">
    
             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:orientation="vertical">
    
             <TextView
                 android:layout_width="match_parent"
                 android:layout_height="200dp" />
             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:orientation="vertical"
                 android:background="@drawable/rectangle_corners_layout">
    
                 <TextView
                     android:id="@+id/title"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:text="@string/menu_ffs"
                     android:textSize="25sp"
                     android:textColor="@android:color/black"
                     android:layout_marginLeft="20dp"
                     android:layout_marginTop="20dp"/>
                 <TextView
                     android:id="@+id/text_cb"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:text="@string/fill_form"
                     android:textSize="16sp"
                     android:textColor="@android:color/black"
                     android:layout_marginLeft="20dp"
                     android:layout_marginBottom="30dp"/>
                 <EditText
                     android:id="@+id/et_origin"
                     style="@style/AppTheme.EditTexts"
                     android:hint="@string/enter_origin"
    
                     android:background="@drawable/rectangle_corners"/>
                 <EditText
                     android:id="@+id/et_destination"
                     style="@style/AppTheme.EditTexts"
                     android:hint="@string/enter_destination"
                     android:background="@drawable/rectangle_corners"/>
                 <EditText
                     android:id="@+id/et_commodity"
                     style="@style/AppTheme.EditTexts"
                     android:hint="@string/enter_commodity"
                     android:background="@drawable/rectangle_corners"/>
                 <EditText
                     android:id="@+id/et_weight"
                     style="@style/AppTheme.EditTexts"
                     android:hint="@string/enter_weight"
                     android:inputType="number"
                     android:background="@drawable/rectangle_corners"/>
                 <EditText
                     android:id="@+id/et_boxes"
                     style="@style/AppTheme.EditTexts"
                     android:hint="@string/enter_boxes"
                     android:inputType="number"
                     android:background="@drawable/rectangle_corners"/>
                 <EditText
                     android:id="@+id/et_boxe_size"
                     style="@style/AppTheme.EditTexts"
                     android:hint="@string/enter_boxsize"
                     android:background="@drawable/rectangle_corners"/>
                 <Button
                     android:id="@+id/choose_images_btn"
                     style="@style/AppTheme.RoundButtons"
                     android:text="@string/choose_images"/>
                 <Button
                     android:id="@+id/submit_btn"
                     style="@style/AppTheme.RoundButtons"
                     android:layout_marginBottom="20dp"
                     android:text="@string/submit"/>
             </LinearLayout>
             </LinearLayout>
         </ScrollView>
     </FrameLayout>
    

I Hope this answer Helps You!

在固定图像/imageView android上进行滚动浏览

指尖上的星空 2025-02-16 20:33:10

您可以尝试以下几种解决方法:

解决方案1:

  1. 将Visual Studio更新为最新版本。

  2. 消除 web.config

    中的所有绑定重定向

  3. 消除 web.config

     &lt; propertyGroup&gt;
      &lt; autogenateBindingRects&gt; true&lt;/autogenerateBindingRedects&gt; gt; gt; gt;
      &lt; generateBindingReDirectSoutputType&gt; true&lt;/generateBindingRedeRectSoutputType&gt; gt; gt; gt;
    &lt;/propertyGroup&gt;
    
     
  4. 构建项目。

  5. (webappname).dll.config 文件应位于 bin 文件夹中。它应包含重定向;将它们复制到 web.config 文件。

  6. 从文件中删除以前的摘要 .csproj

从文件 .csproj 解决方案2:

尝试添加&lt; usenetCoregenerator&gt; true&gt;/usenetCoregenerator&gt; 。 CSPROJ 文件:

  <PropertyGroup>
    ...
    <UseNETCoreGenerator>true</UseNETCoreGenerator>
  </PropertyGroup>

注意:确保您使用的.NET 6与受支持的软件包版本,如果没有,请尝试更新。

参考:
https://github.com/azure.com/azure/azure/azure-functions--runctions-unctions-unctions-unctions-unctions-unctions-unctions-unctions-unctions-unctions-unctions-unctions-azure-functions- vs-Build-SDK/essess/160

Here are few workarounds that you can try:

Solution 1:

  1. Update the Visual Studio to the most recent version.

  2. Eliminate every binding redirect in web.config

  3. Include the following in the .csproj file:

    <PropertyGroup>
      <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
      <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    </PropertyGroup>
    
    
  4. Build the project.

  5. The (WebAppName).dll.config file should be located in the bin folder. It should contain redirects; copy them to the web.config file.

  6. Delete the previous snippet from the file .csproj

Solution 2:

Try adding <UseNETCoreGenerator>true</UseNETCoreGenerator> to your .csproj file:

  <PropertyGroup>
    ...
    <UseNETCoreGenerator>true</UseNETCoreGenerator>
  </PropertyGroup>

Note: Make sure that you are using .net 6 with there supported package versions ,if not please try to update .

Reference:
https://github.com/Azure/azure-functions-vs-build-sdk/issues/160

尽管在另一种情况下使用完全相同的输入,但AzureBlobStorageContainer fetchattributes()抛出错误

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文