Skip to content

Instantly share code, notes, and snippets.

@ghsatpute
ghsatpute / README.md
Created January 10, 2023 17:46
Sheets Currency Format for Indian Rupees

Google Sheets Custom Format for Showing Indian Rupees Properly

  1. Go to Format > Number > Custom Currency
  2. And enter below format
    [>9999999][$₹]##\,##\,##\,##0.00;[>99999][$₹]##\,##\,##0.00;[$₹]##,##0.00
    
@ghsatpute
ghsatpute / README.md
Created November 17, 2022 09:21
Disabling security configurations in SpringBoot JUnit5 tests with custom AuthValidator
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.freshworks.marketplace.installation.entity.InstalledExtensionEntity;
import com.freshworks.marketplace.installation.repository.InstalledExtensionRepository;
import com.freshworks.marketplace.installation.repository.InstalledExtensionStateRepository;
import com.freshworks.marketplace.installation.service.InstallationService;
@ghsatpute
ghsatpute / README.md
Created July 9, 2022 19:20
Use two different accounts on Github CLI

~/.gitconfig

[filter "lfs"]
        clean = git-lfs clean -- %f
        smudge = git-lfs smudge -- %f
        process = git-lfs filter-process
        required = true
[user]
        name = Ganesh Satpute
 email = your-email@company.com
@ghsatpute
ghsatpute / README.md
Created July 6, 2022 06:39
How to parse logs from CloudWatch Logs Insights

How to parse logs from CloudWatch Logs Insights

fields @timestamp, @message
| filter @message like 'Request executed successfully'
# {"context":{"accountId":"781754","appId":"7656","msg":"Request executed successfully","timestamp":"2022-07-06 06:32:23.552","uuid":"a16e8644-ebae-4d2d-a58c-246ecb39adbb"}
| parse @message '*accountId":"*","appId":"*",*' as prefix, accountId, appId, postFix
| sort @timestamp desc
| stats count(*) by accountId
@ghsatpute
ghsatpute / README.md
Last active February 2, 2022 08:15
How to log MySQL output to file

Approach 1: Redirect MySQL command line output to file

If your query output is too long, this is easy way to log to a file

  1. Open MySQL REPL
  2. On command prompt enter
    mysql> tee log.out
    Logging to file 'log.out'
    
@ghsatpute
ghsatpute / README.md
Last active April 7, 2021 11:13
Spring Security: Resource Server

Spring Security: Resource Server

Add these dependencies in your pom.xml

        <!-- Security -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
@ghsatpute
ghsatpute / README.md
Created February 11, 2021 13:24
How to run Docker commands inside a container ran by Jenkins Pipeline

How to run Docker commands inside a container ran by Jenkins Pipeline

First, in your base image install Docker

FROM ubuntu:latest
... 

RUN apt-get update \
     && apt-get install -y docker.io \
... 
@ghsatpute
ghsatpute / README.md
Created February 5, 2021 11:40
Read Secret Values from Jenkins

Go to "Manage Jenkins" > "Scripts Console" and run below command.

def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
      com.cloudbees.plugins.credentials.Credentials.class
)
for (c in creds) {
  println(c.id)
  if (c.properties.username) {
    println("   description: " + c.description)
 }
@ghsatpute
ghsatpute / README.md
Last active February 2, 2021 07:25
Enable PR decoration on Sonar Community
  1. Install Sonar
  2. Install Community Branch Plugin
    1. Figure out compatible version of plugin with your installed sonar version
    2. Copy plugin URL from the release page
    3. Run below command at two directories /opt/sonarqube/lib/common and /opt/sonarqube/extensions/plugin (assuming your sonarqube is installed at /opt/sonarqube) wget <pluging release URL> e.g. wget https://github.com/mc1arke/sonarqube-community-branch-plugin/releases/tag/1.3.2
  3. Restart sonar server