This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.
— Erik
| // Set up a mutation observer to watch for url change to detect navigation | |
| var previousUrl = location.href; | |
| var observer = new MutationObserver(function(mutations) { | |
| // If URL changes... | |
| if (location.href !== previousUrl) { | |
| previousUrl = location.href; | |
| // Close popup | |
| removeBanner(); | |
| const puppeteer = require('puppeteer-core'); | |
| const cheerio = require('cheerio'); | |
| const chrome = require('chrome-aws-lambda'); | |
| export default async (req, res) => { | |
| const slug = req?.query?.slug; | |
| if (!slug) { | |
| res.statusCode = 200 | |
| res.setHeader('Content-Type', 'application/json') | |
| res.end(JSON.stringify({ id: null })) |
| // Generates the SAPISIDHASH token Google uses in the Authorization header of some API requests | |
| async function getSApiSidHash(SAPISID, origin) { | |
| function sha1(str) { | |
| return window.crypto.subtle.digest("SHA-1", new TextEncoder("utf-8").encode(str)).then(buf => { | |
| return Array.prototype.map.call(new Uint8Array(buf), x=>(('00'+x.toString(16)).slice(-2))).join(''); | |
| }); | |
| } | |
| const TIMESTAMP_MS = Date.now(); | |
| const digest = await sha1(`${TIMESTAMP_MS} ${SAPISID} ${origin}`); |
| // Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository | |
| $ git ls-files | xargs wc -l |