darkMagentaFlamingoREADME.md1 match
1Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality
convenientAzureSparrowmain.tsx2 matches
4const apiKey = "your_api_key";
56// Function to send SMS
7async function sendSMS(to, from) {
8try {
9const response = await axios.post(
numbergamemain.tsx4 matches
27const HUE_DIFF = 25;
2829function getColor(value: number): string {
30const power = Math.log2(value / 2);
31const hue = (power * HUE_DIFF) % 360;
33}
3435function App() {
36const [board, setBoard] = useState<number[][]>([]);
37const [selectedCells, setSelectedCells] = useState<[number, number][]>([]);
281}
282283function client() {
284createRoot(document.getElementById("root")).render(<App />);
285}
289}
290291async function server(request: Request): Promise<Response> {
292return new Response(
293`
easingbattlegroundmain.tsx23 matches
4import { BrowserRouter as Router, Route, Link, Routes } from "https://esm.sh/react-router-dom";
56function EasingVisualizer({ easing }) {
7const canvasRef = React.useRef(null);
813const height = canvas.height;
1415function drawCurve() {
16ctx.clearRect(0, 0, width, height);
17
18const [x1, y1, x2, y2] = easing.params;
19
20const bezierFunction = cubicBezier(x1, y1, x2, y2);
21
22ctx.beginPath();
23ctx.moveTo(0, height);
24for (let t = 0; t <= 1; t += 0.01) {
25const point = bezierFunction(t);
26const x = point.x * width;
27const y = height - point.y * height;
34// Animate the dot
35const time = (Date.now() % 3000) / 3000;
36const point = bezierFunction(time);
37const x = point.x * width;
38const y = height - point.y * height;
44}
4546const animationFrame = requestAnimationFrame(function animate() {
47drawCurve();
48requestAnimationFrame(animate);
55}
5657function cubicBezier(x1, y1, x2, y2) {
58return function(t) {
59const cx = 3 * x1;
60const bx = 3 * (x2 - x1) - cx;
72}
7374function EasingGuide() {
75return (
76<div className="bg-gray-100 p-6 rounded-lg mb-8">
92<h3 className="text-xl font-semibold mb-2">🧙♂️ Cubic-Bezier Magic:</h3>
93<p className="mb-4">
94Input your easing as a cubic-bezier function, like this:
95<code className="bg-gray-200 px-2 py-1 rounded">cubic-bezier(0.05, 0.00, 0.16, 0.13)</code>
96</p>
104}
105106function EasingForm({ onSubmit }) {
107const [newEasing, setNewEasing] = useState({ name: '', author: '', params: [0.05, 0.00, 0.16, 0.13] });
108109function handleSubmit(e) {
110e.preventDefault();
111onSubmit(newEasing);
113}
114115function handleCubicBezierInput(e) {
116const value = e.target.value;
117const match = value.match(/cubic-bezier\(([\d.]+),\s*([\d.]+),\s*([\d.]+),\s*([\d.]+)\)/);
125<form onSubmit={handleSubmit} className="mb-8">
126<div className="mb-4">
127<label htmlFor="easingInput" className="block mb-2 font-semibold">Easing Function (cubic-bezier format):</label>
128<input
129id="easingInput"
163}
164165function Leaderboard({ easings, onVote, votedEasings }) {
166return (
167<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
184}
185186function Home({ easings, onSubmit, onVote, votedEasings }) {
187return (
188<div>
200}
201202function FullLeaderboard({ easings, onVote, votedEasings }) {
203return (
204<div>
214}
215216function App() {
217const [easings, setEasings] = useState([]);
218const [votedEasings, setVotedEasings] = useState([]);
222}, []);
223224async function fetchEasings() {
225const response = await fetch('/easings');
226const data = await response.json();
228}
229230async function submitEasing(newEasing) {
231await fetch('/easings', {
232method: 'POST',
237}
238239async function vote(id, direction) {
240await fetch(`/vote/${id}/${direction}`, { method: 'POST' });
241setVotedEasings([...votedEasings, id]);
256}
257258function client() {
259createRoot(document.getElementById("root")).render(<App />);
260}
264}
265266async function server(request: Request): Promise<Response> {
267const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
268const SCHEMA_VERSION = 1
ChatGPTTextDefinitionUserscriptmain.tsx13 matches
11// ==/UserScript==
1213(function() {
14"use strict";
1571};
7273// Run the function when the page loads
74window.addEventListener("load", () => {
75console.log("Page loaded, running toggleStylesBasedOnWidth");
77});
7879// Also run the function when the window is resized
80window.addEventListener("resize", () => {
81console.log("Window resized, running toggleStylesBasedOnWidth");
201202// Stream processing
203async function* streamProcessor(reader) {
204const decoder = new TextDecoder();
205let buffer = "";
237238// API response handling
239async function processApiResponse(response) {
240const reader = response.body.getReader();
241253254// Selection handling
255async function handleSelection() {
256console.time("handleSelection");
257const selectedText = getSelectedText();
291}
292293// Helper functions
294function getSelectedText() {
295return window.getSelection().toString().trim();
296}
343};
344345// Function to create a new section and append it properly
346const showLoadingPopup = (selectedText) => {
347const popup = createPopup();
362};
363364function clearPreviousPopup() {
365const previousPopup = document.getElementById("definition-popup");
366if (previousPopup) {
427};
428429function createCloseButton() {
430console.log("Creating close button");
431463}
464465async function makeApiRequest(text) {
466console.log(`Preparing to send fetch request for text: "${text}"`);
467try {
482}
483484// Pure functions to calculate dimensions and positioning
485const calculateCharacterSize = () => {
486const tempElement = document.createElement("span");
1# OpenAI ChatGPT helper function
23This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free.
1import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
23async function getOpenAI() {
4// if you don't have a key, use our std library version
5if (Deno.env.get("OPENAI_API_KEY") === undefined) {
14/**
15* Initiates a chat conversation with OpenAI's GPT model and retrieves the content of the first response.
16* This function can handle both single string inputs and arrays of message objects.
17* It supports various GPT models, allowing for flexibility in choosing the model based on the application's needs.
18*
21* @returns {Promise<string>} A promise that resolves to the content of the first response from the completion.
22*/
23export async function chat(
24input: string | Message[],
25options?: Omit<ChatCompletionCreateParamsNonStreaming, "messages">,
caniuse_notifiermain.tsx2 matches
7const dataKey = "caniuse-data";
89function Feature({ feature }: any) {
10const links = feature.links ?? [];
11return (
27}
2829export default async function(interval: Interval) {
30const previousDataUpdatedAt = await blob.getJSON(updatedKey) ?? 0;
31const previousData = await blob.getJSON(dataKey);
clickTrackerWebsitemain.tsx3 matches
7import confetti from 'https://esm.sh/canvas-confetti';
89function App() {
10const [clicks, setClicks] = useState(0);
1149}
5051function client() {
52createRoot(document.getElementById("root")).render(<App />);
53}
55if (typeof document !== "undefined") { client(); }
5657async function server(request: Request): Promise<Response> {
58const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
59const SCHEMA_VERSION = 2
lucia_sqlitemain.tsx5 matches
4import { generateId, Scrypt } from "npm:lucia";
56export async function createTables(userTable: string, sessionTable: string) {
7return sqlite.batch([
8`CREATE TABLE ${userTable} (
22}
2324async function safeExecute({ userTable, sessionTable, query, error }: {
25userTable: string;
26sessionTable: string;
40}
4142export async function createUser({ userTable, sessionTable, username, password, github_id, google_id }: {
43userTable: string;
44sessionTable: string;
65}
6667export async function getUser(
68{ userTable, sessionTable, username, github_id, google_id }: {
69userTable: string;
98}
99100export async function verifyPassword(hashed_password: string, password: string): Promise<boolean> {
101return new Scrypt().verify(hashed_password, password);
102}