Skip to content

Instantly share code, notes, and snippets.

View djfarrelly's full-sized avatar
🌞

Dan Farrelly djfarrelly

🌞
View GitHub Profile
@djfarrelly
djfarrelly / disable-cron-in-preview.js
Created May 2, 2024 16:49
Inngest: Disable cronjob in Branch Environment / Vercel preview
export const cronJob = inngest.createFunction(
{ id: 'cron-job' },
process.env.VERCEL_ENV === 'preview'
? { event: 'trigger-cron' }
: { cron: '45 23 * * *' },
async ({ step }) => {
// your logic here
}
);
@djfarrelly
djfarrelly / functions.ts
Last active February 22, 2024 20:08
Mux Video Migration tool
import { inngest } from './client';
/*
1. Submit migration job details include video source platform, video destination platform, authentication details, and import settings, and get back a job id (provided by Inngest?)
2. Inngest starts the migration by listing all videos in the source platform
3. A request is then made to each individual video to get that specific video’s details, including a signed URL to access that video’s master file
4. A request is then made to PUT that video over to the destination platform either by providing the signed URL directly to the platform or by pushing chunks of the video to the destination platform as a multipart file upload
5. The status of the video upload/ingest is monitored via multipart upload progress or by listening for a webhook from the destination platform indicating success or failure
6. Each video’s status is then reported back to the client based off of the initial job ID that the client received in step one
7. The job is considered complete when all videos ha
@djfarrelly
djfarrelly / inngest-client.ts
Last active January 11, 2024 17:47
Inngest SDK: Using middleware to access search params from request
import { type NextRequest } from 'next/server';
import { Inngest, InngestMiddleware } from 'inngest';
import { schemas } from './types';
export const searchParamsMiddleware = new InngestMiddleware({
name: 'query-params-pass-through',
init({}) {
return {
onFunctionRun() {
return {
@djfarrelly
djfarrelly / encryption-middleware.ts
Created September 22, 2023 19:52
Inngest - Encryption middleware
import { InngestMiddleware } from "inngest";
export const encryptionMiddleware = (
key: string = process.env.INNGEST_ENCRYPTION_KEY || ""
) => {
if (!key) {
throw new Error("Must provide an encryption key");
}
const prefix = "__ENCRYPTED__";
@djfarrelly
djfarrelly / index.ts
Created October 26, 2022 17:32
Inngest Cloudflare Workers Support (w/ inngest@v0.6.1)
import { createFunction } from "inngest"; // v0.6.1
import { serve } from "inngest/cloudflare";
/**
* Inngest serve requires "node_compat = true" to be set in your wrangler.toml
*
* Set INNGEST_SIGNING_KEY in your wrangler.toml environment variables.
* Get this key in your Inngest dashboard: https://app.inngest.com/secrets
*/
@djfarrelly
djfarrelly / local-deploy.sh
Last active July 12, 2019 16:08
How to test your helm chart values yaml files locally
#!/bin/bash
# Usage `./local-deploy.sh <command> <service-name>
# Requirements: helm must be installed and match the version on our cluster
# commands:
# deploy Deploys the code to the cluster (requires cluster access)
# dry-run Prints the k8s deployment and service yaml files generates by helm
CMD="$1"
SVC="$2"
@djfarrelly
djfarrelly / folders.sh
Last active April 5, 2019 20:08
maildev folder structure
# 3 package approach
/maildev-smtp
/src # most of what currently is in /lib
/test
/index.js
/package.json
/maildev-ui
/src # all the react components, etc.
/public
/package.json
@djfarrelly
djfarrelly / 1-regular-probes.yaml
Last active August 31, 2018 19:37
Reply Server liveness and readiness probes
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: respond-server
namespace: reply
spec:
replicas: 12
strategy:
rollingUpdate:
maxSurge: 2
@djfarrelly
djfarrelly / MongoIdShim.php
Created April 5, 2018 22:13
mongo to mongodb php driver migration helpers
<?php
class MongoId implements Serializable, JsonSerializable
{
public $id;
public function __construct($id)
{
$this->id = (string) $id;
}
@djfarrelly
djfarrelly / index.js
Last active April 22, 2017 18:10
requirebin sketch
const logger = (t) => (document.body.innerHTML = `${document.body.innerHTML}<br>${JSON.stringify(t)}`)
/// app
const { createStore, combineReducers } = require('redux')
const OPEN_COMPOSER = 'OPEN_COMPOSER'
const CLOSE_COMPOSER = 'CLOSE_COMPOSER'
// The metrics reducer - we just grab the even and let the state pass through
const bufferMetrics = (state = {}, action) => {