Skip to content

Instantly share code, notes, and snippets.

View alecmerdler's full-sized avatar

Alec Merdler alecmerdler

View GitHub Profile
@alecmerdler
alecmerdler / atomic-write.test.ts
Created November 7, 2023 21:59
Durable writes using promises (with retries and reverts!)
import { Write, atomicWrite } from '../../util/atomic-write';
describe('write', () => {
const createWrite = (retries: number, shouldSucceed: boolean): Write => {
let attempts = 0;
return {
id: `${shouldSucceed ? 'success' : 'failure'}-${retries}-retries-${Math.floor(Math.random() * 100)}`,
perform: jest.fn(() => (shouldSucceed && (attempts += 1) > retries ? Promise.resolve() : Promise.reject())),
revert: jest.fn(),
@alecmerdler
alecmerdler / train.py
Created April 5, 2023 11:06
Lightning Autoencoder
import os
from argparse import ArgumentParser
import torch
import torch.nn as nn
import torch.utils.data as data
import torchvision as tv
import torch.nn.functional as F
import lightning as L
@alecmerdler
alecmerdler / app.py
Created December 5, 2022 18:56
Training Lightning App
#! python -m pip install streamlit
import lightning as L, torch, torch.nn as nn
import requests, time, threading, os
from lightning.app.utilities.state import AppState
from lightning.app.frontend import StreamlitFrontend
class PyTorchComponent(L.LightningWork):
def run(self):
@alecmerdler
alecmerdler / build-lightning-frontend.sh
Created February 1, 2022 06:45
Build the Lightning app UI
#!/bin/sh
git clone git@github.com:gridai/lightning-ui.git /tmp/lightning-ui
cd /tmp/lightning-ui && yarn install && yarn build
cp -r /tmp/lightning-ui/build/* $HOME/work/PyTorchLightning/lightning/lightning/ui
@alecmerdler
alecmerdler / source.json
Created December 28, 2020 02:54
Deno Skynet data source
{
"status": "online"
}
@alecmerdler
alecmerdler / config.yaml
Last active August 5, 2020 19:41
Base Quay config bundle files
ENTERPRISE_LOGO_URL: /static/img/quay-horizontal-color.svg
FEATURE_MAILING: false
FEATURE_SUPER_USERS: true
SUPER_USERS:
- admin
PREFERRED_URL_SCHEME: https
REGISTRY_TITLE: Quay
REGISTRY_TITLE_SHORT: Quay
SERVER_HOSTNAME: quay-app.quay-enterprise
@alecmerdler
alecmerdler / operatorhubio-catalog.catalogsource.yaml
Last active July 28, 2020 19:05
OperatorHub.io CatalogSource
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: operatorhubio-catalog
labels:
olm-visibility: hidden
openshift-marketplace: "true"
spec:
sourceType: grpc
image: quay.io/operator-framework/upstream-community-operators:latest
@alecmerdler
alecmerdler / vulnerable-deployments.yaml
Last active May 5, 2020 05:46
Set of k8s Deployments running container images with known vulnerabilities for rapid Clair testing
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: abject-testament
labels:
secscan.quay.redhat.com/severity: critical
spec:
replicas: 1
selector:
@alecmerdler
alecmerdler / nodejs.md
Last active May 25, 2020 18:58
NodeJS Scanner