Skip to content

Instantly share code, notes, and snippets.

Emelia Smith ThisIsMissEm

Block or report user

Report or block ThisIsMissEm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View kafka.ts
import { Kafka, logLevel, KafkaConfig, SASLOptions } from "kafkajs";
const options: KafkaConfig = {
clientId: "my-client",
brokers: (process.env.KAFKA_BROKERS &&
process.env.KAFKA_BROKERS.split(",")) || ["localhost:9092"]
};
if (
process.env.KAFKA_AUTH_MECHANISM &&
View KafkaRPC.js
import { Kafka, Consumer, Producer, KafkaMessage } from "kafkajs";
import { Logger } from "pino";
import { EventEmitter } from "events";
import uuidv4 from "uuid/v4";
type Options = {
groupId: string;
topicPrefix: string;
logger: Logger;
};
View Keys-api.js
type Key {
constructor(identifier)
unlock(): Promise<void>
lock(): Promise()<void>
decrypt(value: ArrayBuffer): Promise<ArrayBuffer>
}
View Keys-api.js
type Key {
constructor(identifier)
unlock(): Promise<void>
lock(): Promise()<void>
decrypt(value: ArrayBuffer): Promise<ArrayBuffer>
}
@ThisIsMissEm
ThisIsMissEm / gist:13d37d8745f39656ed52e88031d69bf6
Created Jul 24, 2019
Securely(?) sharing private keys using DHTs & one-time tokens
View gist:13d37d8745f39656ed52e88031d69bf6
‪From the initiating client (owner)‬
1. create a short-code (say 12 lowercase hex characters)‬
2. Using the dat archives public key, encrypt that value, let that be token‬
3. poll a DHT for token's value‬
4. Once we receive a value for that token, encrypt the archive private key with the received public key & save as a file
‪From the new client:‬
1. Ask the user to input the short-code from the same dat archive
2. Using the archives public-key, encrypt that value
3. Create a new public/private key pair
View message-log-db.js
const fs = require("fs").promises;
const createReadStream = require("fs").createReadStream;
const debug = require("debug");
class MessageLogDB {
constructor(filename, separator) {
this.separator = separator || "\r\n";
this.separator_length = Buffer.byteLength(this.separator, "utf8");
this.filename = filename;
View index.js
const fs = require("fs").promises;
const path = require("path");
const execa = require("execa");
const assert = require("assert");
const gitUrlParse = require("git-url-parse");
const fse = require("fs-extra");
async function findRepos(workingDirectory) {
const nodes = await fs.readdir(workingDirectory, { withFileTypes: true });
const directories = nodes.filter(node => node.isDirectory());
@ThisIsMissEm
ThisIsMissEm / package.json
Last active Apr 6, 2019
Concept for multi-registry support in package.json
View package.json
{
"name": "my-app",
"version": "1.0.0",
"registries": {
"npm": { "url": "registry.npmjs.org", "default": true },
"tidelift": { "url": "registry.tidelift.org" },
"acme-corp": { "url": "verdaccio.acme.corp" }
},
"dependencies": {
"express": "^4.0.x",
View output.console
$ npm run test
> node-fetch@2.2.0 test /Users/emelia/Work/HighSnobiety/repos/node-fetch
> cross-env BABEL_ENV=test mocha --require babel-register test/test.js
node-fetch
✓ should return a promise
✓ should allow custom promise
@ThisIsMissEm
ThisIsMissEm / 1.js
Created Aug 21, 2018
Despite the code being identical other than the ordering of the "addEventListener" calls, the results change when run on the Cloudflare Worker platform.
View 1.js
addEventListener('fetch', event => {
console.log("fetch handler 2", event.request)
})
addEventListener('fetch', event => {
console.log("fetch handler 1")
event.respondWith(handleRequest(event.request))
})
/**
You can’t perform that action at this time.