Skip to content

Instantly share code, notes, and snippets.

View outsinre's full-sized avatar

Zachary Hu outsinre

View GitHub Profile
@outsinre
outsinre / deep_compare.lua
Last active February 15, 2023 13:26
Lua gist
-- deeply compare two objects like 'pl.tablex.deepcompare()'
local function deep_equals(t1, t2, ignore_mt)
-- different type
if t1Type ~= t2Type then return false end
-- compare simple values directly
if t1Type ~= 'table' then return t1 == t2 end
-- both table type; try metatable method
if not ignore_mt then
local mt1 = getmetatable(t1)
[cplayer] Reading config file /home/zachary/.config/mpv/mpv.conf
[cplayer] Setting option 'no-border' = '' (flags = 4)
[cplayer] Setting option 'ontop' = 'no' (flags = 4)
[cplayer] Setting option 'save-position-on-quit' = 'yes' (flags = 4)
[cplayer] Setting option 'autofit-larger' = '100%' (flags = 4)
[cplayer] Setting option 'profile' = 'pseudo-gui' (flags = 4)
[cplayer] Setting option 'terminal' = 'no' (flags = 4)
libva info: VA-API version 0.38.1
libva info: va_getDriverName() returns 0
a-a 12 34 12
a-a-a 56 56
a-ba-ao-ke-luo 78 90 90

Each line is a key values pattern. The key is a string delimited by hyphens. while values delimited by spaces.

I want to remove duplicate vlaues on each line:

I want to merge lines that share common prefix. Example:

a 1
a 2
bc-de 3
bc-de 4
bc-de 5

After merging:

I want to merge lines that share common prefix. Example:

a 1
a 2
bc-de 3 4
bc-de 5

After merging:

I want to merge lines that share common prefix. Example:

a 1
a 2
a-b 3
a-b 4
a-b 5

After merging:

I want to merge lines that share common prefix. Example:
```
a 1
a 2
a-b 3
a-b 4
a-b 5
```
After merging:
@outsinre
outsinre / workspacetest.txt
Created December 6, 2015 05:41
workspace/test.txt
create_an_agent_socket() {
echo "No agents found"
read -p "Create an agent and add keys (y/n)?" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
if [ -z "$SSH_AUTH_SOCK" -a -z "$SSH_AGENT_PID" ]; then
eval "$(ssh-agent -s)" > /dev/null
fi
else
@outsinre
outsinre / etcportagepackage.useuseflags
Created October 15, 2015 01:34
/etc/portage/package.use/useflags
# This package.use file was generated by gentoolkit's 'enalyze rebuild' module
# Date: Thu Oct 15 09:27:47 2015
app-editors/emacs xft
app-emulation/virtualbox -qt4 extensions
app-i18n/fcitx gtk3
app-portage/layman sync-plugin-portage
app-text/texlive cjk linguas_zh xetex
app-text/texlive-core cjk xetex
dev-lang/python:2.7 sqlite
@outsinre
outsinre / .lesshst
Created October 14, 2015 06:02
.lesshst
.less-history-file:
.search
"efi
"removable
"bootloader
"zachary
"8.1
"xorg-server
"dolvm
"root_key