void *p = (void *)rand();
post @ 2020-12-29
1
composer require tymon/jwt-auth ^1.0.0-rc.2
  1. 复制vender/laravel/lumen-framework/config/auth.php到/config/auth.php
  2. app.php 启动服务注册之类的
1
2
3
4
5
6
7
8
9
10

$app->withFacades();
$app->withEloquent();
$app->routeMiddleware([
'auth' => App\Http\Middleware\Authenticate::class,
]);

$app->register(App\Providers\AppServiceProvider::class);
$app->register(App\Providers\AuthServiceProvider::class);
$app->register(Tymon\JWTAuth\Providers\LumenServiceProvider::class);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

return [
'defaults' => [
'guard' => 'api',
],

'guards' => [
'api' => ['driver' => 'jwt','provider' => 'admins'],
],

'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => \App\Models\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => \App\Models\Admin::class,
],
],

'passwords' => [
//
],

];
  1. 修改 ‘app/Providers’ 文件夹下的 ‘AuthServiceProvider.php’ 如下所示:

    1
    2
    3
    4
    5
    6
    7
    8
    public function boot()
    {
    // 当使用auth中间件的api门卫的时候验证请求体
    $this->app['auth']->viaRequest('api', function ($request)
    {
    return app('auth')->setRequest($request)->user();
    });
    }
  2. 模型下增加

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    use Tymon\JWTAuth\Contracts\JWTSubject;
    class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
    public function getJWTIdentifier()
    {
    return $this->getKey();
    }

    /**
    * JWT
    *
    * @author AdamTyn
    */
    public function getJWTCustomClaims()
    {
    return [];
    }
  3. $token = Auth::login($user) //这样就获取到token了
    header :\
    Authorization : “Bearer “ + token

阅读此文
  • 不要运行大任务! 不然会后悔的! win10 subsystem for ubuntu 16.04!
    1
    2
    3
    4
    5
    6
    7
    8
    wsl -l --all  -v   //首先查看所有分发版本
    * Ubuntu-20.04 Running 1

    wsl --export Ubuntu-20.04 d:\ubuntu20.04.tar //导出分发版为tar文件到d盘
    wsl --unregister Ubuntu-20.04 //注销当前分发版
    wsl --import Ubuntu-20.04 d:\ubuntu d:\ubuntu20.04.tar --version 1 //重新导入并安装分发版在d:\ubuntu
    ubuntu2004 config --default-user Username //设置默认登陆用户为安装时用户名
    del d:\ubuntu20.04.tar //删除tar文件(可选)
阅读此文
post @ 2019-06-09
1
2
3
4
5
composer create-project laravel/laravel blog 5.5.* --prefer-dist		//5.5.*是LTS版本
composer require laravelcollective/html=5.5.* //Form支持
composer require barryvdh/laravel-ide-helper //ida 支持
php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config //导出配置
php artisan ide-helper:generate
1
2
Collective\Html\HtmlServiceProvider::class,
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
1
'From' => Illuminate\Support\Facades\Facade::class,
1
2
config/ide-helper.php:
'include_fluent' => true,
阅读此文
post @ 2018-12-24

vs2017 github 添加项目文件时忽略指定文件。

各种坑。
vs2017集成了与github
点几下就可以把项目丢到github 比较方便
添加项目文件时想排除一些关键的 比如数据库连接阿 什么的 可是他不管你。
笨办法;文件移动目录外
.gitignore文件添加你需要忽略的文件就好了

1
2
3
4
5
6
*.a       # 忽略所有 .a 结尾的文件
!lib.a # 但 lib.a 除外
/TODO # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO
build/ # 忽略 build/ 目录下的所有文件
doc/*.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt
test.txt
阅读此文

WIN10 + vmware + WIN10_guest kdnet调试环境设置

官方介绍:

拷贝后运行得知:

1
2
3
4
Failed to parse the busparams:PCI  11 0 0
Network debugging is not supported on any of the NICs in this machine.
KDNET supports NICs from Intel, Broadcom, Realtek, Atheros, Emulex, Mellanox
and Cisco.

so:

1
2
bcdedit /debug on
bcdedit /dbgsettings net hostip:192.168.0.xxx port:65535

Microsoft Store -> Search -> Windbg PreView

Attach to kernel

net

port 65535 key = xxxxxx(上面cmd会给你的)

Target = guest ip

reboot guest

阅读此文
post @ 2018-10-07

js嵌套razor语法 例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<script>
$(function () {
@{
var islogin = this.Html.ViewContext.HttpContext.Session.GetString("Manage");
if (islogin == null)
{
<text>
{
view.gohome();
}
</text>
}
}
});

</script>

页面生成如下:

1
2
3
4
5
6
7
8
9
<script>
$(function () {

{
view.gohome();
}
});

</script>

session使用:
nuget: Microsoft.AspNetCore.Session

1
2
3
4
5
6
7
8
9
10
11
12
this.HttpContext.Session
public static void Set<T>(ISession session, string key, T value)
{
session.SetString(key, JsonConvert.SerializeObject(value));
}

public static T Get<T>(ISession session, string key)
{
var value = session.GetString(key);
return value == null ? default(T) :
JsonConvert.DeserializeObject<T>(value);
}

建议不要使用asp.net core mvc了
测试
只是个登陆页面 什么操作都没有 so 还是少用吧

阅读此文
post @ 2018-10-07
  • 不要运行大任务! 不然会后悔的! win10 subsystem for ubuntu 16.04!
阅读此文
post @ 2018-10-05

记录下,不用每次去查

1
2
3
4
5
6
7
8
9
10
11
12
13
sudo apt install mysql-server
sudo netstat -tap | grep mysql
mysql_secure_installation //~mysql/bin/mysql_secure_installation
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf //bind-address

mysql-u root -p
CREATE USER 'username'@'%' IDENTIFIED BY 'passwd';//创建一个用户 可以远程访问
CREATE DATABASE mydb; //创建mydb这个库
GRANT SELECT, INSERT ON mydb.* TO 'username'@'%';
flush privileges;


sudo service mysql restart

阅读此文

Jexus官方介绍 jexus
为了方便:
直接安装jexus独立版 for ubuntu

1
sudo curl https://jexus.org/release/x64/install.sh|sudo sh

配置就不需要了调试环境:

1
2
cd /usr/jexus/siteconf
vim demo

1
2
3
4
port = 8080 //端口
hosts = * //没有域名 可看官方介绍
root = /home/ubuntu/8080root //www目录
indexs = index.html
1
2
cd ..
sudo ./jws restart

上面就配置好了
打开vs (ver = 2017)
发布
上传至www目录下
访问即可

阅读此文
post @ 2018-09-25

微软官方安装方法

1
2
3
4
5
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install aspnetcore-runtime-2.1
后发现:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

root@DESKTOP-ME54PJV:/home/xxoo# sudo apt-get install aspnetcore-runtime-2.1
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
dotnet-sdk-2.1 : Depends: dotnet-runtime-2.1 (>= 2.1.4) but it is not going to be installed
Depends: aspnetcore-runtime-2.1 (>= 2.1.4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
  • 解决方法:
    1
    2
    apt install aptitude
    aptitude install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
root@DESKTOP-ME54PJV:/home/xxoo# sudo apt-get install aspnetcore-runtime-2.1
The following NEW packages will be installed:
aspnetcore-runtime-2.1{a} dotnet-host{a} dotnet-hostfxr-2.1{a} dotnet-runtime-2.1{a} dotnet-runtime-deps-2.1{ab} dotnet-sdk-2.1
0 packages upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 132 MB of archives. After unpacking 380 MB will be used.
The following packages have unmet dependencies:
dotnet-runtime-deps-2.1 : Depends: libicu55 which is a virtual package and is not provided by any available package

The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) aspnetcore-runtime-2.1 [Not Installed]
2) dotnet-runtime-2.1 [Not Installed]
3) dotnet-runtime-deps-2.1 [Not Installed]
4) dotnet-sdk-2.1 [Not Installed]



Accept this solution? [Y/n/q/?] Y
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

libicu55 没有源可以提供
/etc/apt/sources.list中加入
deb http://security.ubuntu.com/ubuntu xenial-security main

apt update
apt install aspnetcore-runtime-2.1
即可
root@DESKTOP-ME54PJV:/home/xxoo# dotnet --version
2.1.402
阅读此文
⬆︎TOP