Skip to content

Instantly share code, notes, and snippets.

View bbstilson's full-sized avatar
🕺

Brandon Stilson bbstilson

🕺
View GitHub Profile
import org.allenai.sqs.reader._
import scala.collection.parallel.CollectionConverters._
import scala.concurrent.ExecutionContext
import scala.collection.parallel.ExecutionContextTaskSupport
import java.util.concurrent.Executors
import com.amazonaws.services.sqs.AmazonSQSClientBuilder
object Main {
val cores = Runtime.getRuntime().availableProcessors()
import $ivy.`io.circe::circe-core:0.12.3`
import $ivy.`io.circe::circe-generic:0.12.3`
import $ivy.`io.circe::circe-parser:0.12.3`
import $ivy.`org.scala-lang.modules::scala-parallel-collections:1.0.0`
import ammonite.ops._
import scala.collection.parallel.CollectionConverters._
import io.circe._, io.circe.generic.auto._, io.circe.parser._, io.circe.syntax._
import scala.jdk.CollectionConverters._
import scala.util._

Current

[info] Performance report: Report Not Uploaded to S3
[info] 1439 total requests (1439 succeeded, 0 failed).
[info] Min Time: 97ms
[info] Max Time: 7512ms
[info] Mean Time: 833ms
[info] Std Deviation: 760ms
[info] 50th Percentile: 640ms
case class LibraryTag(
id: Int = LibraryTag.NEW_TAG_ID_PLACEHOLDER,
name: String,
createdAtUtc: Timestamp,
modifiedAtUtc: Timestamp
)
case class UpdateTagRequest(
name: String
)
function encrypt(text, password) {
const initVect = crypto.randomBytes(16);
const key = getCipherKey(password);
const cipher = createCipheriv('aes256', key, initVect);
const cipherText = cipher.update(text).digest();
return initVect + ciphertext;
}
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const getCipherKey = require('./getCipherKey');
function decrypt({ file, password }) {
// First, get the initialization vector from the file.
const readInitVect = fs.createReadStream(file, { end: 15 });
const { Transform } = require('stream');
class AppendInitVect extends Transform {
constructor(initVect, opts) {
super(opts);
this.initVect = initVect;
this.appended = false;
}
_transform(chunk, encoding, cb) {
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const AppendInitVect = require('./appendInitVect');
const getCipherKey = require('./getCipherKey');
function encrypt({ file, password }) {
// Generate a secure, pseudo random initialization vector.
{"lastUpload":"2020-07-03T22:26:04.449Z","extensionVersion":"v3.4.3"}

Let's encrypt some files with Node! - Part 1

What we'll be learning

This tutorial is targeted to people who are very familiar with javascript and are at least somewhat familiar with Node.js.

We'll be learning:

  • How to work with Node streams.
  • How to write custom streams.