countGithubLOCUIREADME.md1 match
9## What It Does
1011This simple tool fetches the GitHub repository as a ZIP file,
12decompresses it on the fly (thanks to `fflate` 💨),
13and counts the lines of code — on val.town
countGithubLOCmain.tsx1 match
5const repo = `${username}/${repoName}`;
6const url = `https://github.com/${repo}/archive/refs/heads/master.zip`;
7fetch(url)
8.then((res) => {
9if (!res.ok || !res.body) return reject(new Error(`HTTP error! status: ${res.status}`));
multilingualchatroommain.tsx21 matches
195useEffect(() => {
196if (roomId) {
197const fetchDefaultUsername = async () => {
198try {
199// First, check if there's a username in localStorage
202setUsername(storedUsername);
203} else {
204// If not, fetch a default username from the server
205const response = await fetch(`/default-username?room=${roomId}`);
206if (response.ok) {
207const defaultUsername = await response.text();
218}
219} catch (error) {
220console.error("Error fetching default username:", error);
221}
222};
223224fetchDefaultUsername();
225}
226}, [roomId]);
230const pollMessages = async () => {
231try {
232const response = await fetch(`/messages?room=${roomId}&language=${language}`);
233if (response.ok) {
234const newMessages = await response.json();
242}
243} catch (error) {
244console.error("Error fetching messages:", error);
245}
246};
247248const fetchUsers = async () => {
249try {
250const response = await fetch(`/users?room=${roomId}`);
251if (response.ok) {
252const userList = await response.json();
254}
255} catch (error) {
256console.error("Error fetching users:", error);
257}
258};
259260const fetchTypingUsers = async () => {
261try {
262const response = await fetch(`/typing-users?room=${roomId}`);
263if (response.ok) {
264const typingUsersList = await response.json();
266}
267} catch (error) {
268console.error("Error fetching typing users:", error);
269}
270};
271272pollMessages();
273fetchUsers();
274fetchTypingUsers();
275const messageIntervalId = setInterval(pollMessages, 2000);
276const userIntervalId = setInterval(fetchUsers, 5000);
277const typingIntervalId = setInterval(fetchTypingUsers, 1000);
278279return () => {
289if (language !== "en") {
290try {
291const translatedMessage = await fetch("/translate-text", {
292method: "POST",
293headers: { "Content-Type": "application/json" },
315if (inputMessage && roomId && username) {
316try {
317const response = await fetch("/send-message", {
318method: "POST",
319headers: { "Content-Type": "application/json" },
346} else {
347try {
348const response = await fetch("/update-user", {
349method: "POST",
350headers: { "Content-Type": "application/json" },
403if (roomId && username) {
404try {
405await fetch("/update-typing", {
406method: "POST",
407headers: { "Content-Type": "application/json" },
cheerfulCyanBarnaclemain.tsx7 matches
1import { fetch } from "https://esm.town/v/std/fetch";
23export const bookReservationOnResy = async ({
145)
146}&password=${encodeURIComponent(params.password)}`;
147const response = await fetch(`${RESY_API_URL}/3/auth/password`, {
148method: "POST",
149body: body,
167}) => {
168const url = `${RESY_API_URL}/3/details`;
169const response = await fetch(url.toString(), {
170method: "POST",
171headers: RESY_DEFAULT_HEADERS,
192searchParams.set("party_size", params.seats.toString());
193searchParams.set("venue_id", params.venueId);
194const response = await fetch(`${url}?${searchParams}`, {
195method: "GET",
196headers: RESY_DEFAULT_HEADERS,
212searchParams.set("url_slug", params.slug);
213searchParams.set("location", params.city);
214const response = await fetch(`${url}?${searchParams}`, {
215method: "GET",
216headers: RESY_DEFAULT_HEADERS,
224authToken: string;
225}) => {
226const response = await fetch(`${RESY_API_URL}/3/book`, {
227method: "POST",
228headers: {
252venueId,
253});
254console.log("Fetched available slots for day", {
255count: slots.length,
256times: slots.map((slot) => `${slot.date.start} -> ${slot.date.end}`),
3const repo = 'val-town/sdk';
4const url = `https://github.com/${repo}/archive/refs/heads/master.zip`;
5const res = await fetch(url);
67const unzip = new Unzip(onfile);
generateframeImageREADME.md1 match
5### Why
6I'm using this val for my 3-color e-ink display run by a Raspberry Pi Zero W. The Pi runs a cron job that tell's it
7to fetch this url twice a day and render it to the display. Works like a charm.
89Right now I'm not displaying much but I'm going to keep iterating on what type of information I want to display.
multilingualchatroommain.tsx21 matches
195useEffect(() => {
196if (roomId) {
197const fetchDefaultUsername = async () => {
198try {
199// First, check if there's a username in localStorage
202setUsername(storedUsername);
203} else {
204// If not, fetch a default username from the server
205const response = await fetch(`/default-username?room=${roomId}`);
206if (response.ok) {
207const defaultUsername = await response.text();
218}
219} catch (error) {
220console.error("Error fetching default username:", error);
221}
222};
223224fetchDefaultUsername();
225}
226}, [roomId]);
230const pollMessages = async () => {
231try {
232const response = await fetch(`/messages?room=${roomId}&language=${language}`);
233if (response.ok) {
234const newMessages = await response.json();
242}
243} catch (error) {
244console.error("Error fetching messages:", error);
245}
246};
247248const fetchUsers = async () => {
249try {
250const response = await fetch(`/users?room=${roomId}`);
251if (response.ok) {
252const userList = await response.json();
254}
255} catch (error) {
256console.error("Error fetching users:", error);
257}
258};
259260const fetchTypingUsers = async () => {
261try {
262const response = await fetch(`/typing-users?room=${roomId}`);
263if (response.ok) {
264const typingUsersList = await response.json();
266}
267} catch (error) {
268console.error("Error fetching typing users:", error);
269}
270};
271272pollMessages();
273fetchUsers();
274fetchTypingUsers();
275const messageIntervalId = setInterval(pollMessages, 2000);
276const userIntervalId = setInterval(fetchUsers, 5000);
277const typingIntervalId = setInterval(fetchTypingUsers, 1000);
278279return () => {
289if (language !== "en") {
290try {
291const translatedMessage = await fetch("/translate-text", {
292method: "POST",
293headers: { "Content-Type": "application/json" },
315if (inputMessage && roomId && username) {
316try {
317const response = await fetch("/send-message", {
318method: "POST",
319headers: { "Content-Type": "application/json" },
346} else {
347try {
348const response = await fetch("/update-user", {
349method: "POST",
350headers: { "Content-Type": "application/json" },
403if (roomId && username) {
404try {
405await fetch("/update-typing", {
406method: "POST",
407headers: { "Content-Type": "application/json" },
Update_Wise_Old_ManREADME.md1 match
6## Config
78You need an environment variable called `OSRS_USERS`, which has a comma-separated string of usernames to fetch
910Example: `OSRS_USERS=zezima,LynxTitan,Mageboy20`
8586try {
87const response = await fetch("/", {
88method: "POST",
89body: JSON.stringify({ prompt, currentCode: code, errorMessage: shaderErrorMessage }),
dailyDadJokemain.tsx2 matches
1import { email } from "https://esm.town/v/std/email";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
34export async function dailyDadJoke() {
5let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6return email({
7text: punchline,