Skip to content

Instantly share code, notes, and snippets.

View linktohack's full-sized avatar

Quang-Linh LE linktohack

View GitHub Profile
@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 / 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 / backlink.el
Created June 11, 2020 16:51
Org back link
@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 / 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 / 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 / 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 / app.ts
Last active May 15, 2019 20:57
(Somewhat) Elm in TypeScript
// FRAMEWORK
type Html<Msg> =
| {
el: string;
attrs: { [key: string]: string };
events: { [key: string]: (event: Event) => Msg };
children: Html<Msg>[];
}
| { text: string };
@linktohack
linktohack / Program.fsx
Created May 14, 2019 12:08
Fable (2.2+) interop
module Program
open System.Text.RegularExpressions
open Fable.Core
open Fable.Core.JS
open Fable.Core.JsInterop
module Process =
type IEnv =
abstract PORT: string option
async function series<T>(promises: (() => Promise<T>)[],): Promise<T[]> {
const results: T[] = [];
async function seriesInner(promises: (() => Promise<T>)[]): Promise<T[]> {
if (promises.length > 0) {
const p = promises.shift();
const result = await p();
results.push(result);
return seriesInner(promises);
} else {
return results;