Skip to content

Instantly share code, notes, and snippets.

View linktohack's full-sized avatar

Quang-Linh LE linktohack

View GitHub Profile
@linktohack
linktohack / mc.el
Created March 2, 2020 22:11
Multiple cursors ST version
(global-set-key (kbd "s-d") 'mc/mark-next-like-this-word)
(global-set-key (kbd "s-k") nil)
(global-set-key (kbd "s-k s-d") 'mc/skip-to-next-like-this)
(global-set-key (kbd "s-k s-u") 'mc/unmark-next-like-this)
(define-key mc/keymap (kbd "<return>") nil)
(global-unset-key (kbd "s-<down-mouse-1>"))
(global-set-key (kbd "s-<mouse-1>") 'mc/add-cursor-on-click)
@linktohack
linktohack / iptables.sh
Created March 9, 2020 18:06
Reset iptables
sudo iptables-save | awk '/^[*]/ { print $1 }
/^:[A-Z]+ [^-]/ { print $1 " ACCEPT" ; }
/COMMIT/ { print $0; }' | sudo iptables-restore
sudo iptables-legacy-save | awk '/^[*]/ { print $1 }
/^:[A-Z]+ [^-]/ { print $1 " ACCEPT" ; }
/COMMIT/ { print $0; }' | sudo iptables-legacy-restore
sudo iptables-save
@linktohack
linktohack / lb.yaml
Created April 11, 2020 11:52
LoadBalancer service
# Source: stack/templates/stack.yml
apiVersion: v1
kind: Service
metadata:
name: ant-media-loadbalancer-udp
spec:
loadBalancerIP: REDACTED
ports:
- name: udp-5000
port: 5000
@linktohack
linktohack / files.el
Created June 10, 2020 17:21
Tramp thread safe
;;; files.el --- file input and output commands for Emacs -*- lexical-binding:t -*-
;; Copyright (C) 1985-1987, 1992-2020 Free Software Foundation, Inc.
;; Maintainer: [email protected]
;; Package: emacs
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
@linktohack
linktohack / backlink.el
Created June 11, 2020 16:51
Org back link
@linktohack
linktohack / org-sync-attachments.el
Last active February 25, 2022 14:54
Org Sync attachments
(defun org-sync-attachments ()
"Update the current entry's attachment metadata."
(interactive)
(let* ((attachments (if (org-attach-dir)
(org-attach-file-list (org-attach-dir))))
(tag-state (if attachments 'on 'off))
(org-attach-file-list-property "Attachments"))
(if attachments
(org-set-property org-attach-file-list-property
@linktohack
linktohack / helm.sh
Last active September 23, 2020 17:16
Helm save all stacks
helm ls -A | awk 'NR > 1 { print "helm -n " $2 " get values " $1 " > " $2 "_____" $1 ".yaml" }' > run.sh && source run.sh
@linktohack
linktohack / kubel-lens.el
Last active February 25, 2022 14:50
KUBEL with Lens config
(defvar helm-source-lens-kubeconfigs nil "Lens kubeconfigs source")
(defun my/kubel-with-lens-configs (&optional kubeconfigs-dir)
"Launch kubel with Lens configs.
Require `yq' (a wrapper of `jq' for `yaml') in your path."
(interactive)
(unless kubeconfigs-dir
(setq kubeconfigs-dir "~/Library/Application Support/Lens/kubeconfigs"))
@linktohack
linktohack / tab-line-close-tab-function.el
Created July 30, 2021 11:07
Delete window when the last tab buried.
(setq tab-line-close-tab-function
#'(lambda (tab)
"Delete window when the last tab buried."
(let* ((buffer (if (bufferp tab) tab (cdr (assq 'buffer tab))))
(window (get-buffer-window buffer)))
(with-selected-window (or window (selected-window))
(let ((last-tab-p (length< (tab-line-tabs-window-buffers) 2)))
(if (eq buffer (current-buffer))
(bury-buffer)
(set-window-prev-buffers nil (assq-delete-all buffer (window-prev-buffers)))
@linktohack
linktohack / clock.lua
Created August 24, 2021 08:59
HAMMERSPOOL Clock item in menubar
local clockingLog = hs.logger.new("clocking")
local clockingMenu = hs.menubar.new()
local currentTask = nil
local function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
local function eval(sexp, callback)
hs.task.new(