Skip to content

Instantly share code, notes, and snippets.

@actionjack
actionjack / clean_code.md
Created Nov 18, 2021 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin
View clean_code.md

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@actionjack
actionjack / git-subdirectory-tracking.md
Created Jul 23, 2021 — forked from tswaters/git-subdirectory-tracking.md
Adding subdirectory of a remote repo to a subdirectory in local repo
View git-subdirectory-tracking.md

This is way more complicated than it should be. The following conditions need to be met :

  1. need to be able to track and merge in upstream changes
  2. don't want remote commit messages in master
  3. only interested in sub-directory of another repo
  4. needs to go in a subdirectory in my repo.

In this particular case, I'm interested in bringing in the 'default' template of jsdoc as a sub-directory in my project so I could potentially make changes to the markup it genereates while also being able to update from upstream if there are changes. Ideally their template should be a separate repo added to jsdoc via a submodule -- this way I could fork it and things would be much easier.... but, it is what it is.

After much struggling with git, subtree and git-subtree, I ended up finding this http://archive.h2ik.co/2011/03/having-fun-with-git-subtree/ -- it basically sets up separate branches from tracking remote, the particular sub-directory, and uses git subtree contrib module to pull it all togther. Following are

@actionjack
actionjack / a-mongodb-replica-set-docker-compose-readme.md MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume
View a-mongodb-replica-set-docker-compose-readme.md

This will guide you through setting up a replica set in a docker environment using.

  • Docker Compose
  • MongoDB Replica Sets
  • Mongoose
  • Mongoose Transactions

Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!

@actionjack
actionjack / a-mongodb-replica-set-docker-compose-readme.md MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume
View a-mongodb-replica-set-docker-compose-readme.md

This will guide you through setting up a replica set in a docker environment using.

  • Docker Compose
  • MongoDB Replica Sets
  • Mongoose
  • Mongoose Transactions

Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!

View mongodb-replica.sh
#!/usr/bin/env bash
# MongoDB port
PORT=27017
# Consul key to setup the lock
MONGO_KEY="mongodb/replicaset"
#
# Retrieve MongoDB instance IPs from Consul
#
View #1 Merging Rubygems and Bundler.md

Merging Rubygems and Bundler

1.sh:

#!/bin/sh
set -eux
rm -rf rubygems bundler
git clone https://github.com/rubygems/rubygems
git clone https://github.com/rubygems/bundler
@actionjack
actionjack / github_users_cred.md
Last active Mar 10, 2021
GitHub User's Creed
View github_users_cred.md

GitHub User's Creed

This is my GitHub token. There are many like it, but this one is mine.

My GitHub token is my best friend. It is my life. I must master it as I must master my life.

Without me, my GitHub token is useless. Without my GitHub token, I am useless. I must code my GitHub token true. I must code cleaner than my enemy who is trying to out code me. I must out code him before he out codes me. I will ...

My GitHub token and I know that what counts in war is not the commits we make, the frequency of our rebases, nor the pull requests we make. We know that it is the merges that count. We will merge ...

@actionjack
actionjack / taint_module.sh
Created Nov 18, 2020 — forked from justinclayton/taint_module.sh
Terraform: taint all resources from one module
View taint_module.sh
#!/bin/bash
module=$1
for resource in `terraform show -module-depth=1 | grep module.${module} | tr -d ':' | sed -e 's/module.${module}.//'`; do
terraform taint -module ${module} ${resource}
done
@actionjack
actionjack / get_latest_release.sh
Created Nov 5, 2020 — forked from lukechilds/get_latest_release.sh
Shell - Get latest release from GitHub
View get_latest_release.sh
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@actionjack
actionjack / nginx.conf
Created Sep 14, 2020 — forked from deltheil/nginx.conf
Hide sensitive GET parameters within nginx access logs thanks to the Lua module
View nginx.conf
http {
log_format filt '$remote_addr - $remote_user [$time_local] "$_request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
location /login {
# `set` is provided by the Rewrite module
set $filter "password|secret";