8,037 Matching Annotations
  1. Jun 2022
    1. # tunejack.sh uses the TuneIn public API (at opml.radiotime.com) to search for # a radio station, print out its details and try to play it somehow.
    1. Creating GUID/UUID in Javascript using ES6 Crypto APIWe can use JavaScript ES6’s crypto API to generate GUID/UUID at the client side.crypto API comes up with a method called getRandomValues() which is used to generate a Universally Unique IDentifier as shown below

      js function CreateUUID() { return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) ) }

    1. However, if a TCO-capable engine can realize that the doA(b+1) call is in tail position meaning doB(b) is basically complete, then when calling doA(b+1), it doesn’t need to create a new stack frame, but can instead reuse the existing stack frame from doB(b). That’s faster and uses less memory.This sort of optimization becomes crucial when dealing with recursion, especially if the recursion could have resulted in thousands of stack frames. With TCO, the engine can perform all those calls in a single stack frame.
      Recursive function without TCO optimization

      ```js function factorial(n) { console.trace();

      if (n === 0) {
          return 1;
      }    // no proper tail call
      return n * factorial(n - 1);
      

      } factorial(2);VM31:4 console.trace factorial @ VM31:4VM31:4 console.trace factorial @ VM31:4 factorial @ VM31:10VM31:4 console.trace factorial @ VM31:4 factorial @ VM31:10 factorial @ VM31:10 ```

      Recursive function with TCO optimization

      js 'use strict'; function factorial(n, total = 1) { console.trace(); if (n === 0) { return total; } // proper tail call return factorial(n - 1, n * total); } factorial(2);Trace at factorial Trace at factorial Trace at factorial

    1. bash curl --http2 -H 'accept: application/dns-json' https://1.1.1.1/dns-query?name=cloudflare.com --next --http2 -H 'accept: application/dns-json' https://1.1.1.1/dns-query?name=example.com

    1. The bearerURI for a VHF/FM service is compiled as follows:fm:<gcc>.<pi>.<frequency>The <frequency> element may be replaced by the asterisk ("*") character to signify any frequency. In this case the PIcode alone shall be used by the device to locate the source
      Table 4: Example of RadioDNS bearerURI construction for RDS/RBDS

      | GCC | PI | Frequency (MHz) | RadioDNS bearerURI | |-----|------|------------------|--------------------| | ce1 | c586 | 95,8 | fm:ce1.c586.09580 | | de0 | d1e0 | 103,9 | fm:de0.d1e0.10390 | | ce1 | c201 | many | fm:ce1.c201.* |