Townieusage-dashboard.ts4 matches
45// Basic Auth middleware
6async function basicAuthMiddleware(req: Request): Promise<Response | null> {
7const realm = "Usage Dashboard";
8const unauthorizedResponse = new Response("Unauthorized", {
50}
5152export default async function(req: Request) {
53// Check authentication first
54const authResponse = await basicAuthMiddleware(req);
288289<script>
290document.addEventListener('DOMContentLoaded', function() {
291// Add click event listeners to all tabs
292document.querySelectorAll('.tab').forEach(tab => {
293tab.addEventListener('click', function() {
294const tabId = this.getAttribute('data-tab');
295
glastonewsindex.ts5 matches
910// ======= Fetch HTML with Improved Retry =======
11async function fetchHtmlWithRetry(url, options = {}, retries = 5, delay = 1000) {
12for (let i = 0; i < retries; i++) {
13try {
7172// ======= Fetch News =======
73async function fetchNews() {
74const url = "https://glastonburyfestivals.co.uk/news/";
75try {
9495// ======= Fetch Your Own Recent Bluesky Post Titles =======
96async function fetchOwnRecentPostTitles(agent, handle, limit = 100) {
97const feed = await agent.getAuthorFeed({ actor: handle, limit });
98return feed.data.feed.map(item => item.post.record.text);
100101// ======= Fetch Embed Data =======
102async function fetchEmbedData(url) {
103try {
104const html = await fetchHtmlWithRetry(url);
168169// ======= Main Bot =======
170async function main() {
171try {
172await agent.login({
untitled-5581lambdaCalculus.ts11 matches
19// c: cutoff - indices >= c are shifted, < c are bound locally and untouched
20// term: the term to process
21function shift(d: number, c: number, term: Term): Term {
22switch (term.type) {
23case "var":
39// s: the replacement term
40// term: the term in which substitution occurs
41function substitute(j: number, s: Term, term: Term): Term {
42switch (term.type) {
43case "var":
63// 2. substitute(0, <shifted_t2>, t1): Replace Var(0) in t1 with the shifted t2.
64// 3. shift(-1, 0, <result>): Decrement free variables in the result as the outer lambda binder is removed.
65function betaReduce(absBody: Term, arg: Term): Term {
66const shiftedArg = shift(1, 0, arg);
67const substitutedBody = substitute(0, shiftedArg, absBody);
72// Single Step Reducer (Normal Order)
73// --------------------------
74function reduceStep(term: Term): Term | null {
75switch (term.type) {
76case "app":
79return betaReduce(term.func.body, term.arg);
80}
81// Rule 2: t1 t2 ---> t1' t2 (Reduce function part)
82const reducedFunc = reduceStep(term.func);
83if (reducedFunc) {
107// Full Reducer
108// --------------------------
109function reduce(term: Term, maxSteps: number = 100, verbose: boolean = false): Term {
110let currentTerm = term;
111if (verbose) console.log(`Reducing: ${termToString(currentTerm)}`);
124125// --------------------------
126// toString Function
127// --------------------------
128const baseVarNames = "xyzabcdefghijklmnopqrstuvw";
129130function generateVarName(depth: number, usedNames: string[]): string {
131let name: string;
132let tempDepth = depth;
149}
150151function termToStringInternal(term: Term, boundNames: string[]): string {
152switch (term.type) {
153case "var":
183}
184185function termToString(term: Term): string {
186return termToStringInternal(term, []);
187}
256const Y = Abs(App(Y_inner, Y_inner));
257258// A sample function F (e.g. identity I)
259const F_for_Y_test = I;
260const test_Y_F = App(Y, F_for_Y_test);
templateTwitterAlertREADME.md2 matches
46- Key: `mentionsDiscord`
47- Value: Your Discord webhook URL.
48Notifications will be sent using this function:
4950```ts
6364- **Proxies via Val Town's [SocialDataProxy](https://www.val.town/v/stevekrouse/socialDataProxy)**: Limited to 10 cents per day for [**Val Town Pro users**](https://www.val.town/pricing). This API is *only* for Pro users.
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.
templateTwitterAlertmain.tsx1 match
12const isProd = false;
1314export async function twitterAlert({ lastRunAt }: Interval) {
15// If isProd, search for tweets since that last time this interval ran
16// if not, search for tweets since 48 hours ago for testing
testtowniePostView.tsx2 matches
13}
1415export function PostView({ post }: PostViewProps) {
16// Format date
17const formatDate = (timestamp: number) => {
27if (typeof marked !== 'undefined' && typeof hljs !== 'undefined') {
28marked.setOptions({
29highlight: function(code: string, language: string) {
30if (language && hljs.getLanguage(language)) {
31return hljs.highlight(code, { language }).value;
testtowniePostList.tsx2 matches
8}
910export function PostList({ posts }: PostListProps) {
11if (posts.length === 0) {
12return (
18}
1920// Format date function
21const formatDate = (timestamp: number) => {
22return new Date(timestamp).toLocaleDateString('en-US', {
testtownieFooter.tsx1 match
3import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
45export function Footer() {
6const currentYear = new Date().getFullYear();
7const projectInfo = React.useMemo(() => {
testtownieHeader.tsx1 match
3import { Link } from "https://esm.sh/react-router-dom@6.20.1?deps=react@18.2.0";
45export function Header() {
6return (
7<header className="bg-white shadow-sm">
testtownieindex.tsx6 matches
1011// Main App component
12function App() {
13return (
14<BrowserRouter>
2930// Home page component
31function Home() {
32const [posts, setPosts] = React.useState<PostWithTags[]>([]);
33const [loading, setLoading] = React.useState(true);
3536React.useEffect(() => {
37async function fetchPosts() {
38try {
39const response = await fetch('/api/posts');
7475// Single post page component
76function Post() {
77const { slug } = useParams<{ slug: string }>();
78const [post, setPost] = React.useState<PostWithTags | null>(null);
8283React.useEffect(() => {
84async function fetchPost() {
85if (!slug) return;
86
139140// 404 Not Found component
141function NotFound() {
142return (
143<div className="text-center py-12">