Skip to content

Instantly share code, notes, and snippets.

@huacnlee
huacnlee / ghostty-omarchy.config
Created September 15, 2026 02:52
Omarchy style Ghostty config
# Omarchy style config for Ghostty
confirm-close-surface = false
window-save-state = always
theme = Adventure
selection-background = #fafafa
selection-foreground = #1a1a1a
split-divider-color = #404040
unfocused-split-opacity = 0.65
@huacnlee
huacnlee / line_path.rs
Last active November 27, 2024 11:09
GPUI build line path by points
fn build_line_path(points: Vec<Point<Pixels>>, width: f32) -> Path<Pixels> {
let mut path = Path::new(point(points[0].x, points[0].y));
let half_width = width / 2.0;
let angle_threshold: f32 = 15.;
// 4~6 for performance, 8~12 for medium, 16~24 for high quality
const SEGMENT: usize = 0;
let angle_threshold_cos = angle_threshold.to_radians().cos();
for i in 0..points.len() - 1 {
@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