Skip to content

Instantly share code, notes, and snippets.

Avatar

Dinuka Arseculeratne dinukadev

View GitHub Profile
View PascalsTriangle.scala
object PascalsTriangle extends App {
/**
* 1
* 1 1
* 1 2 1
* 1 3 3 1
* 1 4 6 4 1
*
*/
View Exceptionhandler
@ControllerAdvice(annotations = RestController.class)
public class ExceptionHandlerAdvice {
@ExceptionHandler(InvalidDataException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<String> handleInvalidDataExceptions(InvalidDataException e) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_PLAIN);
return new ResponseEntity<>(e.getMessage(), headers, HttpStatus.BAD_REQUEST);
}
@dinukadev
dinukadev / IAM Role based Service Account Creation
Created May 19, 2020
A script to create an IAM role with full S3 access linked to a service account in Kubernetes
View IAM Role based Service Account Creation
#!/bin/bash
CLUSTER_NAME=`eksctl get cluster --region ap-southeast-2 -o json | jq -r '.[0].name'`
ISSUER_URL=$(aws eks describe-cluster \
--name $CLUSTER_NAME \
--query cluster.identity.oidc.issuer \
--output text \
--region ap-southeast-2)
ISSUER_HOSTPATH=$(echo $ISSUER_URL | cut -f 3- -d'/')
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
@dinukadev
dinukadev / jenkins_build_jenkinsfile
Last active Nov 13, 2019
Jenkins build plan pipeline
View jenkins_build_jenkinsfile
node {
def mvnHome
env.JAVA_HOME="${tool 'JDK12'}"
env.MAVEN_HOME="${tool 'M3'}"
env.PATH="${env.JAVA_HOME}/bin:${env.MAVEN_HOME}/bin:${env.PATH}"
stage('Checkout source') {
git(
url: "${repo}",
credentialsId: "${GithubCredentialsId}",