Skip to content

Instantly share code, notes, and snippets.

@ashbuilds
ashbuilds / server.ts
Last active May 30, 2024 14:38
Implementing GraphQL Subscriptions with Websockets in a Bun Server using graphql-yoga
import Bun from 'bun'
import { createYoga, YogaInitialContext, YogaServerInstance } from 'graphql-yoga'
import { makeHandler } from "graphql-ws/lib/use/bun";
import { ExecutionArgs } from "@envelop/types";
import { schema } from './graphql/schema';
interface IUserContext {
token?: string;
}
@ashbuilds
ashbuilds / NotionQAClient.ts
Last active June 8, 2023 09:48
The NotionPageAI class enables integration between Notion pages and AI-powered functionalities. It provides methods for generating embeddings, storing them in a vectorDB, and performing conversational question-answering based on indexed Notion pages.
import { Client as NotionClient } from '@notionhq/client';
import { createClient, SupabaseClient } from '@supabase/supabase-js';
import { ConversationalRetrievalQAChain } from 'langchain/chains';
import { OpenAIEmbeddings } from 'langchain/embeddings/openai';
import { OpenAIChat } from 'langchain/llms/openai';
import { BufferMemory } from 'langchain/memory';
import { ContextualCompressionRetriever } from 'langchain/retrievers/contextual_compression';
import { LLMChainExtractor } from 'langchain/retrievers/document_compressors/chain_extract';
import { ChainValues, LLMResult } from 'langchain/schema';
@ashbuilds
ashbuilds / pa_cal.cfg
Created October 19, 2022 15:44 — forked from JeremyKennedy/pa_cal.cfg
Klipper Pressure Advance Line Calibration Macro
[gcode_macro PA_CAL]
# Klipper pressure advance line calibration macro.
# Usage: PA_CAL BED=100 NOZZLE=240 PA_START=0.0 PA_STOP=0.1 NZL=0.4
# Or you can execute with no parameters, which will use values from printer.cfg and saved_variables.cfg.
# First prints a line with current set PA, then prints 21 additional line segments starting with PA_START, and increasing to PA_STOP.
# Based on http://realdeuce.github.io/Voron/PA/pressure_advance.html
# Cleaned up and moved to using saved_variables.cfg by u/jibbsisme
# Sourced from u/Deepsiks, assisted by u/imoftendisgruntled, u/scul86, and thanks to u/beansisfat, u/stray_r
description: Tune Pressure Advance
@ashbuilds
ashbuilds / install-quick-dev.sh
Last active December 13, 2019 08:39
Bash to install docker, docker-compose and git centos.
#!/bin/bash
install_docker () {
sudo yum remove -y docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
@ashbuilds
ashbuilds / install-docker.sh
Last active December 11, 2019 16:53
Install docker and docker-compose in Centos
#!/bin/bash
install_docker () {
sudo yum remove -y docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \