Skip to content

Instantly share code, notes, and snippets.

@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 / script.py
Created September 18, 2019 12:07
Python script to check if Internet connectivity exists
import socket
import logging
try:
# see if we can resolve the host name -- tells us if there is
# a DNS listening
host = socket.gethostbyname('www.google.com')
# connect to the host -- tells us if the host is actually
# reachable
s = socket.create_connection((host, 80), 2)
@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 \
...