Skip to content

Instantly share code, notes, and snippets.

View sloppycoder's full-sized avatar
🎯
Focusing

Li Lin sloppycoder

🎯
Focusing
  • Singapore
View GitHub Profile
docker container prune --filter "until=8h" -f
docker network prune --filter "until=8h" -f
docker image prune --filter "until=8h" -f -a
# docker system prune
@sloppycoder
sloppycoder / gist:8b9b7abfb53921f6e293ece1488451d2
Created January 20, 2020 10:36
extract certifcate and key from openshift installation
# openshift installer by default uses a self-signed certificate for ingress controller
# in order to use the ingress we need to extract the certificate and add it to local
# trusted cert store to avoid warnings
oc get secret router-certs-default -n openshift-ingress -o json > secret.json
jq -r '.data."tls.key"' secret.json | base64 -d > private_key.pem
jq -r '.data."tls.crt"' secret.json | base64 -d > cert.pem
#the cert.pem file contains 2 certificate. the 1st one is used by the ingress controller, 2nd one is signer.
@sloppycoder
sloppycoder / gist:19b3f79bce57ff721294de55aa1decad
Last active January 11, 2020 06:33
start AWS instance by tag
#!/bin/bash
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export AWS_DEFAULT_REGION=ap-southeast1
if [ "$1" = "start" ]; then
CMD=start-instances
else
CMD=stop-instances
@sloppycoder
sloppycoder / gist:f20f9c030df2a8fcb506964f87c465cd
Last active January 27, 2020 04:16
large file parallel compression test
centos6 is a directory of a VirtualBox VM, size 8689088000
command for compression
time tar --use-compress-program=pbzip2|lzop -cf centos6_oracle11r2.tar.xxx centos6
time lzrtar centos6
command for decompresison
time pbzip2|bzip2|lzop -cd centos6_oracle11r2.tar.xxx | tar tvf -
time lrzip -o - -d centos6.tar.lrz | tar tvf -
# redirect port < 1024 to other ports so that server process can run as non-root
# localhost/loopback
sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 443 -j REDIRECT --to-ports 8443
# external
sudo iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 8443
@sloppycoder
sloppycoder / gist:e2c8e9cb442d4cfc5fc9b443f6f817b7
Last active August 26, 2017 16:11
Register EC2 instance public IP address with Route53
#!/usr/bin/env python
#
# EC2Instance must have an IAM role assign to it which has access to Route53 services
# in this script the role is called 'route53role'
#
from boto import utils, ec2, route53
instance_metadata = utils.get_instance_metadata(timeout=0.5, num_retries=1)