Skip to content

Instantly share code, notes, and snippets.

View naviat's full-sized avatar
🪲

naviat

🪲
View GitHub Profile
@naviat
naviat / README.md
Created March 5, 2024 04:21
redshift-backup_restore

manage-redshift

Amazon Redshift is a cloud data warehouse tool included in AWS. You can manage your data warehouse clusters using the AWS management Console or using the Amazon Redshift APIs. This post demonstrates a small subset of the Redshift API to create clusters from a snapshot and vice versa using a bash shell script.

If you want to delete a cluster, you have a choice of saving it first as a snapshot or deleting it with no final snapshot. With a snapshot, you can restore the cluster at a later time. If you choose not to save it as a snapshot, then the cluster will be deleted permanently with no restore option. In this case, you would have to recreate the cluster manually from scratch.

The script below only gives the user the option to save an existing cluster to a snapshot or restoring a cluster from an existing snapshot. To provide a measure of security and protection, you should set up IAM policies that walls off clusters and snapshots from accidental deletes or unprivileged access to your data.

@naviat
naviat / verify_public_key_and_retrieve_secret.py
Last active April 25, 2024 05:13
Verify public key and retrieve secret
import json
import boto3
import base64
import os
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from botocore.exceptions import ClientError
///////
// Warning, code untested
///////
type Thinger interface {
SomeMethod( arg bool ) bool
}
type RealThing struct {
state bool
@naviat
naviat / instructions.md
Created January 15, 2024 21:07 — forked from matthewjberger/instructions.md
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

@naviat
naviat / LocalDot.md
Last active January 15, 2024 19:53
Dotfile for zsh

Step by step

For AWS CLI ALIAS

  • Install aws cli
  • Copy file alias to ~/.aws/cli/ and use the alias: aws
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"
ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
@naviat
naviat / gist:fbce54e6b1b68dbc9cea0e9149e36188
Created May 29, 2023 08:05 — forked from luckydev/gist:ed966a7c12fd4b1311c063b77dc81389
Reset Google authenticator token (2FA) for a specific openvpn user
SSH Login as openvpnas user
$ ssh openvpnas@<open-vpn-server-ip>
$ cd /usr/local/openvpn_as/scripts/ # Go to OpenVPN AS Scripts directory
$ sudo ./sacli --user USERNAME GoogleAuthRegen # Replace USERNAME with username to get a new Google Authenticator Secret
Source: https://forums.openvpn.net/viewtopic.php?t=15366
@naviat
naviat / post-to-slack.sh
Created April 20, 2023 05:01 — forked from stekhn/post-to-slack.sh
Post to Slack using curl on the command line. The incoming webhook for your Slack team needs to be created beforehand.
# Read more about Slack webhooks here: https://api.slack.com/messaging/webhooks
curl -X POST \
-H 'Content-type: application/json; charset=utf-8' \
--data '{ "channel": "#mychannel", "username": "superbot", "icon_emoji": ":bot:", "text": "Foo" }' \
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
@naviat
naviat / .gitattributes
Created February 16, 2023 06:56 — forked from webbertakken/.gitattributes
.gitattributes for Unity projects
#
# Git attributes for Unity projects
#
# Compiled by the GameCI community - https://game.ci
#
# Latest version at https://gist.github.com/webbertakken/ff250a0d5e59a8aae961c2e509c07fbc
#
# Ensure that text files that any contributor introduces to the repository have their line endings normalized
* text=auto
# Maintainer: Jakub Hajek, jakub.hajek@cometari.com
#
# docker stack deploy -c stack-elastic.yml elastic
#
# The stack creates Elasticsearch cluster consiting of
# - 3 dedicated master nodes in order to keep quorum
# - 4 dedicated data nodes to manage CRUD,
#
# Docker compose file to easily deploy Elasticsearch cluster 7.x on Docker Swarm cluster.
@naviat
naviat / slowquery_logger.sh
Created November 30, 2022 02:24 — forked from theprogrammerin/slowquery_logger.sh
Bash script to fetch the log for that hour from Amazon RDS and push it to ElasticSearch / Kibana
#!/bin/bash
#
# Ashutosh Agrawal
# http://blog.theprogrammer.in
#
#
# This bash script simply fetches the log for that hour from Amazon RDS,
# parse and genarlise it using mysql_slow_log_parser (https://gist.github.com/theprogrammerin/e3206a4ec7a7a4086ac2)
# and then push the parsed log to elastic search using logstash (slowquery.conf)(https://gist.github.com/theprogrammerin/034a3efd849112d166ea)
# For analysis on analytic tool like kibana.