This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.sql.Sql | |
def dbUrl = "jdbc:postgresql://localhost/test-db" | |
def dbUser = "test" | |
def dbPassword = "test" | |
def dbDriver = "org.postgresql.Driver" | |
def sql = Sql.newInstance(dbUrl, dbUser, dbPassword, dbDriver) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grapes([ | |
@Grab(group='net.sf.jung', module='jung2', version='2.0.1'), | |
@Grab(group='net.sf.jung', module='jung-algorithms', version='2.0.1'), | |
@Grab(group='net.sf.jung', module='jung-visualization', version='2.0.1'), | |
@Grab(group='net.sf.jung', module='jung-graph-impl', version='2.0.1')]) | |
import java.awt.* | |
import javax.swing.* | |
import edu.uci.ics.jung.graph.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- http://frank.zinepal.com/unsign-a-jar-with-ant --> | |
<macrodef name="unsignjar"> | |
<attribute name="jar"/> | |
<sequential> | |
<!-- Remove any existing signatures from a JAR file. --> | |
<tempfile prefix="usignjar-" destdir="${java.io.tmpdir}" property="temp.file"/> | |
<echo message="Removing signatures from JAR: @{jar}"/> | |
<mkdir dir="${temp.file}"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.javacodegeeks.com/2013/02/increased-compile-time-safety-with-phantom-types.html | |
public interface Entity { | |
Long getId(); | |
} | |
public final class Ref<T extends Entity> implements Serializable { | |
public final long id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://docs.jboss.org/hibernate/core/3.3/api/org/hibernate/criterion/Restrictions.html#disjunction%28%29 | |
public static Criterion createInRestriction(String propertyName, Collection values) { | |
if (values.size() <= 1000) { | |
return Restrictions.in(propertyName, values); | |
} else { | |
List valueList = asList(values); | |
Disjunction disjunction = Restrictions.disjunction(); | |
int packSize = 1000; | |
for (int i = 0; i < values.size(); i += pack) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://msdn.microsoft.com/en-us/library/ms345103.aspx | |
SELECT o.name AS major_name, o.type_desc AS major_type_desc | |
, c.name AS minor_name, c.type_desc AS minor_type_desc | |
, at.assembly_class | |
FROM ( | |
SELECT object_id, name, user_type_id, 'SQL_COLUMN' AS type_desc | |
FROM sys.columns | |
UNION ALL | |
SELECT object_id, name, user_type_id, 'SQL_PROCEDURE_PARAMETER' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- create user | |
-- sqlcmd -S <ComputerName>\<InstanceName> -E -i mssql_user_setup.sql -v db=<DbName> -v user=<UserName> -v password=<Password> | |
use [$(db)]; | |
go | |
create schema $(user); | |
go | |
create login $(user) with PASSWORD = '$(password)'; | |
create user $(user) for login $(user) with DEFAULT_SCHEMA=$(user); | |
go | |
grant alter to $(user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#!/usr/bin/env groovy | |
/** | |
* Finding cycles in a directed graph | |
*/ | |
class CycleFinder { | |
// Zbiór wierzchołków w grafie | |
def V | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Object which is capable of writing itself | |
*/ | |
public interface Writable<WriterType> { | |
/* | |
* Writes this object to the given writer | |
*/ | |
WriterType writeTo(WriterType writer); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface DfsVisitor { | |
void preorder(v) | |
void postorder(v) | |
void beforeChild(v) | |
void afterChild(v) | |
void skipChild(v) |