Skip to content

Instantly share code, notes, and snippets.

View penguinbroker's full-sized avatar

Dave Lee penguinbroker

  • Geneva Technologies, Inc
  • New York, NY
View GitHub Profile
@penguinbroker
penguinbroker / cognito.yaml
Created January 18, 2019 00:47 — forked from singledigit/cognito.yaml
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
SNSRole:
{
"$class": "io.clause.latedeliveryandpenalty.LateDeliveryAndPenaltyRequest",
"forceMajeure": false,
"agreedDelivery": "2017-10-07T16:38:01.412Z",
"goodsValue": 200,
"transactionId": "402c8f50-9e61-433e-a7c1-afe61c06ef00",
"timestamp": "2017-11-12T17:38:01.412Z"
}
{
"type": "io.clause.latedelivery",
"forceMajeur": "except for Force Majeure cases, ",
"seller": "Seller",
"buyer": "Buyer",
"penaltyUnit": 2,
"penaltyPeriod": ["day"],
"penaltyPercentage": 0.105,
"fractional": {
"fractionalPeriod": "day",
Raw Data Points
- lesson
- entered classroom
- time spent in classroom
- video playback
- visited
- player clicks
- heat maps
VideoPresentation(None,None,None,None,None)
CaptureEvent(Some(b916794a-8f92-474f-8d0b-c178b382988b),46310481-059c-40fb-a31b-253fdf317bc8,CaptureEvent.capturePublished,2015-08-01T21:27:06.410Z)
CaptureEvent(Some(d4fa045f-1a72-4cac-94d9-7550e90b6e37),46310481-059c-40fb-a31b-253fdf317bc8,CaptureEvent.contentUploadFinished,2015-08-01T21:27:06.575Z)
CaptureEvent(Some(4cf854e1-43a2-416b-be3d-9b93baad28f1),46310481-059c-40fb-a31b-253fdf317bc8,CaptureEvent.capturePublished,2015-08-01T21:27:07.256Z)
CaptureEvent(Some(40badefc-5f23-47fa-bc3f-95cb632f1fb0),46310481-059c-40fb-a31b-253fdf317bc8,CaptureEvent.processingFinished,2015-08-01T21:27:29.910Z)
CaptureEvent(Some(004b811e-4f76-4fdb-9c56-0991443129e0),46310481-059c-40fb-a31b-253fdf317bc8,CaptureEvent.capturePublished,2015-08-01T21:27:30.893Z)
VideoPresentation(None,None,None,None,None)
CaptureEvent(Some(777629a6-3f18-418e-8f5f-5621c460430c),3325d9a8-5748-450c-b017-1fb028d6ab0b,CaptureEvent.capturePublished,2015-08-01T15:31:38.643Z)
CaptureEvent(Some(d811e33c-8121-400
@penguinbroker
penguinbroker / gist:80fc8cb0253d0961120a
Last active August 29, 2015 14:20
init pubnub channels
val users = Await.result(ComponentRegistry.institutionUserDao.tableScan, 100.seconds)
users map { user =>
if (user.pubnubAuthKey.isEmpty) {
println(s"updating user ${user.id}")
val updated = user.withAuthKey(echo360.util.IdGenerator.createUuid)
Await.result(ComponentRegistry.institutionUserDao.update(updated), 10.seconds)
Thread.sleep(10)
}
}
@penguinbroker
penguinbroker / gist:1fde23ccf01adede6192
Last active August 29, 2015 14:18
clean up missing lessonSlides
val decks = Await.result(ComponentRegistry.slideDeckDao.tableScan, 100.seconds)
val lpms = Await.result(ComponentRegistry.lessonPublishableMediaDao.tableScan, 100.seconds)
val lessonSlides = Await.result(ComponentRegistry.lessonSlideDao.tableScan, 100.seconds)
val slides = Await.result(ComponentRegistry.slideDao.tableScan, 100.seconds)
slides map { slide =>
decks find (_.id == Some(slide.slideDeckId)) map { deck =>
if (deck.publishableMediaId != slide.publishableMediaId) {
println("found broken slide: " + slide.id)
val updatedSlide = slide.copy(publishableMediaId = deck.publishableMediaId)
@penguinbroker
penguinbroker / gist:bc4493e7e6def45da291
Last active August 29, 2015 14:18
clean slide uris
package migrations
import global.{ComponentRegistry, DaoRegistry}
import com.amazonaws.services.dynamodbv2.model.AttributeValue
import java.net.URI
import scala.concurrent.Await
import scala.concurrent.duration._
object SlideUriMigration extends DatabaseMigration with DaoRegistry {
val institution = Await.result(ComponentRegistry.institutionService.fetchById("8b5fc2a9-9055-46bc-9a83-1ff8c00b004a"), 10.seconds)
Await.result(ComponentRegistry.sectionEnrollmentService.enroll(institution, "74ee7c8f-f854-4b3e-8210-f13714e7110c", "14d3dca8-e277-415e-93f7-1601d6b9ec03", models.UserSectionRole.Instructor), 100.seconds)
@penguinbroker
penguinbroker / gist:8b94fd3db2f322e01821
Last active August 29, 2015 14:16
find broken sections
val sections = Await.result(ComponentRegistry.sectionDao.tableScan, 100.seconds)
sections map { section =>
val sectionId = section.getIdOrFail
val userSections = Await.result(ComponentRegistry.userSectionService.findInstructorsBySectionId(sectionId), 100.seconds)
val instructorIds = userSections.map( _.userId ).distinct
val allInstructors = Await.result(ComponentRegistry.institutionUserService.findByIds(instructorIds, section.institutionId), 100.seconds)
val instructors = allInstructors.filter(!_.isInactive)
instructors.find(_.getIdOrFail == section.instructorId) getOrElse {
println("--")
println("broken section")