Skip to content

Instantly share code, notes, and snippets.

View ndgnuh's full-sized avatar

Hùng ndgnuh

View GitHub Profile
@ndgnuh
ndgnuh / ibus-cycle.sh
Created February 22, 2021 14:13
IBus engine cycling
#!/bin/sh
# chỉnh bộ gõ ở đây {{{ #
engines="xkb:us::eng, Bamboo"
# }}} chỉnh bộ gõ ở đây #
engines=$(echo $engines | sed s'/\s//g')
first_engine=$(echo $engines | cut -d ',' -f 1)
cur_next_engines=$(echo $engines \
| tr ',' '\n' \
@ndgnuh
ndgnuh / runonce
Created March 10, 2021 18:37
Run once shell script
#!/bin/sh
BASEDIR="/var/run/user/$(id -u)/runonce"
COMMAND="$@"
HASH="$(echo "$COMMAND" | md5sum | cut -d ' ' -f 1)"
PIDFILE="$BASEDIR/$HASH"
show_help () {
echo "runonce <command>"
}
@ndgnuh
ndgnuh / gama-headless.sh
Last active April 8, 2021 10:22
Gama headless mode, with custom flags and ffmpeg render option
#!/bin/sh
assign () {
# get rid of single quote mark
eval $1=$(echo $2)
}
banner () {
echo "******************************************************************"
echo "* GAMA version 1.8.1 *"
@ndgnuh
ndgnuh / gaml.vim
Created March 21, 2021 14:15
Vim syntax file for Gama-language (Gaml)
" Syntax highlighting for Gama language
" https://gama-platform.github.io
if exists('b:current_syntax')
finish
endif
setlocal iskeyword+=\#
setlocal iskeyword+=\:
@ndgnuh
ndgnuh / ffcite.tex
Created April 10, 2021 16:01
Nice footnote cite
\ExecuteBiblatexOptions{citestyle=numeric-comp}
\makeatletter
\let\ffcitepre\empty
\let\ffcitepost\empty
\DeclareCiteCommand{\cite}[\mkbibbrackets]
{%
\usebibmacro{cite:init}%
\usebibmacro{prenote}%
}
@ndgnuh
ndgnuh / main.tex
Last active June 16, 2021 12:52
Bìa đồ án tốt nghiệp (Bách Khoa)
% Dùng lualatex để compile, nếu dùng pdflatex thìt thay \pageheight ở trong titlepage.tex bằng \pdfpageheight và thêm hỗ trợ tiếng Việt vào.
\usepackage{tikz}
\usepackage[a4paper, top=3.5cm, bottom=3cm, right=2cm, left=3.5cm]{geometry}
\input{titlepage.tex}
\title{Tiêu đề}
\reporttype{Đồ án tốt nghiệp đại học}
\major{Toán tin}
\author{Nguyễn Đức Hùng}
\address{Hà nội}
\date{2021}
@ndgnuh
ndgnuh / bibliography-setup.tex
Last active June 16, 2021 17:52
Setup biblatex cho đồ án.
% By language
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite] {
\map{
\perdatasource{refs.bib}
\step[fieldset=language, fieldvalue={02english}, append]
\step[fieldset=keywords, fieldvalue={english}, append]
}
\map{
\perdatasource{refs.vn.bib}
@ndgnuh
ndgnuh / border_dwim.lua
Created September 19, 2021 19:17
awesomewm "smart" border_width
local function make_border_dwim(t)
-- use this because there might be multiple tag selected
local cs = t.screen.clients
local border = {}
-- because maximized and fullscreen client
-- are considered floating
local function truefloat(c)
return c.floating and (not c.maximized) and (not c.fullscreen)
end
@ndgnuh
ndgnuh / vn-font-components.md
Last active January 3, 2022 15:12
Vietnamese font components

Các loại dấu mũ, móc

Code point Chú thích
0x0302 Dấu mũ (â, ô)
0x0306 Dấu mũ ngược (ă)
0x03b1 Dấu móc (ơ, ư)

Các loại dấu thanh

@ndgnuh
ndgnuh / l2tp-add-config
Created January 22, 2022 04:59
New L2TP Connection profile
#!/bin/sh
# https://askubuntu.com/questions/1167283/l2tp-connection-client-on-ubuntu-18-04-server
VPNDATA="
gateway = [ipv4],
ipsec-enabled = yes,
ipsec-psk = 0s"$(base64 <<<'[PSK]' | rev | cut -c2- | rev)"=,
mru = 1400,
mtu = 1400,
password-flags = 0,
refuse-chap = yes,