Skip to content

Instantly share code, notes, and snippets.

View mariodavid's full-sized avatar

Mario David mariodavid

View GitHub Profile
@mariodavid
mariodavid / groovy-closures.groovy
Last active September 12, 2018 11:56
Groovy Closures with exceptions and return values
import groovy.transform.InheritConstructors
def doIt(Closure whatToDo) {
println "hello in doIt"
def optionalResult = whatToDo.call()
println "after done it"
optionalResult
}
@mariodavid
mariodavid / index.jsp
Last active February 15, 2020 16:16
CUBA platform portal: activate JSP support
<%
/* this file is located at %CUBA_APP_ROOT%/portal/web/WEB-INF/pages/index.jsp */
%>
<html>
<head><title>First JSP</title></head>
<body>
<%
double num = Math.random();
if (num > 0.95) {
%>
@mariodavid
mariodavid / CustomerCreation.feature
Last active August 29, 2015 14:13
Customer Creation Scenario in Cucumber
Scenario: A valid customer with a delivery address will be created correctly
Given: I am logged in as 'Martin, the Sales Guy'
When: I create the Customer 'Peter' with valid customer information
And: I assign 'Peter' the delivery address 'P. Sherman 42 Wallaby Way, Sydney'
Then: the customer 'Peter' is created
And: 'Bob' has the delivery address 'P. Sherman 42 Wallaby Way, Sydney' assigned
@mariodavid
mariodavid / gist:e7666ad7b534f951f23e
Created November 26, 2014 08:46
database-migration changelog sequence-entity
databaseChangeLog = {
changeSet(author: "mario (generated)", id: "1416989310726-1") {
createTable(tableName: "D_SEQUENCEDEFINITION") {
column(autoIncrement: "true", name: "ID", type: "bigint") {
constraints(nullable: "false", primaryKey: "true", primaryKeyName: "D_SEQUENCEDEFPK")
}
column(name: "VERSION", type: "bigint") {
constraints(nullable: "false")
@mariodavid
mariodavid / gist:828f810059d1fe69391f
Created November 26, 2014 08:44
sequence-entity stacktrace
| Error 2014-11-26 09:15:53,513 [localhost-startStop-1] ERROR liquibase - Change Set changelog-test-sequence-entity.groovy::1416989310726-2::mario (generated) failed. Error: Error executing SQL CREATE TABLE D_SEQUENCENUMBER (ID NUMBER(38,0) NOT NULL, VERSION NUMBER(38,0) NOT NULL, DEFINITION_id NUMBER(38,0) NOT NULL, sequence_group VARCHAR2(40), number NUMBER(38,0) NOT NULL, CONSTRAINT D_SEQUENCENUMPK PRIMARY KEY (ID)): ORA-00904: : ungültiger Bezeichner
Message: Error executing SQL CREATE TABLE D_SEQUENCENUMBER (ID NUMBER(38,0) NOT NULL, VERSION NUMBER(38,0) NOT NULL, DEFINITION_id NUMBER(38,0) NOT NULL, sequence_group VARCHAR2(40), number NUMBER(38,0) NOT NULL, CONSTRAINT D_SEQUENCENUMPK PRIMARY KEY (ID)): ORA-00904: : ungültiger Bezeichner
Line | Method
->> 62 | execute in liquibase.executor.jvm.JdbcExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 104 | execute in ''
| 1091 | execute . . . . . in liquibase.database.AbstractDatabase
|
protected static HttpServer startServer() throws IOException {
System.out.println("Starting grizzly...");
// Alte Version
// ResourceConfig rc = new PackagesResourceConfig("http.resources");
// Map<String, String> initParams = new HashMap<String, String>();
// initParams.put("com.sun.jersey.config.property.packages", "http.resources");
// initParams.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
@mariodavid
mariodavid / gist:4132505
Created November 22, 2012 18:38
hasNext() gegen noSuchElementException
public Bindings computeNext() {
Bindings inter;
boolean flag;
do {
flag = false;
if (this.originalIterator.hasNext()) {
inter = this.originalIterator.next();
if (inter == null) {
return null;
@mariodavid
mariodavid / gist:3754299
Created September 20, 2012 06:45
TomP2P - Send Message directly to a certain content hash
// create hash of our content "test"
Number160 contentHash = Number160.createHash("test");
// find the responsible peer (the hash of it) of the content
Number160 destination = peer.getPeerBean().getStorage()
.findPeerIDForResponsibleContent(contentHash);
// send a message to this peer
FutureDHT future = peer.send(destination).setObject("this is the message").start();