Skip to content

Instantly share code, notes, and snippets.

View huacnlee's full-sized avatar

Jason Lee huacnlee

View GitHub Profile
@huacnlee
huacnlee / gist:25731547eb72c25e44988f76504d1434
Created August 23, 2023 08:21
Go 代码 Aho-Corasick 算法从文本中匹配关键词
package main
import (
"fmt"
"time"
)
type Node struct {
children map[rune]*Node
fail *Node
require('parser')
input = "function foo() {}"
buf = Parser::Source::Buffer.new("test", 1, source: input)
tr = Parser::Source::TreeRewriter::new(buf)
def range(buf, start_pos, end_pos)
Parser::Source::Range::new(buf, start_pos, end_pos)
end
@huacnlee
huacnlee / input.txt
Created October 25, 2022 06:52
Pest grammar example for match nested parn
(hello(world) 你好 (var))
(hello2(world))
{
"recommendations": [
"aeschli.vscode-css-formatter",
"ahmadalli.vscode-nginx-conf",
"aliariff.vscode-erb-beautify",
"be5invis.toml",
"bierner.markdown-preview-github-styles",
"bradlc.vscode-tailwindcss",
"bradymholt.pgformatter",
"crystal-lang-tools.crystal-lang",
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg style="border-radius: 0;" width="324" height="120" viewBox="0 0 324 120" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g>
<defs>
<linearGradient id="avatar" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#ff6a00"/>
<stop offset="100%" stop-color="#ff6a00"/>
</linearGradient>
</defs>
-- 创建名称为readonly的只读用户:
create user social with password '123456';
-- 然后把在public这个schema下现有的所有表的select权限赋给readobly,并执行下面的SQL命令:
grant select on select tables in schema public to social;
-- 上面的命令只是把现有的表的权限给了readonly用户,如果此时创建了表,readonly用户还是不能读,需要使用下面的SQL把所建表的select权限也给用户readonly:
alter default privileges in schema public grant select on tables to social;
@huacnlee
huacnlee / homeland-gobackup.yml
Created February 3, 2020 14:37
Gobackup for Homeland config example
models:
homeland:
compress_with:
type: tgz
encrypt_with:
type: openssl
password: your-archive-password
store_with:
type: oss
bucket: your-backup-bucket-name
@huacnlee
huacnlee / RSpec-to-Minitest.md
Created January 28, 2020 04:46
RSpec to Minitest

RSpec to Minitest

Use Assertions method instead of RSpec expect.

expect to assert_equal

Cases

expect(response.status).to eq 400
@huacnlee
huacnlee / dingtalk-qrcode-login.rb
Last active August 1, 2021 10:12
实现钉钉扫描登录 Ruby
# 实现钉钉扫描登录
#
# 从钉钉 “移动应用接入 - 扫码登录” 开通,并获得 app_id 和 app_secret
# 开通:https://open-dev.dingtalk.com/#/loginMan
#
# 这个流程只能实现简单登录,拿到用户 nick,dingId, openid, unionid
# 文档:https://ding-doc.dingtalk.com/doc#/serverapi2/etaarr
require "openssl"
require "base64"
require "faraday"
.ease-in-out {
-webkit-transform: scale(0.8);
transform: scale(0.8);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}