Skip to content

Instantly share code, notes, and snippets.

View kdabir's full-sized avatar
👨‍💻
go git it

Kunal Dabir kdabir

👨‍💻
go git it
View GitHub Profile
@jherax
jherax / is-private-mode.js
Last active February 14, 2025 11:03
Detect if the browser is running in Private mode - Promise based (last update: Feb 2020)
/**
* Lightweight script to detect whether the browser is running in Private mode.
* @returns {Promise<boolean>}
*
* Live demo:
* @see https://output.jsbin.com/tazuwif
*
* This snippet uses Promises. If you want to run it in old browsers, polyfill it:
* @see https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js
*
@brunnels
brunnels / DeviceDataRepository.java
Last active November 30, 2024 12:57
Generic REST Query Language with RSQL for Spring Data JPA
package org.kraven.repository;
import org.kraven.domain.DeviceData;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* Spring Data JPA repository for the DeviceData entity.
*/
@SuppressWarnings("unused")
public interface DeviceDataRepository extends JpaRepository<DeviceData,Long>, JpaSpecificationExecutor<DeviceData> {
@idleberg
idleberg / sublime-text-macos-context-menu.md
Last active April 28, 2025 22:55 — forked from vincentmac/sublime-text-osx-context-menu.md
“Open in Sublime Text” in macOS context-menu

This list has been updated for Big Sur (and later). Since I don't use these versions, this guide might still need further improvements. For older macOS versions, please see this older revision.

Open in Sublime Text

  • Open Automator
  • Quick Action
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n "$@"
  • Set “Pass input” to as arguments
@vkorobkov
vkorobkov / ThreadSafeSql.groovy
Last active April 17, 2019 11:42
Thread-safe singleton version of groovy.sql.Sql
import groovy.sql.Sql
import javax.sql.DataSource
class ThreadSafeSql extends Sql implements GroovyInterceptable {
private final ThreadLocal<Sql> threadLocal = new ThreadLocal<>()
private final DataSource dataSource
ThreadSafeSql(DataSource dataSource) {
super(dataSource)
this.dataSource = dataSource
@topriddy
topriddy / README.md
Created September 10, 2016 11:44
Steps for Integrating Jacoco in IntelliJ IDEA
  1. Integrate the dependency and plugin sections to relevant parts in your pom.xml from the pom.xml_fragment file below.
  2. Run "mvn clean package" to generate the results
  3. In IntelliJ, Select "Analyse -> Show Coverage Data..." and pick your Jacoco output file. This should be the path specified in the plug-in config i.e: ${basedir}/target/coverage-reports/jacoco-unit.exec

Output should be displayed in the IDE and you should also have the classes overlayed with test coverage.

@knjname
knjname / GrabLoadExternalRepo.groovy
Created August 31, 2016 02:19
A groovy grab example that imports dependencies from an external repository.
@GrabResolver(name = 'jitpack.io', root = 'https://jitpack.io')
@Grab('com.github.baloise:rocket-chat-rest-client:master-8a410650b3-1')
import com.github.baloise.rocketchatrestclient.*
import com.github.baloise.rocketchatrestclient.model.*
@kdabir
kdabir / heredoc_json.bash
Last active January 11, 2024 02:25
json in heredoc in bash script alongwith variable substitution
_BUCKET_NAME="foo.example.com"
_POLICY=$(cat <<EOT
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadForGetBucketObjects",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
@thegitfather
thegitfather / vanilla-js-cheatsheet.md
Last active May 20, 2025 11:56
Vanilla JavaScript Quick Reference / Cheatsheet
import groovy.transform.CompileStatic
@CompileStatic
void swap(int[] a, int i, int j) {
int temp = a[i]
a[i] = a[j]
a[j] = temp
}
@CompileStatic
@olih
olih / jq-cheetsheet.md
Last active June 25, 2025 09:28
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq