Skip to content

Instantly share code, notes, and snippets.

View haeramkeem's full-sized avatar

@haeramkeem haeramkeem

View GitHub Profile
#!/bin/bash
# Change UI mode for Ubuntu 20.04
# Ref: https://superuser.com/a/1139020
# When you want to use GUI X.Org
sudo telinit 5
# When you want to use console
sudo telinit 3
#!/bin/bash
# To get 'com' from 'maps.google.com' -> parse string to get last field using delimiter
# Ref: https://stackoverflow.com/a/48032204
echo 'maps.google.com' | awk -F. '{print $NF}'
# or
awk -F. '{print $NF}' <<< 'maps.google.com'
@haeramkeem
haeramkeem / pip_locale_error.sh
Created May 8, 2022 07:12
PIP3 locale.Error
#!/bin/bash
# Ref: https://stackoverflow.com/a/36394262
echo "export LC_ALL=C" >> ~/.bashrc
source ~/.bashrc
#!/bin/bash
# Ref: https://linux.die.net/man/1/dig
# Get IP of the DNS only
dig www.google.com +short
@haeramkeem
haeramkeem / inquire_systemd_log.sh
Created May 11, 2022 05:51
systemd service log
#!/bin/bash
# Ref: https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs
# Set timezone
# Get available timezone:
# $ timedatectl list-timezones
sudo timedatectl set-timezone Asia/Seoul
# View logs
@haeramkeem
haeramkeem / docker-prune.sh
Last active October 21, 2022 21:03
how to resolve 'ERROR: readlink /var/lib/docker/overlay2: invalid argument'
#!/bin/bash
# Dealing with error: 'ERROR: readlink /var/lib/docker/overlay2: invalid argument'
# In kubernetes or docker
# Have to clear the docker cache
# docker prune will tidy the unused container, images, cache, etc.
docker system prune --all
docker volume prune
@haeramkeem
haeramkeem / bgp_peering_calicoctl_birdc.sh
Created May 18, 2022 05:51
BGP peering - calicoctl birdc commend example
#!/bin/bash
# Show BGP peering establishment status
sudo calico node status
kubectl describe blockaffinities | grep -E "Name:|Cidr:"
sudo birdc show protocols
sudo birdc show route protocol bgp2
@haeramkeem
haeramkeem / ruby-strconv.rb
Created May 22, 2022 09:52
Ruby basic grammar & strconv function
def convert(input)
# Trim string
# @see https://stackoverflow.com/a/1000975
input.strip! || input
# Reverse string
# '!' means modify the value in place
input.reverse!
# To uppercase string
@haeramkeem
haeramkeem / jest-throw-error-test.js
Created May 22, 2022 14:33
Test error with jest
test("Expect error for normal function", () => {
expect(() => {
someAsyncFunction();
}).toThrowError('Error message'));
});
test("Expect error for async function", async () => {
async expect(async () => {
await someAsyncFunction();
}).rejects.toThrowError('Error message'));
@haeramkeem
haeramkeem / sshd-no-hostkeys-available.sh
Created May 23, 2022 01:46
sshd: no hostkeys available -- exited
#!/bin/bash
sudo ssh-keygen -A