Skip to content

Instantly share code, notes, and snippets.

View dtran320's full-sized avatar
🌊
Come co-work with us virtually! https://www.flow.club

David Tran dtran320

🌊
Come co-work with us virtually! https://www.flow.club
View GitHub Profile
@kwindla
kwindla / talk.py
Created October 7, 2024 01:59
command-line openai realtime
import asyncio
import base64
import json
import os
import pyaudio
import shutil
import websockets
class AudioStreamer:
@karpathy
karpathy / stablediffusionwalk.py
Last active October 1, 2024 09:56
hacky stablediffusion code for generating videos
"""
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stablediffusionwalk.py --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
@krasimir
krasimir / delete_artifacts.js
Last active May 25, 2024 00:30
Deleting artifacts in GCP's Cloud Storage (ignores latest and leaves at least two versions)
const spawn = require("child_process").spawn;
const KEEP_AT_LEAST = 2;
const CONTAINER_REGISTRIES = [
"gcr.io/<your project name>",
"eu.gcr.io/<your project name>/gcf/europe-west3"
];
async function go(registry) {
console.log(`> ${registry}`);
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/[email protected]"></script>
<style>
.relative {
position: relative;
}
.renderer {
width: 400px;
@seratch
seratch / Dockerfile
Last active November 29, 2022 22:20
Slack OAuth App Example (Google Cloud Run + Datastore)
# https://hub.docker.com/_/python
FROM python:3.9.2-slim-buster
# Allow statements and log messages to immediately appear in the Knative logs
ENV PYTHONUNBUFFERED True
# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./
@zanona
zanona / sentry-serverless-firebase.ts
Last active September 4, 2024 19:51
Missing Sentry's firebase serverless wrappers
/**
* Temporary wrapper for firebase functions until @sentry/serverless support is implemented
* It currently supports wrapping https, pubsub and firestore handlers.
* usage: https.onRequest(wrap((req, res) => {...}))
*/
import type {Event} from '@sentry/types';
import type {https} from 'firebase-functions';
import type {onRequest, onCall} from 'firebase-functions/lib/providers/https';
import type {ScheduleBuilder} from 'firebase-functions/lib/providers/pubsub';
import type {DocumentBuilder} from 'firebase-functions/lib/providers/firestore';
@kwindla
kwindla / frame-reduced-cpu.html
Created February 1, 2021 04:50
Daily video API: reduced resolution camera settings for lower cpu usage
<html>
<head>
<title>reduced cpu camera setting</title>
<script src="https://unpkg.com/@daily-co/daily-js"></script>
</head>
<body onload="main()">
<script>
// change ROOM_URL to a room in your Daily domain
const ROOM_URL = "https:// A ROOM URL";
@JamieCurnow
JamieCurnow / firestore.ts
Last active November 18, 2024 18:54
Using Firestore with Typescript
/**
* This Gist is part of a medium article - read here:
* https://jamiecurnow.medium.com/using-firestore-with-typescript-65bd2a602945
*/
// import firstore (obviously)
import { firestore } from "firebase-admin"
// Import or define your types
// import { YourType } from '~/@types'
@th3m477
th3m477 / Web3Connection.js
Last active June 13, 2019 21:20
Web3.js websocket connection logic
const RECONNECT_MILLIS = 2000
class Web3Connection {
constructor() {
this.connect()
}
async connect() {
const provider = new Web3.providers.WebsocketProvider('...')
// This is universal, works with Infura -- set provider accordingly
const ethers = require('ethers')
//const provider = ethers.getDefaultProvider('rinkeby')
const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL)
function hex_to_ascii(str1) {
var hex = str1.toString();
var str = '';
for (var n = 0; n < hex.length; n += 2) {