3,320 Matching Annotations
  1. Last 7 days
    1. These are the key parameters.

      prop=revisions&rvprop=content&rvsection=0

      rvsection = 0 specifies to only return the lead section.

    1. For creating SXGs for testing purposes, you can create a self-signed certificate and enable chrome://flags/#allow-sxg-certs-without-extension to have your Chrome process the SXGs created with the certificate without the special extension.

      ```html

      <link rel="prefetch" href="https://your-site.com/sample.sxg" />

      Sample ```

    1. The clientHeight property returns the inner height of an element in pixels. The property includes padding but excludes borders, margins and horizontal scrollbars.Alternatively, you can use the offsetHeight property, which returns the height of the element in pixels, including vertical padding and borders.

      ```js useEffect(() => { setDivHeight(ref.current.offsetHeight); console.log('height: ', ref.current.offsetHeight);

      console.log('width: ', ref.current.offsetWidth); }, []); ```

  2. Aug 2022
    1. If your site is using multiple widgets you can set up Twitter widgets in your pages once, which will make your site faster, and widgets such as embedded Tweets will be more reliable for authors when using content management systems.

      ```html

      <script>window.twttr = (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], t = window.twttr || {}; if (d.getElementById(id)) return t; js = d.createElement(s); js.id = id; js.src = "https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); t._e = []; t.ready = function(f) { t._e.push(f); }; return t; }(document, "script", "twitter-wjs"));</script>

      ```

    1. ```js export function Tweet({ tweetID, }) { const tweetRef = useRef(null); const [isLoading, setIsLoading] = useState(true);

      useEffect(() => { const tweetEl = tweetRef?.current if (window.twttr && tweetEl) (async() => { await window.twttr.ready(); await window.twttr.widgets.createTweet( tweetID, tweetEl, { align: 'center', conversation: 'none', dnt: true, } ); setIsLoading(false); console.log('Tweet loaded') })(); return () => { tweetEl?.remove(); } }, [tweetID, tweetRef]);

      return ( <div ref={tweetRef} className="w-full bg-gray-100 h-fit animate-fadeIn" id={tweetID}> {isLoading &&

      🐦

      } </div> ); }; ```

  3. Jul 2022
    1. A Solid Social Knowledge GraphBy networked these second brains together via the Fediverse, the MyHub.ai toolkit creates a distributed Social Knowledge Graph for each Hub Editor.

    2. Your Hub’s CMS: a Thinking Management System for writersEach Hub’s content management system (CMS) is actually a “Thinking Management System”: a thinking tool based on a Personal Knowledge Graph (PKG) which is custom-designed to support thinking and writing.

    1. ```js const versions = [ { version: 1, data: 1}, { version: 3, data: 3}, { version: 17, data: 17}, { version: 95, data: 95} ];

      function getNextVersion(v) { return versions.slice(0).reduceRight((a , b, i , arr) => b.version <= v ? (arr.length = 0, b) : b) } ```

    1. Here's a complete function that removes accents, replaces special characters with hyphens, also removing additional hyphens:

      ```js const replaceSpecialChars = (str) => { return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Remove accents .replace(/([^\w]+|\s+)/g, '-') // Replace space and other characters by hyphen .replace(/--+/g, '-') // Replaces multiple hyphens by one hyphen .replace(/(^-+|-+$)/g, ''); // Remove extra hyphens from beginning or end of the string }

      console.log(replaceSpecialChars('This is a sentence!!!')); ```

    1. ```js function replaceDiacritics(s) { var s;

      var diacritics =[ /[\300-\306]/g, /[\340-\346]/g, // A, a /[\310-\313]/g, /[\350-\353]/g, // E, e /[\314-\317]/g, /[\354-\357]/g, // I, i /[\322-\330]/g, /[\362-\370]/g, // O, o /[\331-\334]/g, /[\371-\374]/g, // U, u /[\321]/g, /[\361]/g, // N, n /[\307]/g, /[\347]/g, // C, c ];

      var chars = ['A','a','E','e','I','i','O','o','U','u','N','n','C','c'];

      for (var i = 0; i < diacritics.length; i++) { s = s.replace(diacritics[i],chars[i]); }

      document.write(s); } ```