心雨纷扬的博客

一个简单的博客

Deploy in Ubuntu –dev

System Init

阿里云上的ECS

数据盘挂载【按需操作】

1
2
3
4
5
6
7
$ sudo apt update
$ sudo apt upgrade -y
$ sudo apt autoremove
$ sudo fdisk -l
# 执行命令后,如果不存在/dev/vdb,表示您的实例没有数据盘。确认数据盘是否已挂载。
$ sudo fdisk -u /dev/vdb # 执行后输入n开始新分区,后续均可回车使用默认值,最后输入 w 保存

阅读全文 »

vscode 插件列表 推荐

  • auto-close-tag
  • Auto Rename Tag
  • eslint 代码格式校验
  • githistory git工具
  • gitlens 强大的git工具
  • guides 代码指南
  • prettier 代码格式化
  • todo-highlight TODO高亮工具
  • vetur vue感知++
  • vscode intellicode

通用枚举遍历

如果你确认你的枚举类型是 int32,可以使用以下方法

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

/// <summary>
/// 将一个指定的枚举定义(Int)转换成集合对象.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static void ToList<T>() where T:Enum
{
Array datas = Enum.GetValues(typeof(T));

for (var i = 0; i < datas.Length; i++)
{
object value = datas.GetValue(i);
Console.WriteLine("{0,-9} {1}", value + ":",
(int)value);
//需要注意的是这里的强转(int)value ,所以这里需要你事先确认枚举基础类型,如果是byte,此处会抛出异常
}
}

阅读全文 »

C#控制台启动程序或者执行命令

C#启动程序

调用示例

1
StartAConsoleProcess(ygcApiExePath);
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
private static void StartAConsoleProcess(string exePath, params string[] cmdText)
{
Process p = new Process();
p.StartInfo = new ProcessStartInfo(exePath);
p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动

if (exePath.Contains(Path.DirectorySeparatorChar))
{
var file = new FileInfo(exePath);
p.StartInfo.WorkingDirectory = file.Directory.FullName;
}

p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
p.StartInfo.CreateNoWindow = true;//不显示程序窗口
p.OutputDataReceived += YgcApi_OutputDataReceived;
p.ErrorDataReceived += YgcApi_ErrorDataReceived;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
if (cmdText.Length > 0)
{
foreach (var item in cmdText)
{
p.StandardInput.WriteLine(item);
//向cmd窗口发送输入信息
p.StandardInput.AutoFlush = true;
}
}
}
阅读全文 »

windows删除无法访问的文件

现象

通过文件/文件夹的属性的安全选项卡,无法修改所有者和权限

界面上提示:win10 你没有权限查看或编辑这个对象

解决办法

按下 (Windows 徽标键 +X键),点击“命令提示符(管理员)”,复制以下命令并在命令提示符中点击鼠标右键,点击“粘贴”,随后按回车键(Enter)执行:

del /Q '待删除文件路径'

命令完成后重新启动计算机,查看截图3.png是否依然存在,如果存在,再次打开命令提示符(管理员)复制以下命令并粘贴执行:

1
ATTRIB 待删除文件路径>%temp%\pngA.txt & FSUTIL usn readdata 待删除文件路径>>%temp%\pngA.txt & icacls 待删除文件路径>>%temp%\pngA.txt & %temp%\pngA.txt

我试过执行完第一个命令,然后重启电脑就正常了。

参考文档

  • https://answers.microsoft.com/zh-hans/windows/forum/all/win10/52534abd-6c42-41cd-8f8e-14bda4132d4c

Asp.Net WebApi 接入Identity Server4 全记录

当前环境

  1. Net Core 2.2+ //建议使用Net Core 3.0

  2. Asp.Net Framework 4.6.2+

  3. Visual Studio 2019//如果使用Net Core 3.0,你可能需要预览版

    阅读全文 »

使用阿里云ECS在Ubuntu 18.04及OSS安装配置NextCloud

配置启用OssFs

  1. 源码编译安装

    1
    2
    3
    4
    5
    6
    7
    sudo apt install automake autotools-dev g++ git libcurl4-gnutls-dev libfuse-dev libssl-dev libxml2-dev make pkg-config
    git clone https://github.com/aliyun/ossfs.git
    cd ossfs
    ./autogen.sh
    ./configure
    make
    sudo make install
  2. 配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    #密码配置
    echo my-bucket:my-access-key-id:my-access-key-secret > /etc/passwd-ossfs
    #多个节点请直接编辑文件,一行一个记录
    chmod 640 /etc/passwd-ossfs
    #目录准备
    mkdir /mnt/ossfs
    sudo vi /etc/fstab
    ## 添加以下行到文件尾,保存后退出
    # ossfs#your_bucket_name your_mount_point fuse _netdev,url=your_url,allow_other 0 0
    ## your_url http://oss-cn-shenzhen-internal.aliyuncs.com 深圳节点内部访问【节约流量】
    sudo mount -a
    # df -h 可以查看挂载详情
阅读全文 »

Asp.Net MVC接入Identity Server4 全记录

当前环境

  1. Net Core 2.2+ //建议使用Net Core 3.0

  2. Asp.Net Framework 4.6.2+

  3. Visual Studio 2019//如果使用Net Core 3.0,你可能需要预览版

    阅读全文 »

PowerShell设置代理

  • 设置代理
1
netsh winhttp set proxy "127.0.0.1:1080"
  • 恢复默认
1
netsh winhttp reset proxy

注意要在管理员模式运行,不然提示权限不足。

命令行设置代理

  • 设置代理
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#HTTP 代理设置:
set http_proxy=http://127.0.0.1:1080

set https_proxy=http://127.0.0.1:1080
# SOCKS5 代理设置:
set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080

# 如果有用户名密码
set http_proxy_user=user
set http_proxy_pass=pass

set https_proxy_user=user
set https_proxy_pass=pass

# 不走代理的IP
# set NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.99.0/24,192.168.39.0/24


# Ubuntu 下命令为 export
# export http_proxy=http://127.0.0.1:1080
  • 恢复默认
1
2
3
4
# 恢复
set http_proxy=

set https_proxy=