Skip to content

Instantly share code, notes, and snippets.

@sunwu51
sunwu51 / nginx.conf
Last active June 28, 2024 02:29
openresty配置详解
# 概述:一共三大部分配置。
# 其中#注释掉的可以在需要的时候开启并修改,没有注释掉的(除了下面location示例)不要删掉,基本都是必须的配置项。
###############################第一部分 全局配置############################
#user nobody; 指定启动进程的用户,默认不用指定即可。
#error_log logs/error.log; 配置日志输出,虽然叫error_log但是可以定义输出的级别,默认不写是ERROR级别
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid; 记录pid的文件,默认就是放到这个位置,可以修改。
@sunwu51
sunwu51 / learn.lua
Last active August 16, 2022 10:08
lua learn
-- 直接赋值是全局变量一般不要这么使用
a = 10
-- local是指定当前作用域(一般指大括号或当前文件内)有效的变量
local a = 10
-- 数字
local b = 10.1
print(a + b) -- 打印20.1,支持常见的运算符以及位运算符
print(15 & (1<<2)) -- 4
@limingxinleo
limingxinleo / RPCAspect.php
Created November 12, 2021 11:28
使用 Aspect 记录 RPC 调用日志
<?php
declare(strict_types=1);
use Hyperf\Di\Aop\AbstractAspect;
use Hyperf\Di\Aop\ProceedingJoinPoint;
use Hyperf\RpcClient\ServiceClient;
use Psr\EventDispatcher\EventDispatcherInterface;
class RPCAspect extends AbstractAspect
@themsaid
themsaid / AppServiceProvider.php
Created January 26, 2020 16:24
Re-encryption after APP_KEY rotation
<?php
namespace App\Providers;
use App\Encrypter;
use Illuminate\Support\Str;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@vyspiansky
vyspiansky / image-src-regexpr.php
Last active October 23, 2025 10:29
PHP: get image src attribute (regular expression)
<?php
// Source: http://goo.gl/qyLFbg
$html = '<img border="0" src="/images/image.jpg" alt="Image" width="100" height="100" />';
preg_match( '@src="([^"]+)"@' , $html, $match );
$src = array_pop($match);
// will return /images/image.jpg