一些SQL语句记录

update point_main as tc right join (
	select ta.SN,tb.*, concat('M5',lpad(ta.SN*10,3,'0')) as C1, concat('M1',lpad(ta.SN*10,3,'0')) as C2 
	from ( SELECT  row_number() over (order by id) as SN,id from point_main  WHERE `point_ip` = '127.0.0.1:10502'	) as ta 
	left join point_main as tb on ta.id = tb.id
 ) as td on td.id = tc.id
 set tc.point_pos = td.C1,	tc.point_switch=td.C2, tc.point_title  = concat('南面',td.C1)

 

GoLang-Proxy

# 1. 七牛 CDN go env -w GOPROXY=https://goproxy.cn,direct 
# 2. 阿里云 go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct 
# 3. 官方 go env -w GOPROXY=https://goproxy.io,direct
export PATH=$PATH:/usr/local/go/bin

GoLang-Install

https://golang.google.cn/doc/install

更因为 Go 1.13 将 `GOPROXY默认成了中国大陆无法访问的 https://proxy.golang.org ,所以我们中国的开发者从今以后必须先修改 `GOPROXY` 才能正常使用 `go` 来开发应用了。 为此, 我们联合中国备受信赖的云服务提供商七牛云专门为咱们中国开发者而打造了一个 Go 模块代理:goproxy.cn

命令作用
go mod download下载依赖包到本地(默认为 GOPATH/pkg/mod 目录)
go mod edit编辑 go.mod 文件
go mod graph打印模块依赖图
go mod init初始化当前文件夹,创建 go.mod 文件
go mod tidy增加缺少的包,删除无用的包
go mod vendor将依赖复制到 vendor 目录下
go mod verify校验依赖
go mod why解释为什么需要依赖

# 参考
# Go 1.13 相比 Go 1.12 有哪些值得注意的改动?
# https://go.dev/doc/go1.13
# https://www.cnblogs.com/piperliu/p/18843567

注册表修复-Windows.VhdFile

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Windows.VhdFile]
@="Disc Image File"
"FriendlyTypeName"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,\
  00,6f,00,6f,00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,\
  32,00,5c,00,73,00,68,00,65,00,6c,00,6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,\
  00,2c,00,2d,00,33,00,31,00,34,00,37,00,35,00,00,00

[HKEY_CLASSES_ROOT\Windows.VhdFile\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,69,00,6d,00,\
  61,00,67,00,65,00,72,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,33,\
  00,32,00,00,00

[HKEY_CLASSES_ROOT\Windows.VhdFile\shell]

[HKEY_CLASSES_ROOT\Windows.VhdFile\shell\mount]
"CommandStateSync"=""
"ExplorerCommandHandler"="{9ab3b1c9-3225-4bb4-93b6-bfb3c0d93743}"
"HasLUAShield"="true"
"MultiSelectModel"="Document"

[HKEY_CLASSES_ROOT\Windows.VhdFile\shell\mount\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
  00,5c,00,45,00,78,00,70,00,6c,00,6f,00,72,00,65,00,72,00,2e,00,65,00,78,00,\
  65,00,00,00
"DelegateExecute"="{9ab3b1c9-3225-4bb4-93b6-bfb3c0d93743}"

[HKEY_CLASSES_ROOT\Windows.VhdFile\tabsets]
"selection"=dword:00000704

[HKEY_CLASSES_ROOT\.vhd]
@="Windows.VhdFile"


[HKEY_CLASSES_ROOT\.vhdx]
@="Windows.VhdFile"

 

openssl自建CA并生成自签名SSL证书

#创建CA私钥文件:
openssl genrsa -des3 -out ca-secure.key 2048
#输入密码:
Enter PEM pass phrase:123456
#再次输入密码:
Verifying - Enter PEM pass phrase:123456
#密码证书转无密码(此步按需,比如配置到Apache或者Nginx中时不必每次启动时输入密码)
openssl rsa -in ca-secure.key -out ca.key
#输入上述密码:
Enter pass phrase for ca-secure.key:123456
#查看私钥内容:
openssl rsa -text -in ca-secure.key
#输入密码:
Enter pass phrase for server.key:123456
#生成CA自签名证书
openssl req -new -x509 -days 3650 -key ca.key -subj "/C=CN/ST=BJ/L=BJ/O=MyRootCA/OU=MyCA/CN=CA" -out ca.crt
#生成服务器私钥和证书申请文件CRS(此处CN代表web服务器主机名或IP地址)
openssl req -newkey rsa:2048 -nodes -keyout server.key -subj "/C=CN/ST=BJ/L=BJ/O=MyRootServer/OU=MyServer/CN=192.168.69.78" -out server.csr
#使用CA证书签名SSL证书,此处`-extfile <(printf "subjectAltName=IP:10.10.49.172[,DNS:,...]")`:扩展用于指定主体的备用名称
openssl x509 -req -extfile <(printf "subjectAltName=IP:192.168.69.78") -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt
#查看证书内容
openssl x509 -text -noout -in server.crt

 

参考
不废话之使用openssl自建CA并生成自签名SSL证书
https://zhuanlan.zhihu.com/p/6358873266

lumen-bing-wallpaper

// # config/filesystems.php
return [
    'default' => env('FILESYSTEM_DRIVER', 'local'),
    'cloud' => env('FILESYSTEM_CLOUD', 's3'),
    /*
    |--------------------------------------------------------------------------
    | Filesystem Disks
    |--------------------------------------------------------------------------
    |
    | Here you may configure as many filesystem "disks" as you wish, and you
    | may even configure multiple disks of the same driver. Defaults have
    | been setup for each driver as an example of the required options.
    |
    | Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace"
    |
    */

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path(''),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
        ],

    ],

];

#参考withFacades 错误原因,Facades\Event 名称命名冲突
#https://blog.csdn.net/u013372487/article/details/107004972

# bootstrap/app.php 
$Facades_Alias_Defaults = [
\Illuminate\Support\Facades\Auth::class => 'Auth',
\Illuminate\Support\Facades\Cache::class => 'Cache',
\Illuminate\Support\Facades\DB::class => 'DB',
\Illuminate\Support\Facades\Event::class => 'LumenEvent',
\Illuminate\Support\Facades\Gate::class => 'Gate',
\Illuminate\Support\Facades\Log::class => 'Log',
\Illuminate\Support\Facades\Queue::class => 'Queue',
\Illuminate\Support\Facades\Route::class => 'Route',
\Illuminate\Support\Facades\Schema::class => 'Schema',
\Illuminate\Support\Facades\Storage::class => 'Storage',
\Illuminate\Support\Facades\URL::class => 'URL',
\Illuminate\Support\Facades\Validator::class => 'Validator',
];

// $app->withFacades();
// $app->withFacades(true, [    \Illuminate\Support\Facades\Event::class => 'LumenEvent', ]);
$app->withFacades(true, $Facades_Alias_Defaults );
$app->withEloquent(); 
$app->configure('filesystems'); 
$app->register(Illuminate\Filesystem\FilesystemServiceProvider::class); 
$app->register(App\Providers\AppServiceProvider::class);

 

# bootstrap/app.php 
$app->withFacades();
$app->withEloquent();
$app->configure('filesystems');
$app->register(Illuminate\Filesystem\FilesystemServiceProvider::class);
$app->register(App\Providers\AppServiceProvider::class);

// 在route/web.php 中添加 
// use App\Http\Controllers\BingController;
$router->get('/bing',  'BingController@bing');
$router->get('/{id}',  'BingController@index');
// # app/Http/Controllers/BingController.php
// #
namespace App\Http\Controllers;

use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Log;

// $directory = 'your_directory_path';
// try {
//     $result = Storage::disk('local')->makeDirectory($directory);
//     if (!$result) {
//         Log::error("Failed to create directory: $directory");
//     }
// } catch (\Exception $e) {
//     Log::error("Error creating directory: " . $e->getMessage());
// }


class BingController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }
    //
    public function index($id)
    {
        return "这是控制器Bing的 index 方法,ID 为: $id";
    }

    public function bing()
    { 
        // $localFilePath = __DIR__ . '/../storage/app/bing_wallpaper.jpg';
        $bing_wallpaper_dir_path = 'app/'.DATE("Ym").'/';
        // $bing_wallpaper_dir_path = 'app/';
        $bing_wallpaper_filename = date("Ymd").'.jpg';
        
        $localFilePath = storage_path($bing_wallpaper_dir_path.$bing_wallpaper_filename );
        // use Illuminate\Support\Facades\Storage;
        // $content = Storage::disk('local')->get('your_file.txt');
        // echo $content;
        
        if (file_exists($localFilePath)) {
            $image = file_get_contents($localFilePath);
            header('localFilePath: '. $localFilePath);
            header('Content-Type: image/jpeg');
            echo $image;
            return;
        } 
        // 检查目录是否存在,如果不存在则创建
        if (!Storage::disk('local')->exists($bing_wallpaper_dir_path)) {
            Storage::disk('local')->makeDirectory($bing_wallpaper_dir_path,null,true);
        }

        $directory = $bing_wallpaper_dir_path;
        try {
            $result = Storage::disk('local')->makeDirectory($directory,null,true );
            if (!$result) {
                Log::error("Failed to create directory: $directory");
            }
        } catch (\Exception $e) {
            Log::error("Error creating directory: " . $e->getMessage());
        }

        // 下载并保存图片
        $bingApiUrl = 'https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1';
        $response = file_get_contents($bingApiUrl);
        $data = json_decode($response, true);

        if ($data && isset($data['images'][0]['url'])) {
            $imageUrl = 'https://www.bing.com' . $data['images'][0]['url'];
            $imageData = file_get_contents($imageUrl);

            if ($imageData) {
                file_put_contents($localFilePath, $imageData);
                header('Content-Type: image/jpeg');
                echo $imageData;
            } else {
                return response()->json(['error' => 'Failed to download image'], 500);
            }
        } else {
            return response()->json(['error' => 'Failed to get Bing wallpaper URL'], 500);
        }
    }

}