Skip to content

Instantly share code, notes, and snippets.

View steven-tey's full-sized avatar
👷
building infra for the next trillion links on the web @dubinc

Steven Tey steven-tey

👷
building infra for the next trillion links on the web @dubinc
View GitHub Profile
@pontusab
pontusab / import.ts
Last active March 14, 2024 13:30
Import background job
import crypto from "node:crypto";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { ChatOpenAI } from "@langchain/openai";
import { eventTrigger } from "@trigger.dev/sdk";
import { capitalCase } from "change-case";
import * as d3 from "d3-dsv";
import { CSVLoader } from "langchain/document_loaders/fs/csv";
import { TokenTextSplitter } from "langchain/text_splitter";
import { z } from "zod";
import { client, supabase } from "../client";
@veekaybee
veekaybee / normcore-llm.md
Last active November 15, 2024 12:06
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

@steven-tey
steven-tey / title-from-url.ts
Last active July 29, 2024 20:57
Get Title from URL
// Note: this gist is a part of this OSS project that I'm currently working on: https://github.com/steven-tey/dub
export default async function getTitleFromUrl (url: string) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 2000); // timeout if it takes longer than 2 seconds
const title = await fetch(url, { signal: controller.signal })
.then((res) => {
clearTimeout(timeoutId);
return res.text();
})
@av01d
av01d / convertDataURItoBinary.js
Created January 20, 2022 13:15
Convert base64 string to Uint8Array (one liner)
/**
* One liner to convert a base64 string to a binary Uint8Array
*
* Example:
* const dataURL = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2w....';
* console.log(convertDataURIToBinary(dataURL));
*/
const convertDataURIToBinary = dataURI =>
Uint8Array.from(window.atob(dataURI.replace(/^data[^,]+,/,'')), v => v.charCodeAt(0));
@MehediH
MehediH / cazoo.js
Created November 21, 2021 20:09
cazoo cloudflare worker
const cazooApiUrl = "https://www.cazoo.co.uk/api/search?sort=createdAt-desc&runningCosts=ulezChargeExempt&fuelType=Petrol%2CElectric%2CPlug_in_Hybrid%2CHybrid&gearbox=Automatic&ownershipType=purchase&maxMonthlyPrice=280";
const discordWebhookUrl = "https://discord.com/api/webhooks/ENTER_YOUR_WEBHOOK"
/*
For this to work, you need to setup Workers KV https://developers.cloudflare.com/workers/runtime-apis/kv
Here, my KV namespace is called CAZOO
For the worker to actually get triggered, you'll also need to set up a cron job from the Workers UI in Cloudflare
*/
async function handleRequest() {
@BjornDCode
BjornDCode / gist:5cb836a6b23638d6d02f5cb6ed59a04a
Created February 3, 2020 11:58
Tailwind - Fixed sidebar, scrollable content
// Source: https://twitter.com/calebporzio/status/1151876736931549185
<div class="flex">
<aside class="h-screen sticky top-0">
// Fixed Sidebar
</aside>
<main>
// Content
</main>
@wallawe
wallawe / image_upload_cloudinary.js
Last active September 7, 2023 03:20
Cloudinary v2 image uploader component in React (using Next.js)
import { Component } from 'react'
import Head from 'next/head'
const CLOUD_NAME = '<name here>'
export default class ImageUploader extends Component {
constructor(props) {
super(props)
this.uploader = null
anonymous
anonymous / r code to debug
Created August 24, 2016 13:28
city.names <- c("A", "B", "C", "D", "E", "F", "G", "H")
observed.turnout = c(18, 30, 14, 52, 24, 29, 48, 49)
observed.diffmeans <- mean(observed.turnout[c(2,4,6,8)]) -
mean(observed.turnout[c(1,3,5,7)])
print(observed.diffmeans)
foo <- as.data.frame(city.names, observed.turnout)
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);