1async function fetchHackerNews() {
2try {
3const response = await fetch("https://news.ycombinator.com/");
14}
1516export default async function(req: Request): Promise<Response> {
17const hackerNews = await fetchHackerNews();
18// return Response.json({ ok: true })
satori-syntax-highlighterutils.ts2 matches
23// Get the base URL from a request URL
4export function getBaseUrl(url: string): string {
5const parsedUrl = new URL(url);
6return `${parsedUrl.protocol}//${parsedUrl.host}`;
89// Build the highlighter URL with parameters
10export function buildHighlighterUrl(
11baseUrl: string,
12code: string,
12export const DEFAULT_CODE = `const btn = document.getElementById('btn')
13let count = 0
14function render() {
15btn.innerText = \`Count: \${count}\`
16}
JobChatAppREADME.md1 match
19โ โโโ database/
20โ โ โโโ migrations.ts # Schema definitions
21โ โ โโโ queries.ts # DB query functions
22โ โโโ routes/ # Route modules
23โ โ โโโ jobs.ts # Job posting endpoints
NPLLMpackage-generator.ts7 matches
7* Generates a TypeScript implementation for a package based on its name and description
8*/
9export async function generatePackageImplementation(
10packageName: string,
11description: string,
18The implementation should:
191. Be a single TypeScript file
202. Export a main function or class that fulfills the package description
213. Include proper JSDoc comments
224. Be simple but functional
235. Include 2-3 helper functions if appropriate
2425Only return the TypeScript code without any explanation or markdown formatting.
34* In a real-world scenario, you would use the TypeScript compiler API
35*/
36export function compileTypeScript(tsCode: string): string {
37// This is a very simplified "compilation" that just removes TypeScript types
38// In a real implementation, you would use the TypeScript compiler
48* Creates a tar archive for an npm package
49*/
50export async function createPackageTar(
51packageName: string,
52version: string = "1.0.0",
90*/
91${
92tsImplementation.replace(/export function/g, "export declare function")
93.replace(/export class/g, "export declare class")
94.replace(/export const/g, "export declare const")
untitled-860checkCert.tsx4 matches
1// This function checks a domain's SSL certificate and extracts the expiration date
2// It can be set up as a scheduled (cron) val to monitor certificate expiration
34export default async function checkCertExpiration(domain) {
5// Default to cdatacloud.net if no domain is provided
6domain = domain || "www.cdatacloud.net";
22// So we need to use the tls module in Node.js or Deno's TLS APIs
2324// For Val Town, we can use Deno's TLS connect function
25const conn = await Deno.connectTls({
26hostname: domain,
62// If you want to run this as a cron job, you could set up email notifications
63// when certificates are close to expiration
64export async function certExpirationCron() {
65const domains = [
66"www.cdatacloud.net",
3233// Initialize the board
34function initializeBoard() {
35const board = Array(8).fill().map(() => Array(8).fill(null));
36
5253// Render the chess board
54function renderBoard() {
55const chessboard = document.getElementById('chessboard');
56chessboard.innerHTML = '';
118119// Get Unicode symbol for chess piece
120function getPieceSymbol(piece) {
121const symbols = {
122'white': {
142143// Handle square click
144function handleSquareClick(event) {
145if (gameState.gameOver) return;
146
185186// Select a piece and calculate valid moves
187function selectPiece(row, col) {
188gameState.selectedPiece = { row, col };
189gameState.validMoves = calculateValidMoves(row, col);
192193// Make a move
194function makeMove(from, to, special) {
195const piece = gameState.board[from.row][from.col];
196const capturedPiece = gameState.board[to.row][to.col];
264265// Handle special moves like castling and en passant
266function handleSpecialMoves(piece, from, to, special) {
267if (!special) return;
268
297298// Calculate valid moves for a piece
299function calculateValidMoves(row, col) {
300const piece = gameState.board[row][col];
301if (!piece) return [];
331332// Calculate pawn moves
333function calculatePawnMoves(row, col, piece) {
334const moves = [];
335const direction = piece.color === 'white' ? -1 : 1;
367368// Calculate knight moves
369function calculateKnightMoves(row, col, piece) {
370const moves = [];
371const offsets = [
392393// Calculate bishop moves
394function calculateBishopMoves(row, col, piece) {
395const moves = [];
396const directions = [
424425// Calculate rook moves
426function calculateRookMoves(row, col, piece) {
427const moves = [];
428const directions = [
456457// Calculate queen moves (combination of bishop and rook)
458function calculateQueenMoves(row, col, piece) {
459return [
460...calculateBishopMoves(row, col, piece),
464465// Calculate king moves
466function calculateKingMoves(row, col, piece) {
467const moves = [];
468const directions = [
556557// Check if a square is within the bounds of the board
558function isInBounds(row, col) {
559return row >= 0 && row < 8 && col >= 0 && col < 8;
560}
561562// Check if a square is attacked by the opponent
563function isSquareAttacked(row, col, color) {
564const opponentColor = color === 'white' ? 'black' : 'white';
565
671672// Check if a player is in check
673function isInCheck(color) {
674const kingPosition = gameState.kingPositions[color];
675return isSquareAttacked(kingPosition.row, kingPosition.col, color);
677678// Check if a move would leave the king in check
679function wouldBeInCheck(color, from, to, special) {
680// Create a temporary copy of the board
681const tempBoard = gameState.board.map(row => [...row]);
812813// Promote a pawn
814function promotePawn(row, col) {
815// Create a modal for promotion options
816const modal = document.createElement('div');
853854// Check game status (check, checkmate, stalemate)
855function checkGameStatus() {
856// Check if the current player is in check
857const isCheck = isInCheck(gameState.currentPlayer);
902903// Check for insufficient material (draw condition)
904function isInsufficientMaterial() {
905let whitePieces = [];
906let blackPieces = [];
963964// Update game status display
965function updateGameStatus() {
966const statusElement = document.getElementById('game-status');
967
980981// Update captured pieces display
982function updateCapturedPieces() {
983const whiteCapturedElement = document.getElementById('captured-pieces-white');
984const blackCapturedElement = document.getElementById('captured-pieces-black');
989990// Reset the game
991function resetGame() {
992gameState.board = initializeBoard();
993gameState.currentPlayer = 'white';
1import { serveFile, readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
23export default async function(req: Request) {
4const url = new URL(req.url);
5const path = url.pathname;
1# Val Town Chess
23A fully functional chess game implemented in JavaScript for Val Town. This game includes all standard chess rules and features.
45## Features
18- Draw conditions (insufficient material, 50-move rule)
19- Captured pieces display
20- Reset game functionality
2122## How to Play
52Potential enhancements for the future:
53- Move history and notation
54- Undo move functionality
55- Timer/clock for timed games
56- Save/load game state
StarterPackFeedsHome.tsx4 matches
10import { UserAvatarsRow } from './StarterPack.tsx'
1112export function Home() {
13const [context, setContext] = useState<any>()
14useEffect(() => {
37}
3839function CuratedPacks() {
40const curatedPacks = [
41'independent-journalists-glnse9',
56}
5758function PackCard({ packId }) {
59const { data: starterPack, isLoading } = useQuery({
60queryKey: ['pack', packId],
94}
9596function VisitForm({}) {
97const navigate = useNavigate()
98const [url, setUrl] = useState('')