Skip to content

Instantly share code, notes, and snippets.

View mohsen0's full-sized avatar

Mohsen mohsen0

  • Qudini
  • London, UK
View GitHub Profile
@mohsen0
mohsen0 / ami-clean.sh
Created May 26, 2022 09:55 — forked from garlandkr/ami-clean.sh
Clean-up an Amazon EC2 instance before creating an AMI
#!/bin/bash
# Run this script with:
# bash <(curl -s https://gist.github.com/garlandkr/e80674b49270b0199fa6/raw/ami-clean.sh
function print_green {
echo -e "\e[32m${1}\e[0m"
}
print_green 'Clean Yum'
@mohsen0
mohsen0 / AWS Vault temporary profile.md
Last active May 11, 2021 09:39
AWS Vault temporary profile

In order to create short lived credentials to use interact with AWS APIs using aws-vault, since most of IDEs like vscode, intellj still doesn't support the integration, you can add this bash function into ~/.bashrc.

function aws_vault_save(){
  local profile_name="$1"
  local region="${2:-eu-west-1}"
  local temp_profile="${profile_name}_tmp"
 creds=$(aws-vault exec -j "${profile_name}")
@mohsen0
mohsen0 / squid.conf
Created April 28, 2021 08:32 — forked from hpcorona/squid.conf
simple squid3 configuration to allow all to connect to all
#Recommended minimum configuration:
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 0.0.0.0/8 192.168.100.0/24 192.168.101.0/24
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
@mohsen0
mohsen0 / hikari-pool.txt
Created April 1, 2021 14:07 — forked from nitishakalwadi/hikari-pool.txt
Spring Boot Hikari New Relic
1. Enable hikari mbean registry in application.properties
spring.datasource.hikari.register-mbeans=true
2. Add the new relic custom instrumentation yml file in the extensions directory where new relic agent is present
name: hikari-db
version: 1.0
enabled: true
jmx:
- object_name: com.zaxxer.hikari:type=Pool (SpringBootJPAHikariCP)
@mohsen0
mohsen0 / self-signed-certificate-with-custom-ca.md
Created February 4, 2021 09:18 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096

Keybase proof

I hereby claim:

  • I am mohsen0 on github.
  • I am mohsen0 (https://keybase.io/mohsen0) on keybase.
  • I have a public key ASBIAc1plKttBrp9Ld1XWQsMszQzSBlHfnpVUhTZDDujCQo

To claim this, I am signing this object:

@mohsen0
mohsen0 / download-var-log.md
Last active May 3, 2019 17:00
Ansible playbook to download /var/log

Ansible playbook to download /var/log

- name: Fetch /var/log
  hosts: all
  become: yes
  gather_facts: false
  tasks:
      - name: Find /var/log
 find:
@mohsen0
mohsen0 / remove-Image.sh
Created June 9, 2018 15:58
Removing an image from docker registry (Distribution)
#!/bin/bash -ex
registry=${1}
name=${2}
tag=${3}
curl -v -sSL -X DELETE "https://${registry}/v2/${name}/manifests/$(
curl -sSL -I \
-H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
@mohsen0
mohsen0 / Ansible.cfg
Created April 26, 2018 08:15
Ansible ssh connection through jump box with timeout set and sharing connection for the whole run
[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60m -o ControlPath=./%r@%h:%p -o ServerAliveInterval=60 -o ServerAliveCountMax=10 -o USER=centos -o ProxyCommand="ssh -o ControlMaster=auto -o ControlPersist=60s -o ServerAliveInterval=60 -o ServerAliveCountMax=10 -o ConnectTimeout=60 -q -W %h:%p centos@jump-box"
@mohsen0
mohsen0 / bash-python.md
Last active September 6, 2017 17:09
running bash interactively inside a python script
import subprocess
import os
pid=subprocess.Popen("env -i DOCKER_MACHINE_NAME=default" +
                         " TERM=xterm-256color " +
                         " DOCKER_TLS_VERIFY=1 " +
                         " DOCKER_HOST="+DOCKER_HOST +
                         " DOCKER_CERT_PATH=" + cert_path +
                         r" PS1=" + DOCKER_HOST +
 " bash -i", shell=True)