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 / replace_quotes.groovy
Created September 22, 2012 14:35
Replace quotes from string in groovy
println """
some "text" with quotes
""".replaceAll (/\"/,/\\\"/)
@kdabir
kdabir / build.gradle
Created February 29, 2016 13:18
simple groovy project starter
plugins {
id 'groovy'
}
repositories {
jcenter()
}
dependencies {
compile "org.codehaus.groovy:groovy-all:2.4.6"
@kdabir
kdabir / README.md
Created August 27, 2012 14:07
Calculate space wasted because of duplicate files

Calculate the space wasted by duplicate files on your Hard Drive

Sometimes (rather always), duplicate files eat up space on hardrive. If you want to compute the total space wasted by such duplicate files this utility script may come handy. fdupes is a nice utility that finds the duplicate files in the given directories. This script consumes the fdupes output and calculates the space wasted.

These steps assume *nix flavor OS (OS X/Linux) but this might work on Windows+Cygwin as well

  1. Install fdupes on your machine (verify by doing fdupes --version on Terminal)
@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(':')
}
import groovy.json.JsonSlurper
def json = new JsonSlurper().parseText("""
{
inline: "json"
}
""")

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:

@kdabir
kdabir / html_markup.groovy
Last active September 15, 2020 05:15
Using MarkupBuilder to generate html markup in groovy
// MarkupBuilder is a lot cleaner way of generating valid xml/html markup
// than writing tags as string and forgetting to close one ;)
def writer = new StringWriter() // html is written here by markup builder
def markup = new groovy.xml.MarkupBuilder(writer) // the builder
markup.html{
table {
tr {
td(class:"row", "hello world!")
@kdabir
kdabir / check_proxy.groovy
Created February 22, 2012 12:36
Setting proxy in groovy
println System.properties.grep ({it.key.contains("proxy")})
// print all system properties
// System.properties.each {k,v-> println "$k=$v"}
@kdabir
kdabir / grape_behind_proxy.cmd
Created March 15, 2012 10:41
Install a library with Groovy Grape when behind a proxy
grape -Dhttp.proxyHost=proxy.corp.com -Dhttp.proxyPort=8080 install org.seleniumhq.selenium selenium-firefox-driver 2.15.0
@kdabir
kdabir / latest_version.groovy
Created April 2, 2016 14:17
Getting latest version of artifact from maven repository
def metadata = new XmlSlurper().parse("https://dl.bintray.com/kdabir/glide/io/github/kdabir/glide/glide-gradle-plugin/maven-metadata.xml")
println metadata.versioning.latest
println metadata.versioning.versions.version*.text()