Skip to content

Instantly share code, notes, and snippets.

View haolian9's full-sized avatar
🐢
make it work, make it right

高浩亮 haolian9

🐢
make it work, make it right
View GitHub Profile
@haolian9
haolian9 / asyncrun.lua
Last active February 22, 2022 12:26
a wrapper of asyncrun that respects modeline-like setting in file
-- inlinecmd
-- b:asyncrun_plaincmd
local M = {}
local inlinecmd_magic = "# asyncrun: "
local plaincmd_varname = "asyncrun_plaincmd"
local find_inlinecmd = function(bufnr)
local _reversed_lines = function(high)
@haolian9
haolian9 / xclip
Created March 8, 2022 16:01
xsel wrapper of xclip for [pass](https://www.passwordstore.org)
#!/usr/bin/env python3
import os
import sys
def as_xsel_args():
"""only supports xclip options that are used by pass
* xclip -selection "$X_SELECTION"
@haolian9
haolian9 / lsmnts.zig
Created June 20, 2022 03:28
list mount points
/// mntpoints come from fstab
const std = @import("std");
const mem = std.mem;
const linux = std.os.linux;
const assert = std.debug.assert;
const os = std.os;
const c_fstab = @cImport(@cInclude("fstab.h"));
allocator: mem.Allocator,
@haolian9
haolian9 / ParkingLot.zig
Created July 10, 2022 14:29 — forked from kprotty/ParkingLot.zig
Small & Fast synchronization primitives for Zig
pub fn ParkingLot(comptime Config: type) type {
return struct {
pub const Lock: type = Config.Lock;
pub const Event: type = Config.Event;
pub const nanotime: fn() u64 = switch (@hasDecl(Config, "nanotime")) {
true => Config.nanotime,
@haolian9
haolian9 / main.lua
Last active May 26, 2023 10:51
interactive sudo for nvim
---@diagnostic disable: unused-local
--design choices/limits
--* sudo runs in a tty process
--* sudo should run in background
--* prompt user to enter his password when needed
--* singleton
--* sync but not blocking nvim
--
--supported forms:
@haolian9
haolian9 / redis_ping.lua
Created April 27, 2023 06:29
send ping to redis from nvim's lua runtime
local uv = vim.loop
local sock = assert(uv.new_pipe())
uv.pipe_connect(sock, "/run/user/1000/redis.sock", function(err) assert(err == nil, err) end)
uv.read_start(sock, function(err, data)
if err then
print("read error", err)
elseif data then
print("read data", data)