Skip to content

Instantly share code, notes, and snippets.

View zeryx's full-sized avatar

zeryx zeryx

View GitHub Profile
name := "algorithm-handler"
organization := "com.foo"
version := "1.0.0"
autoScalaLibrary := false
set -e
CRAN_MIRROR=${CRAN_MIRROR:=http://cran.rstudio.com/}
# When installing from CRAN, use this mirror as a default
echo "options(repos=structure(c(CRAN=\"$CRAN_MIRROR\")))" > ~/.Rprofile
ROOTDIR=/opt/algorithm
# First install the latest CRAN packages system wide so it can populate the shared cache
{
"data":[
{
"text":"The atomic nucleus is held together with the strong nuclear force. Nuclear power is a very economical fuel source for today's economies."
}
],
"namespace":"data://nlp/arxiv_model",
"mode":"predict",
"option":"very accurate",
"returnDocs":true
package AlgorithmHandler.algorithms;
import java.util.HashMap;
public class AdvancedAlgorithm {
public class AlgoInput {
String name;
Integer age;
@Before
public void IntializePipe() throws IOException, InterruptedException {
Process p = Runtime.getRuntime().exec("mkfifo /tmp/pipe");
p.waitFor();
Thread.sleep(100);
System.out.println("fifo pipe made.");
}
Loading required package: methods
Installing package into ‘/opt/algorithm/dependencies’
(as ‘lib’ is unspecified)
Warning: dependency ‘mvtnorm’ is not available
also installing the dependencies ‘glue’, ‘stringi’, ‘colorspace’, ‘utf8’, ‘TH.data’, ‘stringr’, ‘labeling’, ‘munsell’, ‘RColorBrewer’, ‘fansi’, ‘pillar’, ‘pkgconfig’, ‘libcoin’, ‘matrixStats’, ‘multcomp’, ‘truncnorm’, ‘gtable’, ‘lazyeval’, ‘reshape2’, ‘scales’, ‘tibble’, ‘viridisLite’, ‘withr’, ‘modeltools’, ‘strucchange’, ‘coin’, ‘zoo’, ‘sandwich’, ‘e1071’, ‘cmm’, ‘Rsolnp’, ‘numDeriv’, ‘ggplot2’, ‘party’, ‘plyr’, ‘proto’, ‘polspline’, ‘randomForest’, ‘classInt’, ‘mipfp’
trying URL 'http://cran.rstudio.com/src/contrib/glue_1.3.1.tar.gz'
Content type 'application/x-gzip' length 122950 bytes (120 KB)
==================================================
downloaded 120 KB
trying URL 'http://cran.rstudio.com/src/contrib/stringi_1.4.3.tar.gz'
package com.org.example;
import java.util.HashMap;
/**
* Hello world!
*
*/
class AlgorithmBasic
{
public class AlgorithmHandler<INPUT, O, CONTEXT> {
private BiFunction<INPUT, CONTEXT, O> applyFunc;
private Supplier<CONTEXT> loadFunc;
private HashMap<String, Object> context;
private <T, J, L> BiFunction<T, J, L> applyHandler(FunctionWithException<T, J, L> fe) {
return (arg1, arg2) -> {
try {
return fe.apply(arg1, arg2);
public class InternalHandler<I1, I2, O>
{
public delegate O ApplyMethod1(I1 input);
public delegate O ApplyMethod2(I1 input, I2 context);
public delegate I2 LoadMethod();
private I2 _context = default;
private LoadMethod _loadMethod = () => { return default;};
@zeryx
zeryx / AlgorithmAdvanced.scala
Last active April 24, 2019 17:15
Full Scala Example
package algorithmia.Algorithm
import com.algorithmia._
import com.algorithmia.algo._
import com.algorithmia.data._
import com.algorithmia.algorithmHandler._
import com.google.gson._
object Algorithm{