angular 开源案例

GateKeeper is a pretty nifty user registration, authentication and authorization library which uses its own database to store and query the user records. This means that it’s completely decoupled from your main app (so you can, essentially, use Postgre or Mongo for your business logic while using a completely different engine like MySQL for basic user records) and easy to tweak and extend.

GateKeeper是一个非常漂亮的用户注册,身份验证和授权库,它使用自己的数据库来存储和查询用户记录。 这意味着它与您的主应用程序完全脱钩(因此,从本质上讲,您可以将Postgre或Mongo用于您的业务逻辑,而将完全不同的引擎(如MySQL)用于基本用户记录),并且易于调整和扩展。

Open source logo

An example of the library’s use is clearly demonstrated in our post about [the skeleton no-framework project][nowf] which is a sample app composed entirely of Composer packages and acting like a framework-powered app, but completely free of any framework coupling.

我们关于[无框架的骨架项目] [nowf]的帖子中清楚地展示了该库的使用示例,该示例是一个示例应用程序,完全由Composer软件包组成,并且像框架驱动的应用程序一样工作,但是完全没有任何框架耦合。

This post isn’t about Gatekeeper per-se, though. It’s about contributing to open source, and going about the right way to doing it.

不过,这篇文章不是关于Gatekeeper本身的。 这是关于为开源做出贡献,并找到正确的方式来做到这一点。

In this tutorial, we’ll extend GateKeeper with a count feature. Currently, in order to find out the total number of users in the database one would have to fetch them all, then count them – either that or write a query to do so manually. But it might be better if this were built into the adapter interface so that it’s not only a native feature, but also a requirement for future database engines to be added.

在本教程中,我们将使用count功能扩展GateKeeper。 当前,为了找出数据库中的用户总数,必须先提取所有用户,然后对它们进行计数–要么写一个查询,要么手动进行查询。 但是,如果将它内置在适配器接口中可能会更好,这样它不仅是本机功能,而且是将来添加数据库引擎的要求。

第1步:询问所有者 (Step 1: Ask the owner)

The first step of contributing to open source is doing due diligence. This can be as simple as asking the repo owner about the status of this feature, in order to make sure it isn’t planned and is, in fact, desirable. An issue in the repo is often enough, as evident in this case.

为开源做贡献的第一步是尽职调查。 可以简单地向回购所有者询问此功能的状态,以确保它没有计划并且实际上是可取的。 如本例所示 ,回购中的问题通常就足够了。

第2步:叉,克隆,测试 (Step 2: Fork, clone, test)

Note: if you’d like to follow along, please clone an older version of Gatekeeper which doesn’t have this feature yet. This one should do.

注意:如果您想继续,请克隆一个没有此功能的旧版Gatekeeper。 这应该做。

First, let’s fork the repo so we can start working on it.

首先,让我们分叉仓库,以便我们可以开始工作。

Fork button on Github

Next, we need to set up a development environment in which to work on the package. Naturally, we use our trusty Homestead Improved for this. Once the VM has been set up and SSHed into, we can clone our fork, install dependencies and run tests:

接下来,我们需要建立一个开发环境,以在该环境中使用该程序包。 自然,我们为此使用了值得信赖的Homestead改良版 。 设置好虚拟机并通过SSH将其插入后,我们可以克隆fork,安装依赖项并运行测试:

git clone https://github.com/swader/gatekeeper
cd gatekeeper
composer install
vendor/bin/phpunit

All the tests should be green:

所有测试应为绿色:

alt

At this point, it’s preferred to make a separate branch for all the changes we’ll be making.

此时,最好为我们将要进行的所有更改创建一个单独的分支。

git checkout -b "feature-count"

步骤3:行动计划 (Step 3: Plan of Action)

Gatekeeper currently only supports MySQL – this makes our job a bit easier, but still not trivial. Despite only supporting a single type of datasource (for now), abstract and interface classes still need to be updated, seeing as they’re written with future compatibility with different data sources in mind.

Gatekeeper当前仅支持MySQL –这使我们的工作更加轻松,但仍然不简单。 尽管仅支持一种类型的数据源(目前),但是抽象类和接口类仍需要更新,因为它们在编写时考虑到将来与不同数据源的兼容性。

We will, thus, need to modify:

因此,我们将需要修改:

  • Gatekeeper/DataSource – the abstract DataSource class

    Gatekeeper/DataSource –抽象的DataSource类

  • DataSource/MySQL – the MySQL datasource which contains the actual methods we use

    DataSource/MySQL – MySQL数据源,其中包含我们使用的实际方法

  • DataSource/Stub – to upgrade the stub with which to write other datasources, so other contributors know they need a count method, too

    DataSource/Stub –升级用于写入其他数据源的存根,因此其他贡献者也知道它们也需要一个count方法

We also need to create a new Count handler, because Gatekeeper uses magic static calls to create, find, update and delete entities, forwarding them to the appropriate handler depending on the name of the invoked method. For an example, see the __callStatic magic method in Gatekeeper/Gatekeeper.php, and how it defers method calls to handlers like Handler/Create.php or Handler/FindBy.php, etc.

我们还需要创建一个新的Count处理程序,因为Gatekeeper使用魔术静态调用来创建,查找,更新和删除实体,然后根据所调用方法的名称将它们转发到适当的处理程序。 有关示例,请参见Gatekeeper/Gatekeeper.php__callStatic魔术方法,以及如何将方法调用推迟到Handler/Create.phpHandler/FindBy.phpHandler/FindBy.php

步骤4:Just Do It™ (Step 4: Just Do It ™)

委派静态电话 (Delegating the static call)

To prepare the foundation for our custom Count handler, we delegate the static call to it and pass forward the argument and the data source. This is all done by simply adding another elseif block to Gatekeeper::__callStatic:

为了为我们的自定义Count处理程序准备基础,我们将静态调用委派给它,并将参数和数据源传递给它。 只需在Gatekeeper::__callStatic添加另一个elseif块即可完成所有操作:

} elseif ($action == 'count') {
$action = new \Psecio\Gatekeeper\Handler\Count($name, $args, self::$datasource);
}

Since we added a new action, we need to modify the static property $actions as well:

由于添加了新操作,因此我们还需要修改静态属性$actions

/**
* Allowed actions
* @var array
*/
private static $actions = array(
'find', 'delete', 'create', 'save', 'clone', 'count'
);

计数处理程序 (Count handler)

We then create the handler in the file Psecio/Gatekeeper/Handler/Count.php:

然后,我们在文件Psecio/Gatekeeper/Handler/Count.php创建处理程序:

<?php
namespace Psecio\Gatekeeper\Handler;
class Count extends \Psecio\Gatekeeper\Handler
{
/**
* Execute the object/record count handling
*
* @throws \Psecio\Gatekeeper\Exception\ModelNotFoundException If model type is not found
* @return int Count of entities
*/
public function execute()
{
$args = $this->getArguments();
$name = $this->getName();
$model = '\\Psecio\\Gatekeeper\\' . str_replace('count', '',
$name) . 'Model';
if (class_exists($model) === true) {
$instance = new $model($this->getDb());
$count = (!$args) ? $this->getDb()->count($instance) : $this->getDb()->count($instance,
$args[0]);
return (int)$count['count'];
} else {
throw new \Psecio\Gatekeeper\Exception\ModelNotFoundException(
'Model type ' . $model . ' could not be found'
);
}
}
}

It’s almost identical to the Create handler, except for the unreachable return statement at the bottom which I’ve removed, small changes in the body, and a minor alteration to the class’ description.

它与Create处理程序几乎相同,除了我已删除的底部无法访问的return语句,主体上的细微更改以及对类的描述的较小改动之外。

数据源和存根 (DataSource and Stub)

Next, let’s get the easy ones out of the way.

接下来,让我们摆脱那些简单的问题。

In Psecio/Gatekeeper/DataSource/Stub.php, we add a new blank method:

Psecio/Gatekeeper/DataSource/Stub.php ,我们添加了一个新的空白方法:

/**
* Return the number of entities in DB per condition or in general
*
* @param \Modler\Model $model Model instance
* @param array $where
* @return bool Success/fail of action
* @internal param array $where "Where" data to locate record
*/
public function count(\Modler\Model $model, array $where = array()){}

We then add a similar signature to the abstract:

然后,我们向摘要添加类似的签名:

/**
* Return the number of entities in DB per condition or in general
*
* @param \Modler\Model $model Model instance
* @param array $where
* @return bool Success/fail of action
* @internal param array $where "Where" data to locate record
*/
public abstract function count(\Modler\Model $model, array $where = array());

With all this out of the way, it’s time to write the actual logic that takes care of counting.

有了这一切,现在该是编写负责计数的实际逻辑的时候了。

MySQL (MySQL)

It’s time to change DataSource/MySQL.php now. We’ll add the count method right under the find method:

现在该更改DataSource/MySQL.php了。 我们将在find方法下面添加count方法:

/**
* Find count of entities by where conditions.
* All where conditions applied with AND
*
* @param \Modler\Model $model Model instance
* @param array $where Data to use in "where" statement
* @return array Fetched data
*/
public function count(\Modler\Model $model, array $where = array())
{
$properties = $model->getProperties();
list($columns, $bind) = $this->setup($where);
$update = array();
foreach ($bind as $column => $name) {
// See if we keep to transfer it over to a column name
if (array_key_exists($column, $properties)) {
$column = $properties[$column]['column'];
}
$update[] = $column.' = '.$name;
}
$sql = 'select count(*) as `count` from '.$model->getTableName();
if (!empty($update)) {
$sql .= ' where '.implode(' and ', $update);
}
$result = $this->fetch($sql, $where, true);
return $result;
}

Harvesting the logic from the similar find method above, our count method does the following:

从上面类似的find方法中获取逻辑,我们的count方法执行以下操作:

  1. Grab properties as defined in model in question (e.g. see UserModel::$properties)

    抓住相关模型中定义的属性(例如,参见UserModel::$properties )

  2. Separate the values as passed in via $where into columns and their values

    将通过$where传入的值分隔为列及其值

  3. Build the WHERE part of the query by looking into the properties, seeing if any of them have different names to those requested (e.g. requested FirstName has a database counterpart of first_name)

    通过查看properties构建查询的WHERE部分,查看它们是否具有与请求的名称不同的名称(例如,请求的FirstName具有与first_name对应的数据库)

  4. Build whole query

    建立整个查询
  5. Execute with forced single mode on true (see fetch method) because we only expect to get a single value back – an integer indicating the count.

    在强制强制single模式为true下执行(请参阅fetch方法),因为我们只希望返回单个值-表示计数的整数。

  6. Return the count.

    返回计数。

步骤5:测试 (Step 5: Testing)

Ordinarily, there would be a unit testing stage. This is out of the scope of this tutorial, and I encourage you to look at this tutorial instead. If there’s sufficient interest in seeing unit tests developed for this package, we will, of course, accommodate. Let us know in the comments.

通常,会有一个单元测试阶段。 这不在本教程的讨论范围之内,因此我建议您看一下本教程 。 如果有足够的兴趣查看为此程序包开发的单元测试,我们当然会提供。 让我们在评论中知道。

实施实验版 (Implementing the Experimental Version)

Let’s do a manual test. First, we’ll commit and push our work online.

让我们做一个手动测试。 首先,我们将在线提交并推动我们的工作。

git add -A
git commit -m "Adding count feature"
git push origin feature-count

The changes will now be in our fork, online. Then, let’s go ahead and create a brand new project in another folder with the following composer.json file:

现在,这些更改将在线上出现在我们的fork中。 然后,让我们继续使用下面的composer.json文件在另一个文件夹中创建一个全新的项目:

{
"require": {
"psecio/gatekeeper": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/swader/gatekeeper"
}
]
}

Using Composer’s Repositories feature, we can make sure that Composer fetches our copy of Gatekeeper instead of the original, while still thinking it has the original – this allows us to test our changes as if in a real project using Gatekeeper – arguably a more realistic testing scenario than unit tests would be at this point. Save and exit this file, and then run:

使用Composer的存储库功能,我们可以确保Composer可以获取Gatekeeper的副本而不是原始版本,同时仍然认为它具有原始版本–这使我们可以像使用Gatekeeper一样在真实项目中测试我们的更改–可以说是更现实的测试在这种情况下,场景比单元测试要好。 保存并退出此文件,然后运行:

composer require symfony/var-dumper --dev

This will both install the above defined custom package, and Symfony’s VarDumper for easier debugging. You might get asked for a Github token during installation – if that’s the case, just follow the instructions.

这将同时安装上面定义的自定义程序包和Symfony的VarDumper ,以便于调试。 在安装过程中可能会要求您提供Github令牌-如果是这种情况,请按照说明进行操作。

Lo and behold, if we look inside the Gatekeeper main class now, we’ll see that our count updates are all there. Next, let’s follow the typical Gatekeeper installation procedure now by executing vendor/bin/setup.sh and following instructions. If you’re using Homestead Improved, just enter the default values (localhost, homestead, homestead, secret).

瞧,如果我们现在看一下Gatekeeper主类,我们将看到count更新全部存在。 接下来,让我们通过执行vendor/bin/setup.sh并遵循以下说明来遵循典型的Gatekeeper安装过程。 如果您使用的是Homestead Improvement ,则只需输入默认值( localhosthomesteadhomesteadsecret )。

测试中 (Testing)

Now let’s create an index.php file which we’ll use for testing:

现在让我们创建一个index.php文件,我们将使用该文件进行测试:

<?php
require_once 'vendor/autoload.php';
use Psecio\Gatekeeper\Gatekeeper;
Gatekeeper::init('./');
$groups = [
'admin' => 'Administrators',
'users' => 'Regular users'
];
foreach ($groups as $name => $description) {
if (!Gatekeeper::findGroupByName($name)) {
Gatekeeper::createGroup([
'name' => $name,
'description' => $description
]);
}
}

We activate the autoloader, initialize Gatekeeper (it uses the .env file from the root of our folder for credentials), and set up two default groups.

我们激活自动加载器,初始化Gatekeeper(它使用文件夹根目录中的.env文件获取凭据),并设置两个默认组。

Sequel Pro Screenshot of the two groups

Then, let’s go ahead and test counting on the groups:

然后,让我们继续进行测试:

dump(Gatekeeper::countGroup());
dump(Gatekeeper::countGroup(['id' => 1]));

Sure enough, it works.

果然,它可行。

Group count accurate

Let’s test users now.

让我们现在测试用户。

Gatekeeper::countUser();

This accurately produces a count of 0. A common use case for out-of-the-box apps is seeing if there are no users in the database when a user is being created, and then giving that new user Admin privileges. The first user of a system is often considered its owner, so it’s a convenience for setting up super-user accounts. Let’s do that.

这将准确地产生一个为0的计数。开箱即用的应用程序的一个常见用例是,在创建用户时查看数据库中是否没有用户,然后赋予该新用户Admin特权。 系统的第一个用户通常被认为是其所有者,因此设置超级用户帐户很方便。 来做吧。

Gatekeeper::createUser([
'username' => 'bruno-admin',
'first_name' => 'Bruno',
'last_name' => 'Skvorc',
'email' => 'bruno.skvorc@sitepoint.com',
'password' => '12345',
'groups' => (Gatekeeper::countUser()) ? ['users'] : ['admin']
]);
Gatekeeper::createUser([
'username' => 'reg-user',
'first_name' => 'Reggie',
'last_name' => 'User',
'email' => 'reg@example.com',
'password' => '12345',
'groups' => (Gatekeeper::countUser()) ? ['users'] : ['admin']
]);
dump(Gatekeeper::findUserByUsername('bruno-admin')->groups[0]->name);
dump(Gatekeeper::findUserByUsername('reg-user')->groups[0]->name);

Sure enough, the output is accurate – the first group printed on screen is admin, and the second is users.

果然,输出是准确的–屏幕上打印的第一组是admin ,第二组是users

With the count mechanics correctly implemented, it’s time to submit a pull request.

正确实施计数机制后,就可以提交拉取请求了。

提交公关 (Submitting a PR)

First, we go to our own fork of the project. Then, we click the “New Pull Request” button. On the next screen everything should be green – the UI should say “Able to merge”:

首先,我们进入项目的分支。 然后,我们点击“ New Pull Request”按钮。 在下一个屏幕上,所有内容均应为绿色–用户界面应显示“能够合并”:

Able to merge

Once we click the “Create Pull Request” button, we should add a title and a description as detailed as possible, preferably referencing the issue from Step 1 above.

单击“创建请求请求”按钮后,我们应添加尽可能详细的标题和描述,最好参考上述第1步中的问题。

Creating the PR

That’s it – pressing the “Create Pull Request” button wraps things up – all we can do now is wait for feedback from the project owner.

就是这样–按下“创建请求请求”按钮即可完成一切–我们现在所能做的就是等待项目所有者的反馈。

结论 (Conclusion)

This was a case study of contributing to a relatively popular PHP package. I hope it was useful as a learning material and a basic guide into giving back and the process of adding features into something you use.

这是为一个相对流行PHP软件包做出贡献的案例研究。 我希望它可以作为学习材料和对使用中的功能进行回馈和添加功能的基本指南。

It’s important to note that while this is a common process, as I mentioned before, it’s rather uncommon in that it had no unit tests. However, the original library doesn’t test the handlers either, and making a mocking framework for the handlers and the data they can interact with would be too out of scope for this particular post. Again, if you’re curious about that process and would like us to cover it in depth, please do let us know in the comments below that like button.

重要的是要注意,尽管这是一个常见的过程,正如我之前提到的,但由于它没有任何单元测试,因此相当不常见。 但是,原始库也不会测试处理程序,并且为处理程序及其可与之交互的数据创建模拟框架对于此特定文章来说也超出了范围。 同样,如果您对此过程感到好奇,并希望我们深入介绍它,请在“喜欢”按钮下面的评论中告知我们。

It should also be noted that while this was a very easy feature upgrade, sometimes things don’t go according to plan and the changes won’t work immediately in the new project where they’re being tested. In that case, changes can, for example, be made in the vendor folder of the test project until everything works, copied over to the development project, pushed online and then re-installed into the test project to make sure everything still works.

还应该注意的是,尽管这是一个非常容易的功能升级,但有时事情并没有按计划进行,并且所做的更改不会立即在正在测试中的新项目中起作用。 在这种情况下,例如,可以在测试项目的vendor文件夹中进行更改,直到一切正常,将其复制到开发项目,联机,然后重新安装到测试项目中以确保一切仍然正常。

Have your own contribution stories to share? Let us know – we’d love to explore them!

有您自己的贡献故事可以分享吗? 让我们知道–我们很乐意探索它们!

翻译自: https://www.sitepoint.com/contributing-to-open-source-gatekeeper-case-study/

angular 开源案例

查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. 为什么明星割双眼皮没有疤痕

    ...

    2024/4/25 12:15:19
  2. angular的响应式表单

    响应式表单:ts代码中要引入ReactiveFormsModule。 响应式表单涉及到的类&#xff0c;命令。 其中类有三个&#xff0c;这三个类跟后面五个指令是呼应的&#xff0c;响应式表单的原理就是根据模板要显示的内容在ts代码中构建好代码模型&#xff0c;代码模型的构建就是运用这三个…...

    2024/4/21 6:59:56
  3. 代码在线运行网站

    综合各代码在线运行https://c.runoob.com/compilehttp://www.dooccn.com/ http://code.y444.cnPython反编译https://tool.lu/pyc/PHP在线运行https://c.runoob.com/compile/1http://www.dooccn.com/php7/ https://c.runoob.com/compile/6 Python在线运行 Python3在线运行 https…...

    2024/4/21 16:16:39
  4. 不手术想让双眼皮加宽

    ...

    2024/4/21 6:59:53
  5. 割的双眼皮会不自然吗

    ...

    2024/5/9 4:06:16
  6. 做的双眼皮能保持多久

    ...

    2024/5/3 14:10:00
  7. 割双眼皮没拆线前总流眼泪

    ...

    2024/4/20 18:57:47
  8. 不整容怎么变鲁豫割整容 整成双眼皮 多少钱

    ...

    2024/4/20 18:57:46
  9. 9mm 星辰医院做双眼皮会影响运气

    ...

    2024/4/20 18:57:45
  10. Angular的问题【学习angular的,建议看看】

    https://github.com/xufei/blog/issues/15 【文章评论更赞&#xff0c;建议多看多了解】 在过去半年里&#xff0c;我跟一些潜在客户进行了交谈&#xff0c;他们在寻找前端顾问来帮助开发团队控制Angular项目的时候&#xff0c;遇到了麻烦。 尽管有一些对Angular很热情的前端人…...

    2024/4/21 6:59:54
  11. 客户端JavaScript安全性的重要性

    本文由JScrambler提供。 感谢您支持使SitePoint成为可能的合作伙伴。 如今看来&#xff0c;无论看上去在哪里&#xff0c;都注定会看到至少部分使用JavaScript创建的内容 。 原因之一是JavaScript非常易于学习和使用。 另一个原因与易合并的开源库&#xff08;如jQuery &#x…...

    2024/4/21 13:24:48
  12. 前端的发展

    前端的发展 一、概述 Vue (读音 /vjuː/&#xff0c;类似于 view) 是一套用于构建用户界面的渐进式JavaScript框架&#xff0c;发布于2014年2月。与其它大型框架不同的是&#xff0c;Vue 被设计为可以自底向上逐层应用。Vue 的核心库只关注视图层&#xff0c;方便与第三方库&…...

    2024/4/21 6:59:50
  13. 爱思特双眼皮很垃圾

    ...

    2024/5/3 6:42:17
  14. JS+库+框架+工具

    JS库框架工具 要做WEB前端&#xff0c;就需要知道前端到底是什么&#xff0c;需要学习那些知识&#xff1b;前端至少要懂的三个部分&#xff1a;HTML&#xff0c;CSS&#xff0c;JavaScript&#xff08;简称JS&#xff09;&#xff0c;那首先先明确这三个概念&#xff1a; HTML…...

    2024/4/21 6:59:48
  15. javascript功能插件大集合 前端常用插件 js常用插件

    包管理器 管理着 JavaScript 库&#xff0c;并提供读取和打包它们的工具。 npm&#xff1a;npm 是 JavaScript 的包管理器。官网 Bower&#xff1a;一个 web 应用的包管理器。官网 component&#xff1a;能构建更好 web 应用的客户端包管理器。官网 spm&#xff1a;全新的静态包…...

    2024/5/8 5:29:38
  16. 记录一些js框架用途

    accounting.min.js 货币格式化alertify.min.js 提示信息库amd.loader.js 按需动态加载js文件angular-cookies.js 处理cookieangular-file-upload.jsangular-material.min.jsanimate.min.css css3动画async.js 异步工具behave.js 编辑器&#xff0c;使textarea具有IDE编辑能力bj…...

    2024/5/1 0:24:07
  17. 去双眼皮疤痕的药

    ...

    2024/5/1 3:31:16
  18. Vue.js构建用户界面的渐进式框架(前端学习笔记1.0)

    文章目录前言一、Vue是什么&#xff1f;二、前端核心分析1.1.概述1.2.前端三要素1.3.结构层&#xff08;HTML&#xff09;1.4.表现层&#xff08;CSS&#xff09;1.5.行为层&#xff08;JavaScript&#xff09;二、前端发展史2.1.UI框架2.2.JavaScript构建工具2.3.三端同一2.4.…...

    2024/5/1 4:36:14
  19. Angular企业级开发(1)-AngularJS简介

    AngularJS介绍 AngularJS是一个功能完善的JavaScript前端框架&#xff0c;同时是基于MVC(Model-View-Controller理念的框架&#xff0c;使用它能够高效的开发桌面web app和移动端应用。AngularJS由Google公司开发而且开源出来&#xff0c;给所有开发者使用。前端基于Bootstrap…...

    2024/5/1 0:07:44
  20. js前端

    a.前端常见的模式&#xff1a; 1:外观模式;2:代理模式;3:工厂模式;4:单例模式;5:策略模式&#xff1b;6:迭代器模式&#xff1b;7:观察者模式&#xff1b;8:中介者模式;9:访问者模式 b.前端常见的布局&#xff1a; 1.定位布局&#xff0c;2.浮动布局&#xff0c;3.圣杯布局&…...

    2024/4/30 20:50:58

最新文章

  1. 基于Spring Boot的酒店管理系统设计与实现

    基于Spring Boot的酒店管理系统设计与实现 开发语言&#xff1a;Java 框架&#xff1a;springboot JDK版本&#xff1a;JDK1.8 数据库工具&#xff1a;Navicat11 开发软件&#xff1a;eclipse/myeclipse/idea 系统部分展示 系统首页界面图&#xff0c;在系统首页可以查看首页…...

    2024/5/10 5:09:05
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/5/9 21:23:04
  3. mac安装nvm

    一、前景提示 1、保证自己的mac电脑上没安装node环境 2、保证自己的电脑上有安装git&#xff0c;不然下载nvm时会报错。git下载可以参考&#xff1a; 1&#xff09;佛系安装&#xff1a;通过提示下载 XCode 2&#xff09;brem安装 3&#xff09;终极大法&#xff1a;git官网下…...

    2024/5/7 23:35:01
  4. yolov9直接调用zed相机实现三维测距(python)

    yolov9直接调用zed相机实现三维测距&#xff08;python&#xff09; 1. 相关配置2. 相关代码2.1 相机设置2.2 测距模块2.2 实验结果 相关链接 此项目直接调用zed相机实现三维测距&#xff0c;无需标定&#xff0c;相关内容如下&#xff1a; 1. yolov4直接调用zed相机实现三维测…...

    2024/5/9 17:21:28
  5. 在 Visual Studio Code (VSCode) 中隐藏以 . 开头的文件

    打开VSCode。 按下Ctrl ,快捷键打开设置。您也可以点击屏幕左下角的齿轮图标&#xff0c;然后选择“Settings”。 在设置搜索框中&#xff0c;键入files.exclude。 在找到的Files: Exclude项中&#xff0c;点击Add Pattern按钮来添加一个新的模式&#xff0c;或者直接在搜索…...

    2024/5/9 14:31:05
  6. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/5/8 6:01:22
  7. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/5/9 15:10:32
  8. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/5/4 23:54:56
  9. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/5/9 4:20:59
  10. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/5/4 23:54:56
  11. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/5/4 23:55:05
  12. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/5/4 23:54:56
  13. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/5/7 11:36:39
  14. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/5/4 23:54:56
  15. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/5/6 1:40:42
  16. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/5/4 23:54:56
  17. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/5/8 20:48:49
  18. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/5/7 9:26:26
  19. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/5/4 23:54:56
  20. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/5/8 19:33:07
  21. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/5/5 8:13:33
  22. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/5/8 20:38:49
  23. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/5/4 23:54:58
  24. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/5/9 7:32:17
  25. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/5/9 17:11:10
  26. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  27. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  28. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  29. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  30. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  31. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  32. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  33. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  34. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  35. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  36. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  37. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  38. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  39. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  40. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  41. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  42. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  43. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  44. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  45. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57