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 / README.md
Last active August 29, 2015 13:56
This script pulls your starred repos on github and shows some interesting stats at the end. It was created as an example demonstrating how Gstorm is useful in scripts.

This script is created as an example to show how easy it is to use gstorm to crunch and consume data from rest apis.

Usage

Either download the script and run:

groovy ghstarred.groovy <your_github_id>

Or hotload it:

@aalmiray
aalmiray / gist:f39cfe6d4053d5aeb86a
Last active August 29, 2015 14:04
gradle stats
$ gradle stats
:stats
+----------------------+-------+-------+
| Name | Files | LOC |
+----------------------+-------+-------+
| Groovy Sources | 4 | 28 |
| Java Sources | 1 | 2 |
| Groovy Test Sources | 1 | 16 |
| Models | 1 | 8 |
public abstract class DirWatcher extends TimerTask {
def path
def dir = [:]
// Exclude temp files created by vim, emacs, etc...
FileFilter fileFilter = {file -> !(file.name =~ /\.swp$|\~$|^\./)} as FileFilter
public DirWatcher(String path) {
this.path = path;
def files = new File(path).listFiles(fileFilter);
@glaforge
glaforge / gist:c44f439974b631a384e9
Created June 4, 2014 07:28
Super lean Grails 3.0 micro-services coming!
@Grab("com.h2database:h2:1.3.173")
import grails.persistence.*
@Entity
@Resource(uri='/books')
class Book {
String title
}
@dexterous
dexterous / grails-blog
Created February 28, 2011 08:02
minimum steps to create a Grails blog using simple-blog plugin (ignoring SCM commands)
$ grails create-app grails-blog
$ cd grails-blog
$ grails install-plugin simple-blog
$ cat >> grails-app/conf/Config.groovy
> grails.blog.author.evaluator = { request.remoteAddr }
> ^D
$ mkdir -p grails-app/domain/demo/blog/
$ cat > grails-app/domain/demo/blog/Commenter.groovy
> package demo.blog
>
@dexterous
dexterous / BooleanCategory.groovy
Created March 3, 2011 15:04
No more if's; SmallTalk style conditionals in Groovy
class BooleanCategory {
public static Boolean then(Boolean self, Closure c) {
if(self) c()
return self
}
public static Boolean otherwise(Boolean self, Closure c) {
if(!self) c()
return self
@musketyr
musketyr / build.gradle
Created April 1, 2011 20:49
How could be simply passed arguments to the Gradle build
task args
args.map = [:]
tasks.addRule("Pattern: <property>=<value>: Passes arguments to the scripts") { String taskName ->
def match = taskName =~ /(.*?)=(.*?$)/
if(match){
args.map[match[0][1]] = match[0][2]
task(taskName) << {
println "Used to pass value ${match[0][2]} to args.map.${match[0][1]}"
}
@dexterous
dexterous / OS.groovy
Created June 21, 2011 09:31
a not so quick script hacked together to scrape the product info from lenovo's product listing page
enum OS {
DOS('PC DOS 2000 License'), WIN('Genuine Windows 7 Professional 32');
private final String text
private OS(text) { this.text = text }
public static parseText(text) { OS.values().find { it.text == text } }
}
@musketyr
musketyr / GaelykBindingsSpec.groovy
Created July 7, 2011 15:42
Gaelyk Bindings Specification
package groovyx.gaelyk
import groovyx.gaelyk.logging.LoggerAccessor;
import spock.lang.Specification
import spock.lang.Unroll;
import com.google.appengine.api.LifecycleManager;
import com.google.appengine.api.NamespaceManager;
import com.google.appengine.api.backends.BackendService;
import com.google.appengine.api.blobstore.BlobstoreService;
@Evangenieur
Evangenieur / sinatra_all_inline.rb
Created September 17, 2011 10:11
All in one file with sinatra : SASS, CoffeeScript, HTML inline
require "sinatra"
require "slim"
require "coffee-script"
require "sass"
require "eventmachine"
get "/" do
slim :html
end