Skip to content

Instantly share code, notes, and snippets.

View tarilabs's full-sized avatar
🎹
Your fingers hit the keys, your heart develop the code (semi cit.)

Matteo Mortari tarilabs

🎹
Your fingers hit the keys, your heart develop the code (semi cit.)
View GitHub Profile
@tarilabs
tarilabs / gist:2595655
Created May 4, 2012 15:49
Undecorated, alwaysOnTop, centered PROCESSING.ORG Frame (tested on 1.5.1)
boolean drawOnce;
int w = 640;
int h = 480;
void setup() {
drawOnce = true;
frame.removeNotify();
frame.setUndecorated(true);
frame.setAlwaysOnTop(true);
frame.addNotify();
@tarilabs
tarilabs / gist:2654859
Created May 10, 2012 18:19
Open PowerPoint file directly in SlideShow mode, cycle between SlideShows for the PowerPoint files found in the directory; useful for kiosks/totems information display (reminder: Advanced settings in PowerPoint, disable "End with black slide")
@echo off
REM this batch to be placed in the same directory as the PowerPoint files
REM this batch requires for powerpnt.exe to be in the PATH Environment variables
echo @ECHO OFF > loop.bat
for %%A in (*.ppt*) DO echo powerpnt.exe /s "%%A" >> loop.bat
echo loop.bat >> loop.bat
loop.bat
@tarilabs
tarilabs / gist:9511107
Created March 12, 2014 16:48
memo iOS AddressBook SQLite extract numbers and stuff
SELECT * from ABPerson join ABMultiValue on ABPerson.ROWID = ABMultiValue.record_id where ABPerson.First LIKE '%name%'
@Test
public void testMacOSXClassLoaderBehavior() throws Exception {
final ClassTypeResolver resolver = new ClassTypeResolver( new HashSet(), Thread.currentThread().getContextClassLoader() );
resolver.addImport("org.drools.core.test.model.*");
assertEquals( org.drools.core.test.model.Cheese.class,
resolver.resolveType( "Cheese" ) );
try {
resolver.resolveType( "cheese" ); // <<- on Mac/OSX throws NoClassDefFoundError which escapes the try/catch and fail the test.
public void testMatteo() {
ParserConfiguration conf = new ParserConfiguration();
boolean doImportNameMethod = true;
if (doImportNameMethod) {
Class<?> clazz = CoreConfidenceTests.class;
Method nameMethod = null;
for (Method m : clazz.getMethods()) {
if (m.getName() == "name") {
nameMethod = m;
}
@tarilabs
tarilabs / gist:7af2ac16f560517d59bc45c0032a7a9f
Created August 3, 2016 08:54
concurrent creation of kiecontainer check
@Test
public void testMATTEO() throws InterruptedException {
ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete", "1.0.0");
createAndDeployJar( ks, releaseId, createDRL("ruleA") );
ExecutorService es = Executors.newFixedThreadPool(10);
List<Callable<Boolean>> list = new ArrayList<Callable<Boolean>>();
for (int i = 0; i < 6; i++) {
list.add(new Callable<Boolean>() {
@Override
package org.drools.persistence.monitoring;
import org.drools.compiler.Person;
import org.drools.core.SessionConfiguration;
import org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession;
import org.drools.core.command.impl.FireAllRulesInterceptor;
import org.drools.core.command.impl.LoggingInterceptor;
import org.drools.core.factmodel.traits.Traitable;
import org.drools.core.management.DroolsManagementAgent;
@tarilabs
tarilabs / quickcheck with KieHelper and Java 8.java
Last active January 13, 2017 21:51
quickcheck with KieHelper and Java 8
KieSession kieSessionHelper = new KieHelper()
.addContent(new String(Files.readAllBytes(Paths.get("src/main/resources/myRules.drl"))), ResourceType.DRL)
.build().newKieSession();
ReteDumper.dumpRete(kieSessionHelper);
@tarilabs
tarilabs / dump GDST to DRL.java
Created January 13, 2017 21:53
dump GDST to DRL
org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 unmarshal =
org.drools.workbench.models.guided.dtable.backend.GuidedDTXMLPersistence.getInstance().unmarshal(
new String(Files.readAllBytes(Paths.get("src/main/resources/guidedTable.gdst")))
);
String drl = org.drools.workbench.models.guided.dtable.backend.GuidedDTDRLPersistence.getInstance().marshal(unmarshal);
System.out.println(drl);
@FEELType private class DROOLS_1775_1 {}
@FEELType private class DROOLS_1775_2 {}
@FEELType private class DROOLS_1775_3 {}
@FEELType private class DROOLS_1775_4 {}
@FEELType private class DROOLS_1775_5 {}
@FEELType private class DROOLS_1775_6 {}
@FEELType private class DROOLS_1775_7 {}
@FEELType private class DROOLS_1775_8 {}
@FEELType private class DROOLS_1775_11 {}
@FEELType private class DROOLS_1775_12 {}