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
@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]}"
}
@andrei-m
andrei-m / levenshtein.js
Last active October 9, 2024 10:36
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
/*
Copyright (c) 2011 Andrei Mackenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
@rahulsom
rahulsom / Directions.groovy
Created May 26, 2011 03:55
Demo to use Groovy, Grape, and Google Maps API to go from coast to coast
@groovy.lang.Grapes([
@groovy.lang.Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.5.0-RC2')
])
import groovyx.net.http.*
def http = new HTTPBuilder('https://maps.googleapis.com/maps/api/directions/')
http.get(path: 'json',
query: [
@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;
@kennym
kennym / blogspot_to_jekyll.rb
Created July 30, 2011 18:14
Migrate your blogger blog posts to jekyll.
#!/usr/bin/env ruby
#
# Convert blogger (blogspot) posts to jekyll posts
#
# Basic Usage
# -----------
#
# ./blogger_to_jekyll.rb feed_url
#
# where `feed_url` can have the following format:
@rtomayko
rtomayko / optparse-template.rb
Last active June 3, 2023 03:16
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt