This file contains hidden or 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
/***** "Remote" server first *****/ | |
-- Note: Unless the object you are trying to gain access to is in the same DATABASE, it's a remote datebase. Even if it's | |
-- on the same node! | |
-- 1. create the role and assign it a password. Note: CREATE USER is an alias for CREATE ROLE. Either one is fine | |
CREATE ROLE new_user WITH PASSWORD 'somepassword'; | |
-- 2. Grant the required permissions. This grants select, insert, update, and delete on all tables in the public schema. | |
-- I also gave execute to all functions in the public schema as well. | |
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO new_user; | |
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO new_user; |
This file contains hidden or 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
/* | |
I recently took on a project at work to convert a very large Oracle database to PostgreSQL as part of our transition to AWS. | |
Now, I hate Oracle. When I say hate, I'm saying hate because it's unprofessional for me to use any stronger terminology. | |
Oracle likes to make things fairly easy (all things considered). They put a LOT of effort into creating a lot of little | |
features that, for the most part, are nice! But... I firmly believe that they do this because they don't want you to leave. | |
They WANT you to design yourself into a corner to the point where it's too much work for you to leave. | |
Below is a perfect example... | |
The oracle decode function basically makes for a one line case statement. |
This file contains hidden or 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
#!/bin/bash | |
# This is usually caused because of a network outage/restart while the Docker daemon was running. | |
# Restart the Docker daemon to fix it. | |
service docker restart |
This file contains hidden or 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
#!/bin/bash | |
# Get the ARNs of the policies and store in the policies_arn array. | |
mapfile -t policies_arn < <(aws iam list-policies --query 'Policies[*].[Arn]' --output text) | |
# Get the VersionIds for each policy and store in the policies_ver array. | |
mapfile -t policies_ver < <(aws iam list-policies --query 'Policies[*].[DefaultVersionId]' --output text) | |
# Use a for loop to loop through each policy and store the policy document in ~/policies.txt | |
for (( i=0; i<${#policies_arn[@]}; i++ )); do echo ${policies_arn[i]} >> policies.txt && aws iam get-policy-version --policy-arn ${policies_arn[i]} --version-id ${policies_ver[i]} --output json >> ~/policies.txt; done |
This file contains hidden or 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
#!/bin/bash | |
# Swap 'ext4' for the file system type you'd like | |
# Find partition name by running $ cat proc/partitions | |
mkfs.ext4 /dev/[partition_name] | |
# Mount with: | |
mount /dev/[partition_name] /path/to/directory/ | |
# Always mount on boot: |
This file contains hidden or 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
sudo groupadd docker && sudo gpasswd -a ${USER} docker && sudo systemctl restart docker | |
newgrp docker |
This file contains hidden or 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
#!/bin/bash | |
mv /var/run/docker.sock /var/run/docker.sock.orig && socat -v UNIX-LISTEN:/var/run/docker.sock,group=docker,perm=0660,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock.orig; mv /var/run/docker.sock.orig /var/run/docker.sock |
This file contains hidden or 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
#!/bin/bash | |
# Create array | |
array=(foo, bar) | |
echo ${array[@]} # => foo, bar | |
# Remove first index of array. | |
array=("${array[@]:1}") | |
echo ${array[@]} # => bar |
This file contains hidden or 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 busybox | |
VAR USERNAME \ | |
PASSWORD | |
RUN if [[ -n $username ]]; then echo $password; fi |
NewerOlder