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
@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
//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
@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
@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() |
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 Java Code from here: | |
https://stackoverflow.com/questions/1529611/how-to-write-a-java-program-which-can-extract-a-jar-file-and-store-its-data-in-s | |
*/ | |
import java.util.jar.* | |
def jar = new JarFile("path/to/MyLib.jar") | |
def jarFile = new File(jar.name) | |
def distDir = "${jarFile.parent+File.separator}" |
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.awt.* | |
import java.awt.event.* | |
new Frame(title:"Hello AWT", size:[300, 200], locationRelativeTo: null, visible: true).with { | |
def tf = add({ new TextField(text:"www.google.com", bounds: [50,50,150,20])}() ) | |
def l = add({ new Label(bounds: [50,100,250,20]) }()) | |
add({ | |
def b = new Button(label:"Find IP", bounds: [50,150,60,30]) | |
b.addActionListener({ l.text = "IP of ${tf.text} is ${java.net.InetAddress.getByName(tf.text).hostAddress}" }) | |
b}()) |
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.jar.* | |
def outputFile = "MyLib.jar" | |
def distDir = "path/to/content/MyLib" | |
/*Manifest manifest = new Manifest() | |
manifest.mainAttributes[Attributes.Name.MANIFEST_VERSION] = "1.0"*/ | |
def jar = new JarOutputStream(new File("${new File(distDir).parent}/${outputFile}").newOutputStream()/*, manifest*/) | |
new File(distDir).eachFileRecurse { |
OlderNewer