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
@kdabir
kdabir / m2g.groovy
Created September 19, 2021 02:56
Convert Maven dependency to Gradle
#!/usr/bin/env groovy
if (System.in.available()) {
println new groovy.xml.XmlSlurper()
.parse(System.in)
.with {[groupId, artifactId, version, classifier]}
*.text()
.findAll()
.join(':')
}

Keybase proof

I hereby claim:

  • I am kdabir on github.
  • I am kdabir (https://keybase.io/kdabir) on keybase.
  • I have a public key whose fingerprint is 69CC 79FF A8F6 8B18 85E6 2610 D073 3D5F B7CD 257B

To claim this, I am signing this object:

#language: groovy
#sudo: true
before_script:
- export GROOVY_VERSION=2.4.5
- wget http://dl.bintray.com/groovy/maven/apache-groovy-binary-$GROOVY_VERSION.zip -O /tmp/groovy.zip
- unzip /tmp/groovy.zip -d $PWD/.groovy
- export PATH=$PATH:$PWD/.groovy/groovy-$GROOVY_VERSION/bin
- echo "groovy installed"
@kdabir
kdabir / README.md
Last active March 7, 2018 14:50
TattleTale Gradle

TattleTale Gradle plugin

Add to build.gradle

apply from:'https://gist.githubusercontent.com/kdabir/0dbf62e16e5af8ef55b43442148f0fe5/raw/depTree.gradle'

And Run

$ gradle tattletaleReport

def out = new File("application.properties")
new File('webapp/WEB-INF/conf').eachFile { file ->
new File(file, "app.properties").text.eachLine { line ->
if (!line.trim().startsWith("#")){
out << "${file.name}.${line}"
}else {
out << "${line}"
}
out << "\n"
class Servlet {
String name, fqcn
List patterns = []
def getPatternsStr() {
patterns.collect { /"$it"/ }.join(", ")
}
}
def web = new XmlSlurper().parse(new File('webapp/WEB-INF/web.xml'))
@kdabir
kdabir / GenericMap.java
Created October 13, 2016 12:28
Boilerplate function for mapping a list to another using stream API internally. Note that this defeats the purpose of streams, which are lazy and combine operations together. Use it only for one level of mapping where logic is not piped and results need to be immediately realized.
static <T, R> List<R> map(List<T> list, Function<? super T, ? extends R> mapper) {
return list.stream().map(mapper).collect(Collectors.toList());
}
@kdabir
kdabir / valid_base64_chars.txt
Last active August 27, 2016 09:21
valid base64 chars
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
@kdabir
kdabir / ratpack.groovy
Created August 19, 2016 06:15
Minimal ratpack, runnable and reloadable in GroovyConsole
@Grapes([
@Grab('io.ratpack:ratpack-groovy:1.4.0'),
@Grab('org.slf4j:slf4j-simple:1.7.21')
])
import static ratpack.groovy.Groovy.ratpack
ratpack {
handlers {
get {
render "Hello World!"
@kdabir
kdabir / .gitignore
Created August 11, 2016 03:25
Ignores for java, IDEs and gradle
###### OSX ######
.DS_Store
###### Java ######
*.class
# Artifacts
*.jar
*.war
# virtual machine crash logs
hs_err_pid*