https://val.town logo
Join Discord
Powered by
# general
  • now we have an official page about our policy o...
    s

    stevekrouse

    05/18/2023, 6:07 PM
    now we have an official page about our policy on security disclosures - please submit them when you find them 🙏 https://docs.val.town/security-responsible-disclosure
    n
    • 2
    • 1
  • **How I let other users mutate @myhandle.state:...
    o

    ohhhhfudge

    05/18/2023, 11:24 PM
    How I let other users mutate @myhandle.state: I consistently want to write functions for other people to use like:
    Copy code
    jsx
    const notifyIfResourceChanged = () => {
      const data = await checkSomeResource();
      if(data !== @me.lastData) console.email('Something changed!');
      @me.lastData = data;
    }
    Sadly, ^this is no longer possible due to the recent security updates : https://blog.val.town/blog/restricted-library-mode Instead, I achieve the same thing API mode:
    Copy code
    jsx
    // public state val
    const PUBLIC_STATE = {};
    
    // public state updater, called via API mode
    const setPublicState = (key: string, value: any) => {
      const keys = key.split("/");
      let current = @joey.PUBLIC_STATE;
      for (let i = 0; i < keys.length - 1; i++) {
        const key = keys[i];
        if (!current[key]) {
          current[key] = {};
        }
        current = current[key];
      }
      current[keys[keys.length - 1]] = value;
    };
    ^ This allows users to update update PUBLIC_STATE deeply:
    api(@joey.setPublicState, 'a/b/c', 5)
    , which would result in
    { a: { b: { c: 5 } } }
    Here’s an example that will email you whenever your repo get’s a new star on Github, you can just call this function directly (and schedule if desired), without having to fork it to get state setters working: https://www.val.town/v/joey.emailOnGithubStar
    Copy code
    jsx
    // edited for brevity
    const emailOnGithubStar = (userName:string, projectName:string) => {
      const stars = await @joey.getGithubStarsForRepo(userName, projectName);
      if (stars !== @joey.PUBLIC_STATE.STAR_COUNTS[project]) console.email('New star!');
      await api(@joey.setPublicState, `STAR_COUNTS/${project}`, stars);
    }
    n
    s
    • 3
    • 2
  • UI suggestion: multiple unexecuted draft vals o...
    w

    wilt

    05/19/2023, 4:25 PM
    UI suggestion: multiple unexecuted draft vals on the homepage
    n
    s
    • 3
    • 8
  • Migrating From Supabase
    s

    stevekrouse

    05/19/2023, 5:52 PM
    Hey friends! I bunch of you have asked us about our migration away from Supabase, so @tmcw wrote a blog about it! @everyone https://blog.val.town/blog/migrating-from-supabase
    n
    b
    +3
    • 6
    • 15
  • This is great, thanks for writing Tom
    n

    Needle

    05/19/2023, 6:01 PM
    Thread automatically created by ballingt in #1020432421243592717
  • hey, I can't find anything about pricing - how ...
    n

    nitehawk

    05/19/2023, 7:14 PM
    hey, I can't find anything about pricing - how does it work?
    n
    s
    • 3
    • 8
  • what have I done
    z

    zeturk

    05/20/2023, 5:10 AM
    what have I done

    https://cdn.discordapp.com/attachments/1020432421243592717/1109347400314802216/Screenshot_2023-05-20_at_1.09.26_AM.png▾

    n
    s
    • 3
    • 15
  • It would be nice to provide a properly document...
    j

    Jesse

    05/21/2023, 3:32 AM
    It would be nice to provide a properly documented API — the current documentation is at https://docs.val.town/vals#7a2b1483634045fb9977cf39dd182bae > Included API > Vals are evaluated on a limited subset of deno. It includes: > -
    fetch
    to make HTTP requests > -
    Buffer
    - to encode/decode strings > - dynamic
    import
    from npm and https > - [Contact us](https://docs.val.town/01c8eb9c534b4899802f3a9e31d540ab) if you’d like something else added 😊 However, there are other non-ECMAScript APIs which are indeed present, but are unrecognized according to the compiler diagnostic emitter — for example
    TextEncoder
    (see screenshot):
    Copy code
    ts
    const untitled_nmb5TU39 = (text: string): Uint8Array => {
      return new TextEncoder().encode(text); /* Error
                 ~~~~~~~~~~~
      Cannot find name 'TextEncoder'. */
    };
    Using it in another val:
    Copy code
    ts
    const untitled_zu6PjEPZ = [...@me.untitled_nmb5TU39("hello world")];
    outputs:
    Copy code
    [
      104,
      101,
      108,
      108,
      111,
      32,
      119,
      111,
      114,
      108,
      100
    ]

    https://cdn.discordapp.com/attachments/1020432421243592717/1109685172581957632/image.png▾

    n
    s
    • 3
    • 12
  • The documentation currently shows a mix of usin...
    j

    Jesse

    05/21/2023, 3:39 AM
    The documentation currently shows a mix of using the
    export
    keyword and not using it, which is confusing. It doesn't appear to be necessary, and the auto-wrapped IIFEs (https://docs.val.town/vals#37b420a14a6141b093c193580dee145a) don't include it. Perhaps this can become more consistent in the future.
    n
    s
    • 3
    • 7
  • New Thread
    n

    Needle

    05/21/2023, 5:13 AM
    Thread automatically created by darrinm in #1020432421243592717
  • @stevekrouse Unless you’ve intentionally not cr...
    j

    Jesse

    05/21/2023, 12:07 PM
    @stevekrouse Unless you’ve intentionally not created Discord forum channels for things like ideas/features/etc., it might be useful to have them for organizing feedback and keeping the bugs channel on-topic
    n
    s
    • 3
    • 3
  • The docs don't explain: why is `setTimeout` una...
    j

    Jesse

    05/21/2023, 1:38 PM
    The docs don't explain: why is
    setTimeout
    unavailable? If we need to implement a short-delayed retry behavior, it would be useful. This alternative hack works, but surely you don't want that kind of wasted CPU usage...
    Copy code
    ts
    // Not allowed:
    function delay(ms: number): Promise<void> {
      return new Promise((res) => setTimeout(res, ms));
    }
    
    // But this works 😈:
    async function delay(ms: number): Promise<void> {
      const futureTime = Date.now() + ms;
      while (Date.now() < futureTime) {/* Warm the CPU 🫠 */}
    }
    n
    t
    s
    • 4
    • 15
  • Hi everyone. So I export a val `getValues` that...
    d

    darrinm

    05/23/2023, 12:55 AM
    Hi everyone. So I export a val
    getValues
    that returns an object
    @me.values
    and fetch
    getValues
    from a web page. I'm seeing response times in the range from 2.2-6.1s. Is this what I should expect?
    n
    s
    • 3
    • 5
  • New Thread
    n

    Needle

    05/23/2023, 12:55 AM
    Thread automatically created by darrinm in #1020432421243592717
  • random launch day (2 of 4)
    s

    stevekrouse

    05/23/2023, 1:51 PM
    @everyone - (randomly) we have four launches today, so hang onto your hats! First two: #1 - replyTo in
    console.email
    https://twitter.com/stevekrouse/status/1661000255523913729?s=20 #2 - folder & full code search https://twitter.com/stevekrouse/status/1661006102664998915?s=20
  • New Thread
    n

    Needle

    05/23/2023, 3:53 PM
    Thread automatically created by gautam1808 in #1020432421243592717
    s
    • 2
    • 2
  • rename vals
    s

    stevekrouse

    05/23/2023, 7:32 PM
    @everyone launch #3 - you can now RENAME VALS https://twitter.com/stevekrouse/status/1661092538160168972?s=20
    n
    v
    • 3
    • 3
  • hnFollow v6
    s

    stevekrouse

    05/23/2023, 9:23 PM
    @everyone the 4th & final launch today is really just a little teaser. hopefully we launch the real thing tomorrow: hnFollow, the "app", version 6! https://twitter.com/stevekrouse/status/1661120328775467008?s=20
    n
    j
    • 3
    • 3
  • New Thread
    n

    Needle

    05/23/2023, 9:54 PM
    Thread automatically created by quasor in #1020432421243592717
    s
    • 2
    • 2
  • New Thread
    n

    Needle

    05/24/2023, 2:59 PM
    Thread automatically created by darrinm in #1020432421243592717
    s
    • 2
    • 1
  • Since Github's API treats unauthenticated comin...
    r

    robert

    05/24/2023, 3:50 PM
    Since Github's API treats unauthenticated coming from the same IP address towards one rate limit, does that mean every valtown github api call (https://www.val.town/search?q=api.github.com) is grouped together from github's perspective?
    n
    s
    k
    • 4
    • 12
  • Re-launching hnFollow: email notifications any ...
    n

    Needle

    05/24/2023, 7:46 PM
    Thread automatically created by stevekrouse in #1020432421243592717
  • Re-launching hnFollow: email notifications when...
    s

    stevekrouse

    05/24/2023, 7:49 PM
    Re-launching hnFollow: email notifications when authors you follow post in Hacker News @everyone The idea is that we want to make it as easy as installing an app to get started with vals made by the community. Under the hood, it's just a normal val, with a readme, and a couple other superficial niceties. Would love your feedback 🙏 https://www.val.town/v/rodrigotello.hnFollow

    https://cdn.discordapp.com/attachments/1020432421243592717/1111018162968866896/Screenshot_2023-05-24_at_15.44.472x.png▾

    n
    e
    k
    • 4
    • 33
  • I want function type search (like hoogle https:...
    e

    El

    05/24/2023, 9:09 PM
    I want function type search (like hoogle https://hoogle.haskell.org/) for vals
    n
    s
    • 3
    • 2
  • I see the vals doc <https://docs.val.town/vals>...
    c

    crespo

    05/25/2023, 1:44 AM
    I see the vals doc got some improvements. nice!
    n
    s
    • 3
    • 2
  • 2-click, jerry-rigged night mode if you're usin...
    r

    robert

    05/25/2023, 5:52 PM
    2-click, jerry-rigged night mode if you're using Arc: https://arc.net/boost/0C2FA225-3CA6-4273-B755-217691B5F9B5 Now you just need a little pixelized night skyline in the background
    n
    a
    s
    • 4
    • 4
  • Why do I keep seeing this? https://www.val.town...
    n

    nitehawk

    05/25/2023, 11:30 PM
    Why do I keep seeing this? https://www.val.town/v/alp.confession It's almost always at the top of the "explore" page
    n
    s
    +2
    • 5
    • 6
  • Hi! Wanted to say that I really enjoy val.town...
    j

    JackTheRapper

    05/26/2023, 2:21 PM
    Hi! Wanted to say that I really enjoy val.town! I have managed to setup some nice counters on my site with it but for the love of God I can't manage to do a form submittion. Is there anybody here willing and able to assist me? Here is the code I'm trying to run :
    Copy code
    let body = { email: email };
      const response = await fetch(
            "https://api.val.town/v1/run/politelyinvinciblepointer.handleForm",
            {
              method: "POST",
              body: JSON.stringify(body),
            }
          );
          console.log(response);
    I get HTTP 500. The email variable is a simple string. Thanks
    n
    s
    • 3
    • 13
  • ⚡ Launching Val Town Pro (beta) @everyone Va...
    s

    stevekrouse

    05/26/2023, 2:37 PM
    ⚡️ Launching Val Town Pro (beta) @everyone Val Town will always provide a generous free plan. Now you can now upgrade to run longer evaluations, make more fetches, store more data, and retain tracings longer. https://docs.val.town/pricing
    n
    m
    +3
    • 6
    • 6
  • New Thread
    n

    Needle

    05/28/2023, 2:40 PM
    Thread automatically created by Clare in #1020432421243592717