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 / install_capedwarf.sh
Created April 8, 2014 18:09
One liner installation for CapeDwarf. Execute it, let it complete and open a new terminal and run with capedwarf.sh. It takes care of path by itself.
curl -L http://git.io/nixstall | bash -s get http://download.jboss.org/capedwarf/CapeDwarf_WildFly_2.0.0.CR1.zip
@kdabir
kdabir / mongoToCsv.sh
Created May 13, 2014 14:26
Export data from mongo as csv for simple documents
mongoexport --csv -d <db_name> -c <collection> -f <field1,field2,nested.field>
@kdabir
kdabir / dyna_methods.groovy
Created May 27, 2014 23:52
adding dynamic methdos dynamically to a class
class Person {
def name
}
def add(s){ Person.metaClass."$s" = {-> println "hello"; return delegate} }
add("a")
add("b")
new Person().a().b()
@kdabir
kdabir / password.groovy
Created June 4, 2014 06:02
Password generator in groovy...though not as elegant as I would like it to be
(('A'..'Z') + ('a'..'z') + ('0'..'9')).with { Collections.shuffle(it);it }.take(8).join()
@kdabir
kdabir / dir_for_years.groovy
Created June 29, 2014 14:20
indian financial year groups
(2006..2014).collate(2,1, false).collect{ it.join("-")}.each {
new File(parent, it).mkdir()
}
// [2006-2007, 2007-2008, 2008-2009, 2009-2010, 2010-2011, 2011-2012, 2012-2013, 2013-2014]
@kdabir
kdabir / now.rb
Created July 8, 2014 06:40
ruby - current time in ts format
now = Time.now.strftime("%Y%m%d_%H%M%S")
# => "20140708_120932"
@kdabir
kdabir / xml_slurper_path.groovy
Created July 11, 2014 07:55
groovy xml slurpers accesing nested nodes
def root = new XmlSlurper().parseText """
<root>
<a>
<b>b1</b>
<b>b2</b>
</a>
<a>
<b>b3</b>
<b>b4</b>
def slurp(url) {new groovy.json.JsonSlurper().parse(url.toURL())}
def slurpText(text) {new groovy.json.JsonSlurper().parseText(text)}
@kdabir
kdabir / glide.gradle
Last active August 29, 2015 14:04
Minimal config for running glide apps on c9.io
appengine {
httpAddress = System.env["IP"]?:"0.0.0.0"
httpPort = Integer.parseInt(System.env["PORT"]?:"8080")
}
@kdabir
kdabir / chain.groovy
Last active August 29, 2015 14:04
Getting rid of "it"
["Groovy", "is", "Awesome"]*.with {[len: length(), down:toLowerCase()]}*.with { "'$down' is $len char long"}