Skip to content

Instantly share code, notes, and snippets.

View zeryx's full-sized avatar

zeryx zeryx

View GitHub Profile
var imageUUIDs: ListBuffer[String] = new ListBuffer[String]
var pixvanaOperationRequests: ListBuffer[FutureAlgoResponse] = new ListBuffer[FutureAlgoResponse]
//async data transfer masking
imageSplitRequests.foreach((response: FutureAlgoResponse) =>{
val imageUUID = response.get().toString
imageUUIDs += imageUUID
val imageCombine = Supernova(imageUUID, script)
//async data transfer masking
val processingOperationRequests: List[FutureAlgoResponse] = imageSplitRequests.map((response: FutureAlgoResponse) =>{
val imageUUID = response.get.toString
val imageCombine = Supernova(imageUUID, script)
client.algo("algo://supernovaTest/Supernova/0.1.25").pipeAsync(imageCombine)
})
val recombineChunkRequests: List[FutureAlgoResponse] = pixvanaOperationRequests.map((response: FutureAlgoResponse) => {
val pixvanaUUID = response.get.toString
val imageCombine = CombineImages(pixvanaUUID, "temp", "temp", "recombinedChunks", "mkv", 15)
case class ClassInput[I,O](name: String, classObj: Class[I], func: I => O)
def patternMatchCaseClasses(classes: List[ClassInput], gsonInput: JsonElement): Any = {}
val url: URL = new URL("http://www.reddit.com/r/pics/new.json?sort=new")
val conn: URLConnection = url.openConnection()
conn.setRequestProperty("User-Agent", "scala:com.algorithmia.redditImageScraper:v1.0.0 (by /u/zeryx)")
conn.connect()
val response: BufferedReader = new BufferedReader(new InputStreamReader(conn.getInputStream))
val input:Json = Json.parse(response.readLine())
response.close()
@zeryx
zeryx / algo input
Created June 22, 2016 14:54
how to accept multiple inputs into python using dictionaries.
{"csv_1":"...", "csv_2":"..."}
you can make a python .startswith() if check to detect if the string contains an http://, https://, data://, etc.
import Algorithmia
client = Algorithmia.client(INSERT_ALGORITHMIA_API_KEY_HERE)
input = {}
input["input"] = "data://util/Temp/dogs_and_cats.csv"
input["output"] = "dogs_and_cats.pdf"
input["collection"] = "data://.my/Temp"
result = client.algo("algo://util/FileConverter/0.2.0").pipe(input)
pdfFile = client.file(str(result.result)).getFile()
#via REPL
import Algorithmia
def apply(input):
if isinstance(input, dict):
... do stuff ...
out = {}
out["firstCsv"] = "data://path/to/csv1.csv"
out["secondCsv"] = "data://path/to/csv2.csv"
return out
#lets assume you have an algorithm that returns two key/value stores, csv1 and csv2.
import Algorithmia
import json
import csv
#payload class to deserialize json
class Payload(object):
def __init__(self, j):
self.__dict__ = json.loads(j)
client = Algorithmia.client(YOUR_ALGORITHMIA_KEY_HERE)
input = {}
app.controller('labellingSwipe', ['$scope', '$location', '$rootScope', 'usedDefs', 'tags', 'hammerjs', function ($scope, $location, $rootScope, usedDefs, tags, hammer) {
$scope.tagDefs = JSON.parse(document.getElementById("tagDefs").value);
$scope.imageUrl = document.getElementById("image-url").value;
$scope.tagDef = getNext($scope.tagDefs, usedDefs);
if($scope.tagDef === null){
$scope.lastDefs = diffArray(tagDefs, usedDefs);
}
package models
import java.security.MessageDigest
import play.api.libs.json._
case class User(username: String, password: String)
object User {