Skip to content

Instantly share code, notes, and snippets.

View nipunthathsara's full-sized avatar

Nipun Thathsara nipunthathsara

View GitHub Profile
@nipunthathsara
nipunthathsara / Resignation_email_template.txt
Created June 21, 2023 17:37
Resignation email template
Hi <RECIPIENT'S_NAME>,
I am writing this to formally inform the resignation from my current position at <COMPANY_NAME>. After careful consideration and reflection, I have decided that it is time for me to move on to new opportunities and challenges in my career. Accordingly, my last working day would be <DATE> and I will do my best to tie up any loose ends and ensure a seamless transition of my responsibilities before then.
I want to express my sincere gratitude for the opportunities I have had during my time at <COMPANY_NAME>. Working with such a talented and dedicated team has been a valuable experience, and I am truly grateful for the support and guidance I have received throughout my tenure. And I will cherish the memories and lessons learned.
Please let me know if there are any exit procedures or formalities that I need to complete before my departure. I am more than willing to fulfill any requirements necessary to ensure a smooth exit.
Thank you for your understanding. I wish the <COMPANY_NAME> team
@nipunthathsara
nipunthathsara / dynamic-grep.sh
Created November 3, 2022 21:26
Dynamic input grep script
#!/bin/bash
input=input
ii=0
jj=0
counter=0
for IN in `cat $input`; do
# echo $IN
if [ $counter == 0 ]
then
@nipunthathsara
nipunthathsara / BeansExample.java
Created October 14, 2022 20:36
Access beans from static context
private static CryptoProperties cryptoProperties;
@Autowired
public CsrUtils(ApplicationContext applicationContext) {
cryptoProperties = applicationContext.getBean(CryptoProperties.class);
}
public static KeyPair generateKeyPair() {
...
@nipunthathsara
nipunthathsara / openssl.sh
Created September 19, 2022 19:35
OpenSSL commands
# Generate new RSA private key with genpkey.
genpkey -algorithm RSA -out private.key -pass pass:ggg -pkeyopt rsa_keygen_bits:4096 -outform PEM
# Generate new RSA private key with genrsa.
genrsa -out private.key -passout pass:gg 4096
# Read private key details
# '-noout' omits the ENCODED output getting printed in the result.
rsa -text -in private.key -noout
# Or
@nipunthathsara
nipunthathsara / genesis-lms-1-0-0.yml
Created August 26, 2022 22:52
Genesis User Management ReST API contract - OAS3.0
openapi: 3.0.0
servers:
# Added by API Auto Mocking Plugin
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/nipunthathsara/genesis-lms/1.0.0
info:
description: Genesis User Management ReSTful APIs
version: "1.0.0"
title: Genesis User Management ReSTful APIs
contact:
@nipunthathsara
nipunthathsara / extract-keys.sh
Created July 27, 2022 12:43
Extract private/public keys from JKS
# Step 1
# Convert JKS to PKCS12
keytool -importkeystore -srckeystore <SRC_KEYSTORE.JKS> -srcstorepass <SRC_KEYSTORE_PASSWORD> -srckeypass <SRC_KEY_PASSWORD> -srcalias <SRC_KEY_ALIAS> -destalias <DST_KEY_ALIAS> -destkeystore temp.p12 -deststoretype PKCS12 -deststorepass <DST_STORE_PASSWORD> -destkeypass <DST_STORE_PASSWORD>
# <DST_STORE_PASSWORD> <DST_STORE_PASSWORD> Should be the same for PKCS12 keystore type.
# Step 2
# Extract private key
openssl pkcs12 -in temp.p12 -nodes -nocerts -out private_key.pem
# Step 3
@nipunthathsara
nipunthathsara / XssController.java
Created June 27, 2022 23:20
Medium XSS - Controller class and HTML page
@Controller
public class XssController {
@PostMapping("/home")
public String home(@RequestParam(name="string", required=false, defaultValue="World") String name, Model model) {
model.addAttribute("xss", name);
return "index";
}
}
@nipunthathsara
nipunthathsara / SqliModel.java
Created June 20, 2022 21:37
Medium SQLI - Fixed model class
@Component
public class SqliModel {
@Autowired
private JdbcTemplate jdbcTemplate;
public List<Page> getPage(String pageId) {
String sql = "SELECT pageId, title, content FROM pages WHERE pageId=?";
List<Page> pages = jdbcTemplate.query(
sql,
@nipunthathsara
nipunthathsara / SqliController.java
Last active June 20, 2022 18:38
Medium SQLI - COntroller class
@Controller
public class SqliController {
@Autowired
private SqliModel sqliModel;
@GetMapping("/home/{id}")
public String home(@PathVariable String id, Model model) {
List<Page> pages = sqliModel.getPage(id);
model.addAttribute("page", pages.get(0));
return "index";
@nipunthathsara
nipunthathsara / faq-commands.sh
Last active May 18, 2022 12:17
Usefull commands
# Write effective pom into a new file.
mvn help:effective-pom -Doutput=effective-pom-result.xml
# Dependency tree
mvn dependency:tree