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 / webpack_c9.sh
Created December 11, 2015 06:44
Running webpack on c9.io
webpack-dev-server --progress --colors --host $IP --port $PORT
@kdabir
kdabir / hsqltest.groovy
Last active August 21, 2019 19:53
Setting up hsqldb in groovy scripts
@GrabConfig(systemClassLoader=true) @Grab('org.hsqldb:hsqldb:2.2.9') import groovy.sql.Sql
def sql = Sql.newInstance("jdbc:hsqldb:mem:database", "sa", "", "org.hsqldb.jdbcDriver")
println sql.firstRow('VALUES (current_timestamp)')
@kdabir
kdabir / read_excel.groovy
Created February 22, 2012 13:51
Reading MS Excel file in groovy
def file_path = "C:/path/to/excel/file.xlsx"
def read_only = true
// Unfortunately this will work only on windows because of this driver :(
def connection_url= """jdbc:odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};
DBQ=$file_path;READONLY=$read_only"""
if (!new File(file_path).exists()) return "invalid file"
def sql = groovy.sql.Sql.newInstance(connection_url, '', '')
@kdabir
kdabir / empty_check.js
Created November 19, 2012 12:36
disable submit if text field is empty using javascript and jquery
var changeHandler = function (e) {
console.log ($.trim(this.value));
if ($.trim(this.value)){
$("input[type=submit]").removeAttr("disabled");
} else {
$("input[type=submit]").attr("disabled", "disabled");
}
};
$("input[type=text]").keyup(
@kdabir
kdabir / groovy.sublime-build
Last active May 22, 2019 09:24
Run groovy scripts from sublime-text
{
"cmd": ["groovy", "$file"],
"selector": "source.groovy",
"file_regex": "[ ]*at .+[(](.+):([0-9]+)[)]",
"windows": {
"shell": "cmd.exe"
}
}
@kdabir
kdabir / hsqldb.cmd
Created February 23, 2012 07:38
Windows cmd script to run HSQLDB server and client GUI
@echo off
REM set these variables
SET HSQLDB_HOME=c:\path\to\hsqldb
SET DB_NAME=mydb
REM start the server in new window ( prompt visible, so that you can CTRL+C )
REM database files are created in current directory/data
start java -cp %HSQLDB_HOME%\lib\hsqldb.jar org.hsqldb.server.Server --database.0 file:data/%DB_NAME% --dbname.0 %DB_NAME%
REM start the client GUI and connect to server ( no new cmd window opens because of javaw )
@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

@kdabir
kdabir / DecimalFormatExample.java
Created February 23, 2012 05:45
Using DecimalFormat in java/groovy
import java.text.DecimalFormat;
...
DecimalFormat df = new DecimalFormat("###,##0.00");
df.format(number);
// in the format string,
// # -> shows Digit if present else blank
// 0 -> shows Digit if present else 0
// details at : http://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html
@kdabir
kdabir / sort_map_by_value.groovy
Created May 7, 2012 13:48
Sort map by value in groovy
map.sort { a,b -> a.value <=> b.value }
@kdabir
kdabir / README.md
Last active November 20, 2017 08:26
Creating and Scheduling a TimerTask in groovy

Creating a TimerTask can not get easier than this thanks to groovy.

  • import java.util.timer.* is not required as java.util is already imported.
  • the run() is implemented as closure

To Run this:

groovy https://gist.github.com/kdabir/3176945/raw/timer_example.groovy