Skip to content

Instantly share code, notes, and snippets.

View shotgunner's full-sized avatar
👊

Mojtaba Kamyabi shotgunner

👊
View GitHub Profile
@shotgunner
shotgunner / working_effectively_with_legacy_code.md
Created July 11, 2022 19:44 — forked from jonnyjava/working_effectively_with_legacy_code.md
Working effectively with legacy code summary

WORKING EFFECTIVELY WITH LEGACY CODE

To me, legacy code is simply code without tests. I’ve gotten some grief for this definition. What do tests have to do with whether code is bad? To me, the answer is straightforward, and it is a point that I elaborate throughout the book: Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably. Without them, we really don’t know if our code is getting better or worse.

Chapter 1 Changing Software

Four Reasons to Change Software: For simplicity’s sake, let’s look at four primary reasons to change software.

@shotgunner
shotgunner / System Design.md
Created July 25, 2021 10:34 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?

FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@shotgunner
shotgunner / Docker
Created July 1, 2020 09:18 — forked from mitchwongho/Docker
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
  1. Install docker
  2. Install shadowsocks and v2ray then set deamon.json for docker
  3. **in ROOT user => ** export http_proxy=socks5://127.0.0.1:7788 https_proxy=socks5://127.0.0.1:7788 => refrence and in /etc/environment add this line:

export http_proxy=socks5://127.0.0.1:7788
export https_proxy=socks5://127.0.0.1:7788

install npm and add http-proxy-to-socks package to convert socks<->http(s)

@shotgunner
shotgunner / docker-healthcheck.md
Last active November 17, 2023 23:40
How to view docker healthcheck logs?

How to see healthcheck Logs ?

Use docker inspect is different in swarm mode and normal mode if you wnat to use it in swarm mode:

  • Manager nodes: use this command for services. (but if you want to see healthceck logs of specific container see worker nodes section):

    • docker inspect --format "{{json .Spec.TaskTemplate.ContainerSpec.Healthcheck }}" hinava_dashboard |jq
  • Worker nodes: you should use complete name of the container that completed with <tab> key

  • docker inspect hinava_filebeat.1.umvobmm9wrjdz1b08y5jibvl2 | grep -B 10 -A 10 "health"
@shotgunner
shotgunner / docker exec alias
Last active May 30, 2020 06:14
simplified `docker exec -it <some_container> bash` to a alias function in bash
GREEN='\033[0;32m'
NC='\033[0m' # No Color
function goto() {
program="bash"
if [ -n "$2" ]
then
program="$2"
fi
if [ $(docker ps -q --filter "name=$1" | wc -l) -gt 1 ]
@shotgunner
shotgunner / test.js
Created December 3, 2017 19:54
cube slam corrected js file
function require(e,t,n){var i=require.resolve(e);if(null==i){n=n||e,t=t||"root";var a=new Error('Failed to require "'+n+'" from "'+t+'"');throw a.path=n,a.parent=t,a.require=!0,a}var r=require.modules[i];return r.exports||(r.exports={},r.client=r.component=!0,r.call(this,r.exports,require.relative(i),r)),r.exports}var has=Object.prototype.hasOwnProperty;require.modules={},require.aliases={},require.resolve=function(e){for(var t=e+"/index.js",n=[e,e+".js",e+".json",e+"/index.js",e+"/index.json"],i=0;i<n.length;i++){var e=n[i];if(has.call(require.modules,e))return e}return has.call(require.aliases,t)?require.aliases[t]:void 0},require.normalize=function(e,t){var n=[];if("."!=t.charAt(0))return t;e=e.split("/"),t=t.split("/");for(var i=0;i<t.length;++i)".."==t[i]?e.pop():"."!=t[i]&&""!=t[i]&&n.push(t[i]);return e.concat(n).join("/")},require.register=function(e,t){require.modules[e]=t},require.alias=function(e,t){if(!has.call(require.modules,e))throw new Error('Failed to alias "'+e+'", it does not exist');requir

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: