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 java.util.*; | |
class HelloJNI extends Hello { | |
static { | |
System.loadLibrary("HelloCpp"); // HelloCpp.dll (Windows) or libhellocpp.so (*nix) | |
} | |
//instance variable | |
private int number = 10; |
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
#include <iostream> | |
#include "windows.h" | |
//Memory Usage | |
#include "psapi.h" | |
//CPU Usage | |
#include "TCHAR.h" | |
//1- assuming we are monitoring Windows machine | |
//2- consider to use Performance Data Helper library which is much more intuitive |
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
@echo off | |
echo Compiling C/C++ | |
REM C library | |
gcc -Wl,--add-stdcall-alias -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" -shared -o helloc.dll hello.c | |
REM C++ library | |
g++ -Wl,--add-stdcall-alias -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" -shared -o hellocpp.dll hello.cpp | |
echo Running groovy script |
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
@echo off | |
REM Compile script on Windows machine | |
echo Compiling C | |
gcc -c -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32" hello.c | |
echo Generating o library | |
gcc -Wl,--add-stdcall-alias -shared -o hello.dll hello.o | |
echo Generate header interface using JNAcreator | |
java -jar jnaerator.jar -mode Jar -jar hello.jar -runtime JNA -library hello hello.h | |
rem java -jar jnaerator.jar -mode Jar -jar hello.jar -runtime BridJ -library hello hello.h | |
echo Running groovy script |
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
//Separate file for simple AES encrypt/decrypt | |
import javax.crypto.Cipher; | |
import javax.crypto.spec.IvParameterSpec; | |
import javax.crypto.spec.SecretKeySpec; | |
import javax.xml.bind.DatatypeConverter; | |
public class Encryptor { | |
public static String encrypt(String key, String initVector, String value) { | |
try { | |
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8")); |
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 java.util.zip.* | |
String zipFileName = "file.zip" | |
String inputDir = "logs" | |
def outputDir = "zip" | |
//Zip files | |
ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream(zipFileName)) | |
new File(inputDir).eachFile() { 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
@Grab(group = 'org.apache.mahout', module = 'mahout-core', version = '0.9') | |
import org.apache.mahout.cf.taste.impl.common.FastByIDMap | |
import org.apache.mahout.cf.taste.impl.common.FastIDSet | |
import org.apache.mahout.cf.taste.impl.model.file.FileDataModel | |
import org.apache.mahout.cf.taste.impl.recommender.GenericItemBasedRecommender | |
import org.apache.mahout.cf.taste.impl.similarity.TanimotoCoefficientSimilarity | |
//you can get this data from here: http://files.grouplens.org/datasets/movielens/ml-100k.zip | |
def mlDir = new File(getClass().protectionDomain.codeSource.location.path).parent+'/ml-100k' |
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
/** | |
* Original JavaFX tutorial: | |
* http://docs.oracle.com/javafx/2/get_started/form.htm | |
* Tested using JDK8 | |
*/ | |
@Grab('org.codehaus.groovyfx:groovyfx:0.4.0') | |
//@GrabExclude('org.codehaus.groovy:groovy-all') | |
import static groovyx.javafx.GroovyFX.start |
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
class SimpleStringEncryption { | |
public static String encrypt(String str){ | |
int code; | |
String result = ""; | |
for (int i = 0; i < str.length(); i++) { | |
code = Math.round((float) Math.random()*8+1); | |
result += code + Integer.toHexString( ((int) str.charAt(i) ) ^ code )+"-"; | |
} | |
return result.substring(0, result.lastIndexOf("-")); |
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('org.codehaus.groovyfx:groovyfx:0.4.0'), | |
@Grab('com.jfoenix:jfoenix:8.0.3') | |
]) | |
import static groovyx.javafx.GroovyFX.start | |
import com.jfoenix.controls.* | |
start { | |
// you could use registerBeanFactory or use node() |
OlderNewer