Skip to content

Instantly share code, notes, and snippets.

View pmint93's full-sized avatar
Working from anywhere

Thanh Pham Minh pmint93

Working from anywhere
View GitHub Profile
@rmoriz
rmoriz / desc.md
Last active October 25, 2023 12:21
WireGuard Key Generation (wg genkey)

wg genkey / pubkey

wg genkey
qJvFeHHuffBaPWx4veJGQqXw6j5zdo5cSOaBd1Z0Km4=


echo 'qJvFeHHuffBaPWx4veJGQqXw6j5zdo5cSOaBd1Z0Km4=' | wg pubkey
knL56pMLtyQVyZXOd9m2vEeOopPtbv4tMSU0ctBvGQo=
@milesbxf
milesbxf / monzo-alertmanager-config.yaml
Last active July 17, 2024 12:51
Monzo's Alertmanager Slack templates
###################################################
##
## Alertmanager YAML configuration for routing.
##
## Will route alerts with a code_owner label to the slack-code-owners receiver
## configured above, but will continue processing them to send to both a
## central Slack channel (slack-monitoring) and PagerDuty receivers
## (pd-warning and pd-critical)
##
@dreikanter
dreikanter / encrypt_openssl.md
Last active June 20, 2024 10:15 — forked from crazybyte/encrypt_openssl.txt
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@mattheworiordan
mattheworiordan / cli.rb
Created January 9, 2015 12:21
Thor with subcommands that work correctly with help
#!/usr/bin/env ruby
require 'thor'
class SubCommandBase < Thor
def self.banner(command, namespace = nil, subcommand = false)
"#{basename} #{subcommand_prefix} #{command.usage}"
end
def self.subcommand_prefix
@oleksii-zavrazhnyi
oleksii-zavrazhnyi / gist:968e5ea87e99d9c41782
Created November 28, 2014 17:32
BASH Absolute path of current script
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

Is a useful one-liner which will give you the full directory name of the script no matter where it is being called from

These will work as long as the last component of the path used to find the script is not a symlink (directory links are OK). If you want to also resolve any links to the script itself, you need a multi-line solution:

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
@torsten
torsten / expanding-json-arrays-to-rows.sql
Last active April 8, 2021 15:35
Expanding JSON arrays to rows with SQL on RedShift: All queries to reproduce the technique from my blog post https://torsten.io/stdout/expanding-json-arrays-to-rows
-- Related blog post to this Gist:
-- https://torsten.io/stdout/expanding-json-arrays-to-rows
-- Run these commands on a interactive RedShift session:
CREATE TEMP TABLE clusters AS (
SELECT 1 AS id, '[1, 2]' AS node_sizes UNION ALL
SELECT 2 AS id, '[5, 1, 3]' AS node_sizes UNION ALL
SELECT 3 AS id, '[2]' AS node_sizes
);
@nilbus
nilbus / gist:6385142
Last active February 23, 2016 23:35 — forked from ryanlecompte/gist:1420133
Ruby multiple callbacks
# alternative to what is explained in the article Ruby Blocks as Dynamic Callbacks:
# http://www.mattsears.com/articles/2011/11/27/ruby-blocks-as-dynamic-callbacks
class Callbacks
def initialize(block)
block.call(self)
end
def callback(message, *args)
callbacks[message].call(*args)