markdown_downloadmain.tsx10 matches
16* @returns markdown in string
17*/
18export async function html2markdown(html: string): Promise<string> {
19if (AgentMarkdownImport) {
20// TurndownService doesn't work on cf
34* @returns markdown in string
35*/
36export async function readability2markdown(html: string): Promise<{ title: string; markdown: string }> {
37const doc = await (new DOMParser().parseFromString(html, "text/html"));
3844}
4546function response(message: string, contentType = "text/markdown"): Response {
47const headers = new Headers();
48headers.set("Access-Control-Allow-Origin", "*");
64}
6566function err(msg: string): Response {
67const errorMessage = JSON.stringify({
68error: {
74}
7576function fudgeURL(url: string) {
77try {
78return new URL(url);
83}
8485async function processInput(req: Request) {
86let ret = {
87url: undefined as undefined | URL,
129}
130131export async function youtube2markdown(url: URL): Promise<string | undefined> {
132function getYoutubeVideoID(url: URL): string | null {
133const regExp = /(?:youtube\.com\/(?:[^/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?/\s]{11})/i;
134const match = url.href.match(regExp);
161* Simple UI that takes a url
162*/
163export function generate_ui(input_description: string, link: string, link_text: string): string {
164const html = `
165<!DOCTYPE html>
195}
196197export default async function(req: Request): Promise<Response> {
198const action = await processInput(req);
199const url = action.url;
102];
103104function App() {
105const [selectedItem, setSelectedItem] = useState(null);
106const [showWords, setShowWords] = useState(true);
176}
177178function client() {
179createRoot(document.getElementById("root")).render(<App />);
180}
184}
185186export default async function server(request: Request): Promise<Response> {
187const randomColor = Math.floor(Math.random() * 16777215).toString(16);
188return new Response(
111) Interactive vocabulary grid
12132) Real-time search functionality
14153) Word visibility toggle
RobotBackupCallGraphmain.tsx15 matches
2import { thisWebURL } from "https://esm.town/v/stevekrouse/thisWebURL?v=2";
34export default async function server(req: Request): Promise<Response> {
5// Handle GET requests
6if (req.method === "GET") {
288layout: {
289name: 'preset',
290positions: function(node) {
291return { x: 0, y: 0 }; // Initial positions, will be overwritten
292}
297});
298299// Custom layout function
300function customLayout() {
301const mainGraph = cy.elements().not('#isolated, #isolated > node');
302const isolatedGraph = cy.getElementById('isolated');
349350// Add event listeners for highlighting
351cy.on('mouseover', 'node', function(e) {
352const node = e.target;
353highlightNodeChildrenAndParents(node);
354});
355356cy.on('mouseout', 'node', function(e) {
357unhighlightAll();
358});
359360cy.on('click', 'node', function(e) {
361const node = e.target;
362if (node.hasClass('highlighted') || node.hasClass('parent-highlighted')) {
368});
369370function highlightNodeChildrenAndParents(node) {
371const children = node.outgoers();
372const parents = node.incomers();
376}
377378function unhighlightAll() {
379cy.elements().removeClass('highlighted');
380cy.elements().removeClass('parent-highlighted');
529let match;
530while ((match = callRegex.exec(line)) !== null) {
531const calledFunction = match[1].toLowerCase();
532relationships.get(caller).add(calledFunction);
533allNodes.add(calledFunction);
534}
535});
545546const edges = [];
547relationships.forEach((calledFunctions, file) => {
548calledFunctions.forEach(calledFunction => {
549edges.push({
550data: {
551source: file,
552target: calledFunction,
553},
554});
wakatime-readme-chartmain.tsx7 matches
12}
1314function roundRect(
15ctx: any,
16x: any,
39}
4041function roundRectTop(
42ctx: any,
43x: any,
64}
6566function App() {
67const [chartUrl, setChartUrl] = useState<string | null>(null);
6881}
8283function client() {
84createRoot(document.getElementById("root")!).render(<App />);
85}
89}
9091async function fetchWakaTimeData(): Promise<DataPoint[]> {
92const response = await fetch("https://wakatime.com/share/@load1n9/899abefd-d814-4e99-b603-e94af0305d4a.json");
93const data = await response.json();
98}
99100async function generateChart(data: DataPoint[]): Promise<string> {
101const width = 1000;
102const height = 600;
150}
151152export default async function server(request: Request): Promise<Response> {
153const url = new URL(request.url);
154
1if (import.meta.main) Deno.serve(translate);
23export async function translate(req: Request) {
4if (req.method === "POST") {
5const { code: status, data } = await fetch("https://deepl.deno.dev/translate", {
46};
4748translate = async function () {
49this.setState({ loading: true, translation: "" });
50const { text, source_lang, target_lang } = this.state;
53}.bind(this);
5455swap = function () {
56if (this.state.source_lang.toLowerCase() === "auto") {
57this.setState({ source_lang: "en" });
63}.bind(this);
6465handleShortcut = function (e) {
66if (this.state.loading !== true && e.ctrlKey && e.key === "Enter") {
67this.translate();
126render(html\`<\${App} page="All" />\`, document.body);
127128async function translate({ text, source_lang, target_lang }) {
129const Options = z.object({
130text: z.string(),
6const EMAIL_INTERVAL_DAYS = 14 // Send email every 2 weeks
78async function ensureTableExists() {
9await sqlite.execute(`
10CREATE TABLE IF NOT EXISTS ${KEY}_xstate_downloads_${SCHEMA_VERSION} (
24}
2526async function fetchAndProcessData() {
27const response = await fetch(
28'https://api.npmjs.org/versions/xstate/last-week',
60}
6162async function isTableEmpty() {
63const result = await sqlite.execute(`
64SELECT COUNT(*) as count FROM ${KEY}_xstate_downloads_${SCHEMA_VERSION}
67}
6869async function getStats() {
70const results = await sqlite.execute(`
71SELECT
90}
9192async function checkAndSendEmail() {
93const lastSentResult = await sqlite.execute(`
94SELECT last_sent_date FROM ${KEY}_email_log_${SCHEMA_VERSION}
141}
142143export default async function server(req: Request,): Promise<Response> {
144await ensureTableExists()
145155}
156157export default async function cron(interval: Interval,): Promise<void> {
158await ensureTableExists()
159await fetchAndProcessData()
160}
161162// Schedule the function to run once per day starting from tomorrow
163const tomorrow = new Date()
164tomorrow.setDate(tomorrow.getDate() + 1,)
selfDestructmain.tsx1 match
2import { fetchValInfo } from "https://esm.town/v/pomdtr/fetchValInfo?v=2";
34export async function selfDestruct(importMetaUrl: string) {
5const { id } = await fetchValInfo(importMetaUrl);
6const { vals } = new ValTown();
5import { LoginWithGoogleButton } from "https://esm.town/v/stevekrouse/LoginWithGoogleButton";
67function App({ initialEmail }) {
8const [email, setEmail] = useState(initialEmail);
940}
4142function client() {
43const initialEmail = document.getElementById('root').dataset.email;
44createRoot(document.getElementById("root")).render(<App initialEmail={initialEmail} />);
49}
5051async function handler(request: Request): Promise<Response> {
52const url = new URL(request.url);
53const email = request.headers.get("X-LastLogin-Email");
telegramWebhookEchoMessageOLDmain.tsx17 matches
47};
4849async function handleMessage(message) {
50const userMessage = message.text;
51const chatId = message.chat.id;
62}
6364async function processUserInputWithAI(userMessage: string, tasks: Task[], state: UserState): Promise<{ response: string, updatedTasks: Task[], updatedState: UserState, suggestedActions: string[] }> {
65const taskListString = JSON.stringify(tasks);
66const stateString = JSON.stringify(state);
78Based on the user's message and the conversation context, determine the appropriate action to take and execute it.
79Be proactive in guiding the user through their tasks, focusing on prioritization and breaking down tasks into microsteps.
80You can use the following functions:
81- addTask(tasks: Task[], title: string): Adds a new task
82- markTaskAsDone(tasks: Task[], taskId: string): Marks a task as done
138}
139140function addTask(tasks: Task[], title: string) {
141const newTask: Task = {
142id: Date.now().toString(),
150}
151152function markTaskAsDone(tasks: Task[], taskId: string) {
153const task = findTask(tasks, taskId);
154if (task) {
157}
158159function breakDownTask(tasks: Task[], taskId: string, subtasks: string[]) {
160const task = findTask(tasks, taskId);
161if (task) {
175}
176177function findTask(tasks: Task[], taskId: string): Task | null {
178return tasks.find(task => task.id === taskId) || null;
179}
180181function compareTaskPriorities(tasks: Task[], taskId1: string, taskId2: string) {
182const task1 = findTask(tasks, taskId1);
183const task2 = findTask(tasks, taskId2);
191}
192193function suggestMicrosteps(taskTitle: string): string[] {
194// This function would ideally use AI to generate suggestions, but for simplicity, we'll return static suggestions
195return ["Get materials", "Prepare workspace", "Start first step"];
196}
197198function navigateTaskHierarchy(tasks: Task[], currentTaskId: string | null, direction: 'up' | 'down' | 'next' | 'prev'): string | null {
199if (!currentTaskId) return null;
200const currentTask = findTask(tasks, currentTaskId);
217}
218219function generateTaskList(tasks: Task[], showCompleted: boolean, parentId: string | null = null, indent = ''): string {
220let list = '';
221const currentLevelTasks = tasks.filter(task => task.parent_id === parentId && (showCompleted || !task.done));
231}
232233async function sendResponse(chatId: number, message: string, suggestedActions: string[]) {
234const keyboard = [
235...suggestedActions.map(action => [{ text: action }]),
254}
255256async function getTasks(chatId: number): Promise<Task[]> {
257const key = `tasks_${chatId}`;
258try {
265}
266267async function updateTasks(chatId: number, tasks: Task[]) {
268const key = `tasks_${chatId}`;
269try {
274}
275276async function getUserState(chatId: number): Promise<UserState> {
277const key = `state_${chatId}`;
278try {
285}
286287async function updateUserState(chatId: number, state: UserState) {
288const key = `state_${chatId}`;
289try {