Skip to content

Instantly share code, notes, and snippets.

View igaskin's full-sized avatar
🏠
Working from home

Isaac Gaskin igaskin

🏠
Working from home
View GitHub Profile
@apetresc
apetresc / redelegate-cro.sh
Last active March 28, 2023 05:44
A script to automatically claim Crypto.org CRO staking rewards and re-stake them
#!/bin/bash -e
# redelegate-cro.sh is a script that automatically claims all your delegation
# rewards (across any number of validators) in a single transaction (assuming a
# minimum reward threshold is met, to avoid spurious transactions). The rewards
# are then automatically redelegated to the provided validator address, leaving
# behind at least a 0.005 CRO buffer to ensure there is always enough for
# regular transaction fees.
#
# The idea is that it is safe to run this script on a fixed cron schedule and
@ottokruse
ottokruse / aws-console
Last active November 9, 2024 09:35
Python script to launch the AWS console in your webbrowser, using a presigned URL generated from your AWS CLI credentials
#!/usr/bin/env python3
"""
Usage:
- Save this script somewhere on your path (e.g. `vi /usr/local/bin/aws-console && chmod +x /usr/local/bin/aws-console`)
- Make AWS credentials available in one of the usual places where boto3 can find them (~/.aws/credentials, env var, etc.)
- Excute the script: `aws-console --profile myprofile`
- :tada: Your browser opens and you are signed in into the AWS console
"""
@jannfis
jannfis / launch.json
Last active September 20, 2022 13:52
vscode launcher configuration for debugging Argo CD components
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug argocd-server",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/cmd/main.go",
"args": [
@jannfis
jannfis / start-debug.sh
Last active March 5, 2021 07:46
Script to start Argo CD locally for debugging
#!/bin/sh
# Usage: $0 <component to debug>
# Will start all other components, and leaves starting the component to debug
# to the user (most likely, using delve via vscode).
MANDATORY_COMPONENTS="dex redis ui git-server dev-mounter"
case "$1" in
"server")
ADDITIONAL_COMPONENTS="repo-server controller"
;;
@graboskyc
graboskyc / mongomirrorCommand.md
Created February 16, 2020 01:01
mongomirrorCommand
  • Install MongoDB Enterprise Advanced 4.0 using the following commands:

    Purpose Command
    Add MongoDB Public Key wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -
    Add MongoDB EA Repo echo "deb [ arch=amd64 ] http://repo.mongodb.com/apt/ubuntu bionic/mongodb-enterprise/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list
    Update Apt Package Cache sudo apt-get update
    Install MongoDB EA 4.0.15 sudo apt-get install -y mongodb-enterprise=4.0.15 mongodb-enterprise-server=4.0.15 mongodb-enterprise-shell=4.0.15 mongodb-enterprise-mongos=4.0.15 mongodb-enterprise-tools=4.0.15
  • Edit the MongoDB Enterprise config file by running sudo vi /etc/mongod.etc update the binding, add it to a replica set, and enable username and password auth as shown below or in the sample config.

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@ines
ines / diff_strings.py
Created August 1, 2019 12:19
Print colored visual diff in Python
import difflib
import wasabi
def diff_strings(a, b):
output = []
matcher = difflib.SequenceMatcher(None, a, b)
for opcode, a0, a1, b0, b1 in matcher.get_opcodes():
if opcode == "equal":
output.append(a[a0:a1])
elif opcode == "insert":
// This file was initially generated by Windows Terminal 1.0.1401.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@ayubmalik
ayubmalik / gpg-encrypt.go
Last active July 23, 2024 19:09
Golang encrypt file using GPG openpgp. Use standard go libs.
package main
/**
Example hack to encrypt a file using a GPG encryption key. Works with GPG v2.x.
The encrypted file e.g. /tmp/data.txt.gpg can then be decrypted using the standard command
gpg /tmp/data.txt.gpg
Assumes you have **created** an encryption key and exported armored version.
You have to read the armored key directly as Go cannot read pubring.kbx (yet).

Dope Shell Stuff

These are my favorite tools for making my terminal a nice place to work.

Tools

  • bat: cat, with syntax highlighting, git, and diff support
  • chezmoi: Sync your dotfiles using a Git repo
  • diff-so-fancy: better-looking diffs for modern terminals
  • eza: ls, but pretty by default