Skip to content

Instantly share code, notes, and snippets.

@myh-st
myh-st / tailc
Created May 22, 2019 03:51 — forked from liufuyang/tailc
Color output of linux tail command
#!/bin/bash
# save this file as tailc then
# run as: $ tailc logs/supplier-matching-worker.log Words_to_highlight
file=$1
if [[ -n "$2" ]]; then
color='
// {print "\033[37m" $0 "\033[39m"}
/(WARN|WARNING)/ {print "\033[1;33m" $0 "\033[0m"}
/(ERROR|CRIT)/ {print "\033[1;31m" $0 "\033[0m"}
@myh-st
myh-st / nginx.conf
Last active October 4, 2019 07:24 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
@myh-st
myh-st / opt1_template.j2
Created November 25, 2019 07:13 — forked from halberom/opt1_template.j2
ansible - example of template if else
{# style 1 - long form #}
{% if filepath == '/var/opt/tomcat_1' %}
{% set tomcat_value = tomcat_1_value %}
{% else %}
{% set tomcat_value = tomcat_2_value %}
{% endif %}
{# style 2 - short form #}
{% set tomcat_value = tomcat_1_value if (filepath == '/var/opt/tomcat_1') else tomcat_2_value %}
@myh-st
myh-st / mail_body.j2
Created January 7, 2020 10:23 — forked from halberom/mail_body.j2
ansible - example of using mail module to send one email for all hosts
# templates/mail_body.j2
{% for host in play_hosts %}
The {{ host }} says {{ hostvars[host]['result']['stdout'] }}
{% endfor %}
@myh-st
myh-st / bash.generate.random.alphanumeric.string.sh
Created August 18, 2020 03:19 — forked from earthgecko/bash.generate.random.alphanumeric.string.sh
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@myh-st
myh-st / centos_install_ngrok.sh
Created September 3, 2020 03:06 — forked from davidneelin/centos_install_ngrok.sh
a script that auto install ngrok in centos
#!/bin/bash
if [[ $# -lt 1 ]]; then
echo "usage: $0 domain"
exit 0
else
domain=$1
echo "domain is ${domain}"
fi
@myh-st
myh-st / gist:55995751003e056bac939b10952c774d
Created September 10, 2020 07:01 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@myh-st
myh-st / get_macs.yml
Created September 16, 2020 09:43 — forked from tbondarchuk/get_macs.yml
Ansible: Get mac addresses of all interfaces except local
---
- hosts: all
tasks:
- name: Get mac addresses of all interfaces except local
debug:
msg: "{{ ansible_interfaces | difference(['lo']) | map('regex_replace', '^(.*)$', 'ansible_\\1' ) | map('extract', hostvars[inventory_hostname], 'macaddress') | list }}"
@myh-st
myh-st / sshPemKey.md
Last active October 30, 2020 04:30 — forked from rxm/sshPemKey.md
Create an SSH key in PEM format

Create an SSH key in PEM format

I have not been able to use ssh-keygen -e to reliably generate a private key for SSH in PEM format. This format is sometimes used by commercial products. Instead, I had to convert the key using openssl.

# generate an RSA key of size 2048 bits
ssh-keygen -t rsa -b 2048 -f azure -C 'azure-dev'

# copy key to x.x.x.x and add to authorized_keys
@myh-st
myh-st / DellXPS15_9560_AHCI_RAID.md
Created March 8, 2021 12:05 — forked from chenxiaolong/DellXPS15_9560_AHCI_RAID.md
Switching between AHCI and RAID on the Dell XPS 15 (9560)

Switching between AHCI and RAID on the Dell XPS 15 (9560)

This guide likely applies to other models and, potentially, even laptops from other OEMs that have NVME drives. However, I've only tested this on my Dell XPS 15 (9560) with the OEM Windows installation from the Signature Edition model.

Switching from RAID to AHCI

Switching from RAID to AHCI is significantly simpler than switching from AHCI to RAID. All that's needed is a successful boot to Safe Mode.

  1. To set the default boot mode to Safe Mode, use msconfig.exe or open an admin cmd/PowerShell window and run: