This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use JSON 'encode_json'; | |
my $code = `find .. -name '*.tf' -exec cat {} +`; | |
my @blocks = map { $_ =~ m/ (?^:((?:\{(?:(?>[^\{\}]+)|(?-1))*\}))) /xg } $code; | |
my @repos = grep { m| \s* source \s*=\s* ".+/modules/repository" |xg } @blocks; | |
my @names = map { $_ =~ m/ \s* name \s*=\s* "((?:[^"]+|"")*)" /xg } @repos; | |
my @unique = sort { $a cmp $b } do { my %seen; grep { !$seen{$_}++ } @names }; | |
print encode_json { data => encode_json { repos => \@unique } }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import yaml | |
from collections import defaultdict | |
environments = [ | |
d.removesuffix(".tfvars") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
SELF_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd -P) | |
SELF_FILE="$SELF_DIR/$(basename "${BASH_SOURCE[0]}")" | |
replace() { | |
local inpat=$1 | |
local outpat=$2 | |
echo "$inpat ==> $outpat ..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read -r -d '' TF_CLI_ARGS_plan << \ | |
---------------------------------------------- | |
-compact-warnings | |
-var-file=${PWD}/environments/${ENVIRONMENT}.tfvars | |
---------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from logging import getLevelName, basicConfig, INFO | |
format = "%(asctime)s⏐%(levelname)5.5s⏐%(name)s.%(funcName)s():%(lineno)d⏐ %(message)s" | |
basicConfig(format=format, level=getLevelName(INFO)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Add quick links to GitHub | |
// @match https://github.com/* | |
// @inject-into content | |
// ==/UserScript== | |
const links = ` | |
# --- START OF LINKS --- | |
/Cleeng | |
/CodeForPoznan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class jsondict(dict): | |
__getattribute__ = dict.__getitem__ | |
def __init__(self, d): | |
for k, v in d.items(): | |
if isinstance(v, dict): | |
d[k] = jsondict(v) | |
super().__init__(d) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bytes | |
print(f"{os.path.getsize(filepath):,} B") | |
Kilobits | |
print(f"{os.path.getsize(filepath)/float(1<<7):,.0f} kb") | |
Kilobytes | |
print(f"{os.path.getsize(filepath)/float(1<<10):,.0f} KB") | |
Megabits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# source: https://stackoverflow.com/a/43640996 | |
FILE=$1 | |
# replace FILE with the file or folder you wish to remove from the given git repository. | |
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch $FILE" -- --all | |
rm -rf .git/refs/original/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd dirA | |
terraform state pull > ../dirA.tfstate | |
cd ../dirB | |
terraform state pull > ../dirB.tfstate | |
terraform state mv -state=../dirA.tfstate -state-out=../dirB.tfstate module.foo module.foo | |
terraform state push ../dirB.tfstate |