Skip to content

Instantly share code, notes, and snippets.

View onema's full-sized avatar
👾

Juan Manuel Torres onema

👾
View GitHub Profile
class Function extends LambdaHandler[S3Event, Unit] with NoopLambdaConfiguration
import com.amazonaws.serverless.proxy.model.{AwsProxyRequest, AwsProxyResponse}
import com.amazonaws.services.lambda.runtime.Context
import io.onema.userverless.configuration.lambda.NoopLambdaConfiguration
import io.onema.userverless.function.ApiGatewayHandler
import io.onema.userverless.function.ApiGatewayHandler.Cors
import org.apache.http.HttpStatus
class ApiGatewayFunction
extends ApiGatewayHandler
import com.amazonaws.services.lambda.runtime.Context
import io.onema.userverless.configuration.lambda.NoopLambdaConfiguration
import io.onema.userverless.function.SnsHandler
case class Foo(bar: String)
class Function extends SnsHandler[Foo] with NoopLambdaConfiguration {
//--- Methods ---
def execute(event: Foo, context: Context): Unit = {
import com.amazonaws.services.lambda.runtime.Context
import com.amazonaws.services.lambda.runtime.events.S3Event
import com.amazonaws.services.s3.{AmazonS3, AmazonS3ClientBuilder}
import com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord
import io.onema.userverless.configuration.lambda.EnvLambdaConfiguration
import io.onema.userverless.function.LambdaHandler
import scala.collection.JavaConverters._
class CopyFunction extends LambdaHandler[S3Event, Unit] with EnvLambdaConfiguration {
@onema
onema / codebuild-4scala_cfn.yml
Created September 7, 2018 21:09
Cloudformation template to create codebuild service for scala libraries
# Code pipeline for scala applications
AWSTemplateFormatVersion: '2010-09-09'
Description: >
Template to create codebuild service for components and libraries
#
#--------------------------------------------------------------------------
# PARAMETERS
#--------------------------------------------------------------------------
@onema
onema / Function.scala
Last active March 22, 2018 16:05
My own solution of the LambdaSharp challenge March2018-DynamoDB
/**
* See https://github.com/LambdaSharp/March2018-DynamoDB
*/
package onema
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClientBuilder
import com.amazonaws.services.lambda.runtime.Context
import collection.JavaConverters._
import com.amazonaws.services.lambda.runtime.events.S3Event
@onema
onema / CaseClassToCsv.sc
Created April 19, 2017 14:26
Converting a case class to a map
import java.io.{BufferedWriter, FileWriter}
import com.github.tototoshi.csv.CSVWriter
// ...
def writeCaseClasses(seqOfCaseClasses: Seq[AnyRef], filename: String): Unit = {
import Implicits._
val mapOfKeyValues = seqOfCaseClasses.map(x => x.toMap)
val values = mapOfKeyValues.map(_.values.toSeq)
@onema
onema / lock-down-access-to-instance-types.yml
Created January 24, 2017 21:43
Cloud formation template for single policy based on the reInvent2015 talk https://www.youtube.com/watch?v=Du478i9O_mc
AWSTemplateFormatVersion: "2010-09-09"
Description: >
Tempalte to create a managed policy to lock down users to create instance of a specific type
Parameters:
InstanceTypes:
Description: >
Comma separated list of instance types that will be allowed by the policy
e.g. "t1.*, t2.*, m3.*"
@onema
onema / gist:eb5fbd8200882569a43b
Created December 8, 2015 00:54
Prevent vagrant from asking for password
sudo /bin/bash -c "echo 'Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports' >> /etc/sudoers"
sudo /bin/bash -c "echo 'Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart' >> /etc/sudoers"
sudo /bin/bash -c "echo 'Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports' >> /etc/sudoers"
sudo /bin/bash -c "echo '%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE' >> /etc/sudoers"
@onema
onema / graceful_int_handler.py
Created November 5, 2015 17:53 — forked from nonZero/graceful_int_handler.py
GracefulInterruptHandler
import signal
class GracefulInterruptHandler(object):
def __init__(self, sig=signal.SIGINT):
self.sig = sig
def __enter__(self):
self.interrupted = False