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
void loop() { | |
int read = analogRead(SENSOR); | |
Serial.println(read); | |
if( read > 50 ) { | |
Serial.println("on"); | |
digitalWrite(LED,HIGH); | |
tone(BUZZER, 10); | |
delay(100); | |
}else { |
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
dependencies { | |
localGroovyConf localGroovy() | |
compile 'org.codehaus.groovy:groovy-all:2.5.4' | |
compile 'com.sparkjava:spark-core:2.7.2' | |
compile 'org.slf4j:slf4j-simple:1.7.21' | |
compile group: 'org.apache.tika', name: 'tika-core', version: '1.19.1' | |
implementation fileTree(dir: 'libs', include: ['*.jar']) | |
} |
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
task runServer(dependsOn: 'classes', type: JavaExec) { | |
System.setProperty('environment', 'prod') | |
dependsOn 'classes' | |
classpath = sourceSets.main.runtimeClasspath | |
main = 'codes.recursive.Bootstrap' | |
systemProperties = System.getProperties() | |
} |
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
package codes.recursive.service | |
import com.oracle.bmc.auth.AuthenticationDetailsProvider | |
import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider | |
import com.oracle.bmc.objectstorage.ObjectStorage | |
import com.oracle.bmc.objectstorage.ObjectStorageClient | |
import java.security.Security | |
class OciClientManager { |
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
OciClientManager clientManager | |
ObjectStorage objectClient | |
String bucketName = "doggos" | |
String namespaceName | |
ObjectService(OciClientManager clientManager) { | |
this.clientManager = clientManager | |
this.objectClient = clientManager.getObjectClient() | |
GetNamespaceResponse namespaceResponse = objectClient.getNamespace( | |
GetNamespaceRequest.builder().build() |
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
def listBuckets() { | |
ListBucketsRequest listBucketsRequest = ListBucketsRequest.builder() | |
.namespaceName(this.namespaceName) | |
.compartmentId(System.getProperty("ociCompartmentId")) | |
.build() | |
ListBucketsResponse listBucketsResponse = objectClient.listBuckets(listBucketsRequest) | |
return listBucketsResponse | |
} |
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
def getBucket() { | |
def listBucketsResponse = listBuckets() | |
GetBucketRequest getBucketRequest = GetBucketRequest.builder() | |
.namespaceName(this.namespaceName) | |
.bucketName( listBucketsResponse.items.find { it.name == this.bucketName }.name ) | |
.fields([GetBucketRequest.Fields.ApproximateCount]) | |
.build() | |
GetBucketResponse getBucketResponse = objectClient.getBucket(getBucketRequest) | |
return getBucketResponse | |
} |
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
def listObjects() { | |
ListObjectsRequest listObjectsRequest = ListObjectsRequest.builder() | |
.namespaceName(this.namespaceName) | |
.bucketName(this.bucketName) | |
.build() | |
ListObjectsResponse listObjectsResponse = objectClient.listObjects(listObjectsRequest) | |
return listObjectsResponse | |
} |
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
def getObject() { | |
def listObjectsResponse = listObjects() | |
GetObjectRequest getObjectRequest = GetObjectRequest.builder() | |
.namespaceName(namespaceName) | |
.bucketName(bucketName) | |
.objectName(listObjectsResponse.listObjects.objects.first().name) | |
.build() | |
GetObjectResponse getObjectResponse = objectClient.getObject(getObjectRequest) | |
def object = Util.writeInputStream(getObjectResponse.inputStream, getObjectResponse.contentType) | |
return [object: object, response: getObjectResponse] |
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
// route handler (Bootstrap.groovy): | |
post "/oci/upload-create", { req, res -> | |
def objectName = req.queryParams("objectName") | |
def contentType = req.queryParams("contentType") | |
return JsonOutput.toJson( objectService.createMultipartUpload(objectName, contentType) ) | |
} | |
// service method (ObjectService.groovy): | |
def createMultipartUpload(objectName, contentType="application/octet-stream") { | |
CreateMultipartUploadDetails createMultipartUploadDetails = CreateMultipartUploadDetails.builder() |