Skip to content

Instantly share code, notes, and snippets.

@ghsatpute
ghsatpute / .gitignore
Last active December 16, 2020 05:24
Kafka Notes
venv/**
.idea/**
@ghsatpute
ghsatpute / README.md
Last active August 31, 2020 15:37
Python mapping object to JSON

Python mapping object to json and vice versa

class School(object):
    def __init__(self, students: List[Student], online: bool):
        self.students: List[Student] = students
        self.online: bool = online

    def __repr_json__(self):
        return self.__dict__
@ghsatpute
ghsatpute / README.md
Last active March 20, 2024 07:16
Funny JavaScript

Funny JavaScript

> 0==-null
true
> 0==+null
true
> 0==null
false
@ghsatpute
ghsatpute / README.md
Created July 16, 2020 11:19
Serverless Deploy in Existing Stack

Serverless Deploy in Existing CloudFormation Stack

provider:
  name: aws
  region: us-west-2
  runtime: python3.6
  stage: ${opt:stage, 'dev'}
 vpc:
@ghsatpute
ghsatpute / README.md
Created June 21, 2020 14:55
AWS Command cheatsheet

IAM

Get MFA Token

$ aws --profile my-profile sts  get-session-token --serial-number arn:aws:iam::{account}:mfa/{user-id} --token-code {user-token}

CloudFormation

Deploy stack

 aws --profile my-profile-mfa cloudformation create-stack --stack-name \
@ghsatpute
ghsatpute / README.md
Created June 16, 2020 13:35
Spring Profiles via Maven

While building the package set the profile

 $ mvn -Pdev clean install

When the jar is built you can simply run by

$ java -jar target/<your jar name>.jar

You'll see output as below

@ghsatpute
ghsatpute / README.md
Created May 17, 2020 11:46
Counting all the lines in current directory recursively

Below command recursively counts number of lines in current directory. It excludes certain directories such as ./target/, ./.idea/, etc.

find . ! -path "./target/*" ! -path "./.mvn/*" ! -path "./.idea/*" -name "*" |  xargs wc -l
@ghsatpute
ghsatpute / Mapper.java
Created May 15, 2020 18:39
Spring Boot Mapper Example
...
import ma.glasnost.orika.CustomMapper;
import ma.glasnost.orika.Mapper;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.MappingContext;
import ma.glasnost.orika.impl.ConfigurableMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@ghsatpute
ghsatpute / README.md
Created April 24, 2020 17:04
IntelliJ Plugin: Exact file type matcher

While writing IntelliJ Idea Plugin how to map the exact file name.

For example, you want to write a plugin for files exactly named abc.json, or in more practical scenarios Jenkinsfile

  1. Write FileMatcherType class
 class MyFileType extends LanguageFileTyp {
    public static final MyFileType INSTANCE = new MyFileType();

    private MyFileType() {
        super(MyLanguage.INSTANCE);
    }
@ghsatpute
ghsatpute / Readme.md
Last active February 5, 2021 16:24
Create Github PR Jobs on Jenkins

Steps to configure PR jobs on Jenkins This job will run every time someone creates a pull request on your Github repository

  1. On Jenkins 
    1. Install Jenkins PR Plugin https://plugins.jenkins.io/ghprb/
    2. Create a freestyle project 
    3. Add Github project link
    4. In Source code management > branch specifier add ${ghprbActualCommit}
    5. Click on advance and add Refspec as "+refs/pull/:refs/remotes/origin/pr/" (because we want to run only for PRs)
    6. In Triggers, select "Github Pull Request Builder"