Skip to content

Instantly share code, notes, and snippets.

View kasunbg's full-sized avatar
🐶

Kasun Gajasinghe kasunbg

🐶
View GitHub Profile
@kasunbg
kasunbg / CloudformationStackDeleter.java
Created September 25, 2019 09:44
This class finds CREATE_COMPLETE stacks that are more than five days old, and output a aws cloudformation delete command to stdout. This simply outputs the result, no actual stacks will be deleted.
package org.sample;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
@kasunbg
kasunbg / my-app-ingress.yaml
Last active June 28, 2019 14:10
Ingress kubernetes resource to expose your HTTPS application
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-app-ingress
namespace: YOUR-OPTIONAL-NAMESPACE
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" # the annotation that made this all possible
spec:
tls:
@kasunbg
kasunbg / SSL-certs-OSX.md
Created June 15, 2019 11:12 — forked from croxton/SSL-certs-OSX.md
Generate ssl certificates with Subject Alt Names

Generate ssl certificates with Subject Alt Names on OSX

Open ssl.conf in a text editor.

Edit the domain(s) listed under the [alt_names] section so that they match the local domain name you want to use for your project, e.g.

DNS.1   = my-project.dev

Additional FQDNs can be added if required:

import requests
import sys
import os
PLUGIN = 'credentials'
BACKDIR_COUNT = 10
if len(sys.argv) != 3:
print 'usage:\n\tpython CVE-2018-1999002.py [jenkins base url] [absolute file path]'
print ''
@kasunbg
kasunbg / run-gui-apps-from-a-different-user.md
Created April 23, 2019 13:37
How to run a GUI application as a different user?

How to run a GUI application as a different user:

Suppose you are logged into your Linux box as user1 using some X window system already (with GNOME/Unity/..). Now you want to run some gui app as another user, user2.

Run:

  1. xhost + - Run as the user1. This enables access to user1's X window system from other users. You should see following output: 'access control disabled, clients can connect from any host'
  2. sudo su - user2 - Using your favorite terminal, log-in to second user.
  3. export DISPLAY=:0.0 - optional for some apps.
@kasunbg
kasunbg / README.md
Created April 3, 2019 07:41
Create AWS IAM user via CLI

Usually, you need to run following four commands to create a user.

#!/bin/bash
# create bare user 
aws iam create-user --user-name <user> --tags Key=Creator,Value=kasung

# enable aws console access
aws iam create-login-profile --user-name  --password  --password-reset-required
@kasunbg
kasunbg / delete-k8s-namespaces.sh
Created March 22, 2019 03:13
Delete k8s namespaces that are more than one day old
#!/bin/bash
kubectl get namespaces | sort -n -k3 | grep "kubernetes-namespace.*d$" | awk '{print $1}' | xargs kubectl delete namespaces
# Instructions and command outputs when running helm install for apim-analytics
# Repo: https://github.com/wso2/kubernetes-apim/tree/master/helm/pattern-1
kasun@gaje:~/k8s/kubernetes-apim/helm/pattern-1$ helm install --name wso2apim-with-analytics-rdbms-service -f mysql/values.yaml stable/mysql --namespace wso2
NAME: wso2apim-with-analytics-rdbms-service
LAST DEPLOYED: Sat Feb 23 11:30:01 2019
NAMESPACE: wso2
STATUS: DEPLOYED
RESOURCES:
==> v1/Secret
@kasunbg
kasunbg / delete-unused-security-groups.sh
Created January 11, 2019 12:36
Delete unused AWS security groups
comm -23 <(aws ec2 describe-security-groups --query 'SecurityGroups[*].GroupId' --output text | tr '\t' '\n'| sort) \
<(aws ec2 describe-instances --query 'Reservations[*].Instances[*].SecurityGroups[*].GroupId' --output text | tr '\t' '\n' | sort | uniq) \
| tee -a unused-security-groups-in-ec2.txt
for x in `cat unused-security-groups-in-ec2.txt`; do echo 'deleting sg: $x' ; aws ec2 delete-security-group --group-id $x; done
@kasunbg
kasunbg / 1.this.is.a.xml
Last active November 30, 2021 20:30
Write valid YAML without indentation by using curly-braces. See 3.this.is.a.valid.explicit.yaml
<Colors>
<Red>FF0000</Red>
<Blue>0000FF</Blue>
<Green>008000</Green>
</Colors>