Skip to content

Instantly share code, notes, and snippets.

@skullquake
skullquake / mxnh_006
Created January 28, 2020 10:04
Mendix Nashorn Example 6
HOST=https://nhutil-sandbox.mxapps.io
ENDPOINT=/main
URL=$(HOST)$(ENDPOINT)
CURL=curl
SRC=./src/a.js
.phony:POST
POST:
@$(CURL) \
--insecure \
$(URL) \
@skullquake
skullquake / mxnh_005
Created January 24, 2020 06:30
Mendix Nashorn Example 5
var astack=root.getContext().getActionStack();
var calleridx=astack.length-1;
var caller=astack[calleridx];
caller.setVariable(
"str_foo",
"Hello Microflow, how are things up there?"
)
var astack=
root
.getContext()
.getActionStack()[0];
var numthrs=10;
var numacc=com.mendix.core.Core.retrieveXPathQueryAggregate(
root.getContext(),
"COUNT(//Administration.Account)"
);
var maxacc=JSON.parse(astack
@skullquake
skullquake / mxnh_003
Created January 23, 2020 13:52
Mendix Nashorn Example 3
function alert(s){
com.mendix.webui.FeedbackHelper.addTextMessageFeedback(
root.getContext(),
com.mendix.systemwideinterfaces.core.IFeedback.MessageType.INFO,
s,
true
)
}
function getMethodsByObject(c){
var r={};
@skullquake
skullquake / mxnh_002
Created January 23, 2020 13:38
Mendix Nashorn Example 2
var Path=Java.type('java.nio.file.Path')
var Paths=Java.type('java.nio.file.Paths')
var Files=Java.type('java.nio.file.Files');
var IOUtils=Java.type('org.apache.commons.io.IOUtils');
com.mendix.core.Core.addRequestHandler(
"foobar",
new (
Java.extend(
com.mendix.externalinterface.connector.RequestHandler,
{
@skullquake
skullquake / mxnh_001
Last active January 23, 2020 13:34
Mendix Nashorn Example 1
for(var i=0;i<8;i++){
com
.mendix
.core
.Core
.getLogger("myscript")
.info("hello world:) "+i);
}
@skullquake
skullquake / ja_exec.java
Last active February 1, 2020 06:10
Mendix Java action to invoke Nashorn
// BEGIN USER CODE
javax.script.ScriptEngine engine=new javax.script.ScriptEngineManager().getEngineByName("nashorn");
javax.script.Bindings bindings=engine.createBindings();
bindings.put("root", this);
engine.eval(str_script,bindings);
return true;
// END USER CODE
@skullquake
skullquake / gist:3247a277877ed5593c3caaf59e846f9c
Created September 30, 2019 06:19 — forked from samhocevar/gist:00eec26d9e9988d080ac
Configure sshd on MSYS2 and run it as a Windows service
#!/bin/sh
#
# msys2-sshd-setup.sh — configure sshd on MSYS2 and run it as a Windows service
#
# Please report issues and/or improvements to Sam Hocevar <[email protected]>
#
# Prerequisites:
# — MSYS2 itself: http://sourceforge.net/projects/msys2/
# — admin tools: pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights
#
@skullquake
skullquake / mxnhqs.js
Last active June 11, 2019 12:30
mx nashorn quickstore
//--------------------------------------------------------------------------------
//configuration
//--------------------------------------------------------------------------------
var storeIDField="Title";
var storeIDValue="myDataStore";
var storeTable="Nashorn.JS";
var storeValueField="Contents";
var str_ret='';
function print(s){
str_ret+=s;
@skullquake
skullquake / pasteit.js
Last active June 12, 2019 09:32
mx-devtool
//----------------------------------------
//Inline Widget Def
//----------------------------------------
require(
[
"dojo/_base/declare",
"dijit/_TemplatedMixin",
"dojo/dom-construct",
"dojo/parser",