Skip to content

Instantly share code, notes, and snippets.

View s5unty's full-sized avatar

Sun Wuan s5unty

View GitHub Profile
@blueyed
blueyed / _tmux_pane_words.zsh
Last active May 26, 2023 07:39
ZSH configuration to complete words from tmux pane(s)
# Complete words from tmux pane(s) {{{1
# Source: http://blog.plenz.com/2012-01/zsh-complete-words-from-tmux-pane.html
# Gist: https://gist.github.com/blueyed/6856354
_tmux_pane_words() {
local expl
local -a w
if [[ -z "$TMUX_PANE" ]]; then
_message "not running inside tmux!"
return 1
fi
@kborovik
kborovik / How to use a GPG key for SSH authentication
Created October 8, 2020 12:28
How to use a GPG key for SSH authentication
# How to use a GPG key for SSH authentication
# Tested on Ubuntu 20.04 LTS
# Enable SSH support in gpg-agent:
echo enable-ssh-support > ~/.gnupg/gpg-agent.conf
# Cache GPG & SSH passwords for 24 hours (the reboot will clear the password cache)
echo max-cache-ttl 86440 >> ~/.gnupg/gpg-agent.conf
echo max-cache-ttl-ssh 86440 86440 >> ~/.gnupg/gpg-agent.conf
echo default-cache-ttl 86440 >> ~/.gnupg/gpg-agent.conf
@dtjm
dtjm / join_test.go
Last active November 26, 2023 13:18
Benchmarking various ways of concatenating strings in Go
package join
import (
"fmt"
"strings"
"testing"
)
var (
testData = []string{"a", "b", "c", "d", "e"}
@louiszuckerman
louiszuckerman / gfid-resolver.sh
Last active November 29, 2023 10:01
Glusterfs GFID Resolver Turns a GFID into a real path in the brick
#!/bin/bash
if [[ "$#" < "2" || "$#" > "3" ]]; then
cat <<END
Glusterfs GFID resolver -- turns a GFID into a real file path
Usage: $0 <brick-path> <gfid> [-q]
<brick-path> : the path to your glusterfs brick (required)
@sanhuang
sanhuang / README.md
Created November 29, 2016 07:25
繁簡體中文日文韓文的Unicode字元範圍

** 匹配Unicode字符的正則表達式

這裡是幾個主要非英文語系字符範圍(google上找到的):

  • 2E80~33FFh:中日韓符號區。收容康熙字典部首、中日韓輔助部首、注音符號、日本假名、韓文音符,中日韓的符號、標點、帶圈或帶括符文數字、月份,以及日本的假名組合、單位、年號、月份、日期、時間等。
  • 3400~4DFFh:中日韓認同表意文字擴充A區,總計收容6,582個中日韓漢字。
  • 4E00~9FFFh:中日韓認同表意文字區,總計收容20,902個中日韓漢字。
  • A000~A4FFh:彝族文字區,收容中國南方彝族文字和字根。
  • AC00~D7FFh:韓文拼音組合字區,收容以韓文音符拼成的文字。
  • F900~FAFFh:中日韓兼容表意文字區,總計收容302個中日韓漢字。
  • FB00~FFFDh:文字表現形式區,收容組合拉丁文字、希伯來文、阿拉伯文、中日韓直式標點、小符號、半角符號、全角符號等。
@akorn
akorn / rsync_parallel.sh
Last active January 26, 2024 08:18 — forked from rcoup/rsync_parallel.sh
This script can transfer large directory structures with parallel rsync workers. Example command line: `rsync_parallel . -- -aHSAX --exclude '*13' . /tmp/2/.`
#!/bin/zsh
#
# Copyright (c) 2014, 2020 by Dr. András Korn. Implements the basic idea of a similar script by Robert Coup (2013).
# License: GPLv3
function usage() {
echo 'Usage:
rsync_parallel [--parallel=N] <args to find(1) to generate list of stuff to transfer> -- <args to rsync>
@mayneyao
mayneyao / notion2blog.js
Last active February 29, 2024 18:01
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@mazgi
mazgi / console.log.md
Last active March 18, 2024 17:18
LDAP Auth for SSSD, SSH, SUDO
# uname -a
Linux base 4.0.5-gentoo #1 SMP Wed Jul 1 02:23:16 JST 2015 x86_64 Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz GenuineIntel GNU/Linux

Packages

# emerge -pvq openldap openssh sssd sudo
[ebuild R ] net-nds/openldap-2.4.38-r2 USE="berkdb crypt gnutls ipv6 minimal sasl ssl syslog tcpd -cxx -debug -experimental -icu -iodbc -kerberos -odbc -overlays -perl -samba (-selinux) -slp -smbkrb5passwd" ABI_X86="(64) -32 (-x32)" 
@andrewlkho
andrewlkho / gist:7373190
Last active March 25, 2024 03:37
How to use authentication subkeys in gpg for SSH public key authentication

GPG subkeys marked with the "authenticate" capability can be used for public key authentication with SSH. This is done using gpg-agent which, using the --enable-ssh-support option, can implement the agent protocol used by SSH.

Requirements

A working gpg2 setup is required. It may be possible to use gpg 1.4 but with gpg-agent compiled from gpg2. If you are using OS X 10.9 (Mavericks) then you may find the instructions [here][1] useful.

# GIT heart FZF
# -------------
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
fzf-down() {
fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@"
}