Skip to content

Instantly share code, notes, and snippets.

@sandipchitale
sandipchitale / gradle.properties
Last active December 30, 2024 00:42
Configure runIde task of JetBrains plugin gradle build to use locally installed IDE #jetbrains-plugin
# This file should be in ~/.gradle/gradle.properties
#
# In build.gradle.kt
# tasks {
# ...
# runIde {
# if (project.hasProperty("runIde_ideDir")) {
# ideDir = file("${project.extra["runIde_ideDir"]}")
# }
# }
runIde_ideDir=/home/sandipchitale/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate
@sandipchitale
sandipchitale / Search.java
Created December 26, 2024 21:24
Search in text area #search-in-java-swing-text-area
private void searchActionMap(String text, JTextArea textArea) {
if (text.isEmpty()) {
textArea.setCaretPosition(0);
} else {
int index = textArea.getText().toLowerCase().indexOf(text.toLowerCase(), textArea.getCaretPosition());
if (index == -1) {
// Try to wrap
index = textArea.getText().toLowerCase().indexOf(text.toLowerCase());
if (index == -1) {
@sandipchitale
sandipchitale / KeyEventCombinationTable.java
Last active December 14, 2024 11:09
KeyEventCombinationTable #KeyEventCombinationTable
import java.awt.event.KeyEvent;
import java.util.*;
public class KeyEventCombinationTable {
public static void main(String[] args) {
// Get all VK_ fields
List<String> vkFields = new ArrayList<>();
// List<String> asciiChars = new ArrayList<>();
// Collect VK_ fields
@sandipchitale
sandipchitale / ExpandableMenu.kt
Created December 4, 2024 10:43
Permanent main menu in JetBrains IDEs #jetbrains #IJPL-43725
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
@file:Suppress("ReplaceRangeToWithUntil")
package com.intellij.openapi.wm.impl.customFrameDecorations.header.toolbar
import com.intellij.ide.ProjectWindowCustomizerService
import com.intellij.openapi.actionSystem.impl.ActionMenu
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.util.SystemInfoRt
import com.intellij.openapi.util.registry.Registry
@sandipchitale
sandipchitale / NamesToDiff1Repository.java
Created October 17, 2024 05:29
Use ctid in spring data JPS repository #postgres #sringdatajpa
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import java.util.Optional;
public interface NamesToDiff1Repository extends CrudRepository<NamesToDiff1, Long> {
@Query(value = "SELECT ctid FROM names", nativeQuery = true)
Iterable<Object> findAllRowIds();
@Query(value = "SELECT * FROM names WHERE ctid = ?::tid", nativeQuery = true)
@sandipchitale
sandipchitale / URL.txt
Last active October 14, 2024 08:04
start.spring.io #start-spring-io
Sample url to load config:
https://start.spring.io/#!type=gradle-project&language=java&bootVersion=3.3.4&baseDir=demo&groupId=com.example&artifactId=demo&name=BABA&description=BUI%20project%20for%20Spring%20Boot&packageName=com.example.demo&packaging=jar&javaVersion=17&dependencies=web
https://start.spring.io/#!type=gradle-project
language=java
bootVersion=3.3.4
baseDir=demo
@sandipchitale
sandipchitale / linux.sh
Last active October 8, 2024 22:07
Netstat comand and output #netstat
> netstat -anpt46
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3200 0.0.0.0:* LISTEN 7430/java
tcp 0 0 127.0.0.1:52829 0.0.0.0:* LISTEN 2213/./jetbrains-to
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:27500 0.0.0.0:* LISTEN -
@sandipchitale
sandipchitale / FileTypes.md
Last active September 9, 2024 23:15
FileTypes in IntelliJ Ultimate #intellij

Class: com.intellij.openapi.fileTypes.impl.AbstractFileType Name: IDL Description: IDL Class: com.intellij.openapi.fileTypes.impl.AbstractFileType Name: JavaFX Description: JavaFX Class: com.intellij.openapi.fileTypes.impl.AbstractFileType Name: C++ Description: C/C++ Class: com.intellij.openapi.fileTypes.impl.AbstractFileType Name: C# Description: C# Class: com.intellij.openapi.fileTypes.impl.AbstractFileType Name: Perl Description: Perl Class: com.intellij.openapi.fileTypes.impl.AbstractFileType Name: AspectJ Description: AspectJ (syntax highlighting only) Class: com.intellij.openapi.fileTypes.impl.AbstractFileType Name: Haskell Description: Haskell Class: com.intellij.openapi.fileTypes.impl.AbstractFileType Name: PHP Description: PHP (syntax highlighting only) Class: com.intellij.ide.highlighter.ArchiveFileType Name: ARCHIVE Description: Archive Class: com.intellij.openapi.fileTypes.PlainTextFileType Name: PLAIN_TEXT Description: Text

@sandipchitale
sandipchitale / Kaitenzushi.java
Last active August 29, 2024 04:00
Kaitenzushi #facebook
public int getMaximumEatenDishCount(int N, int[] D, int K) {
// N must be less than D.length right?
if (N > D.length) {
throw new IllegalArgumentException("N must be less than or equal to D.length");
}
int count = 0;
// LRU cache to store the last K dishes
Map<Integer, Integer> lastK = new LinkedHashMap<Integer, Integer>(K, 0.75f, false) {
@Override