tripu's notebooks

  • npm bin fields - PoC - /tripu/npm-bin-fields---poc
    Last edited 24 days ago
    const { dirname, resolve, relative } = require('path') const bin = {"doraemon-storybook:main": "bin/doraemon_storybook-main"}; const target = '/opt/bin'; const path = '/yes/no/'; // norm({name: 'a:b/c.d', bin: 'one:two.three/four'}); for (const [key, val] of Object.entries(bin)) { const to = resolve(target, key) const absFrom = resolve(path, val) const from = relative(dirname(to), absFrom) console.dir({path, from, to, absFrom}) }
  • Symmetrical encryption in Node.js - /tripu/symmetrical-encryption-in-node-js
    Last edited 2 months ago
    Two ways to test this: · Run the cell below to see a demo, or · cURL or browse the API endpoint: https://runkit.io/tripu/symmetrical-encryption-in-node-js/branches/master
  • Origin 2 - /tripu/origin-2
    Last edited 7 months ago
    exports.endpoint = (request, response) => { response.end(`<h1>Origin 1</h1> <p>This link will redirect you to <code>https://www.ietf.org/</code>:</p> <a href="https://codepen.io/tripu/full/WNNJJbP"> <code>https://codepen.io/tripu/full/WNNJJbP</code> </a>`); };
  • Origin 1 - /tripu/origin-1
    Last edited 7 months ago
    exports.endpoint = (request, response) => { response.end(`<h1>Origin 1</h1> <p>This link will redirect you to <code>https://www.ietf.org/</code>:</p> <a href="https://codepen.io/tripu/full/WNNJJbP"> <code>https://codepen.io/tripu/full/WNNJJbP</code> </a>`); };
  • Redirect depending on referrer - /tripu/redirect-depending-on-referrer
    Last edited 7 months ago
    exports.endpoint = (request, response) => { response.end(`<script> const ref = document.referrer; const redirect = url => { window.alert(\`You will be redirected to\n${url}\`); window.location.href = url; }; if (-1 !== ref.indexOf('WNNJJrm') || -1 !== ref.indexOf('slack.com')) redirect('https://www.iana.org/'); else if (-1 !== ref.indexOf('NWWMMGe') || -1 !== ref.indexOf('google.com')) redirect('https://www.ietf.org/'); else window.alert(\`Unknown referrrer\n(${ref})\`); </script>`); };
  • Connecting to IRC from Node.js - /tripu/connecting-to-irc-from-node-js
    Last edited 3 years ago
    const irc = require('irc'); const config = { realName: 'Test; cf https://runkit.com/tripu/5914592a8518d10011506236', channels: ['#test'] }; const client = new irc.Client('irc.w3.org', 'tripu-bot', config); if (client) { client.addListener('error', (err) => console.debug(err)); client.addListener('registered', () => client.say('#test', "Hi! I'm alive!")); }