Skip to content

Instantly share code, notes, and snippets.

@actionjack
actionjack / clean_code.md
Created November 18, 2021 12:28 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

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 July 23, 2021 14:56 — forked from tswaters/git-subdirectory-tracking.md
Adding subdirectory of a remote repo to a subdirectory in local repo

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
Created June 16, 2021 14:01 — forked from harveyconnor/a-mongodb-replica-set-docker-compose-readme.md
MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume

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
Created June 16, 2021 14:01 — forked from harveyconnor/a-mongodb-replica-set-docker-compose-readme.md
MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume

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!

#!/usr/bin/env bash
# MongoDB port
PORT=27017
# Consul key to setup the lock
MONGO_KEY="mongodb/replicaset"
#
# Retrieve MongoDB instance IPs from Consul
#

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 March 10, 2021 11:01
GitHub User's Creed

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 November 18, 2020 16:15 — forked from justinclayton/taint_module.sh
Terraform: taint all resources from one module
#!/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 November 5, 2020 20:17 — forked from lukechilds/get_latest_release.sh
Shell - Get latest release from GitHub
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 September 14, 2020 11:08 — forked from deltheil/nginx.conf
Hide sensitive GET parameters within nginx access logs thanks to the Lua module
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";