Skip to content

Instantly share code, notes, and snippets.

View dotproto's full-sized avatar

Simeon Vincent dotproto

View GitHub Profile
@dotproto
dotproto / LICENSE
Last active July 16, 2020 14:09
MV3 webRequest demo. To view the console, you may need to manually open devtools for the service worker. On Chrome, visit chrome://serviceworker-internals and search for the service worker registered to `chrome-extension://<extension-id>/` where extension-id is the ID of your extension.
Copyright 2020 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@dotproto
dotproto / background.js
Created February 26, 2020 08:53
Simple Chrome Extension messaging demo modeled after the TCP/IP handshake (SYN, SYN-ACK, ACK)
// Copyright 2020 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Start synchronizaiton on browser action click
chrome.browserAction.onClicked.addListener(function(tab) {
console.log('Handshake initiated: BG sending SYN');
chrome.tabs.sendMessage(tab.id, { type: 'bg-syn' });
});
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
@dotproto
dotproto / LICENSE
Created November 15, 2019 21:21
Minimal working Manifest V3 extension.
Copyright 2019 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@dotproto
dotproto / yt-translation.js
Created October 4, 2019 18:00
Open transcription suggestion for current YT video
javascript:(function(){
var log = (...a) => console.log(...a);
const url = new URL(document.location.href);
if (url.hostname.endsWith('youtube.com')) {
const id = url.searchParams.get('v');
window.location = `https://www.youtube.com/timedtext_video?v=${id}`;
}
})()
@dotproto
dotproto / LICENSE
Created June 13, 2019 17:09
Simple extension that injects a script before the page loads
Copyright 2019 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@dotproto
dotproto / index.css
Created July 10, 2018 18:18 — forked from stereokai/index.css
Trigonometry in CSS
//----------------------------------*\
// TRIGONOMETRY FUNCTIONS
//----------------------------------*/
// # Trigonometry in CSS
//
// - Through Taylor/Maclaurin polynomial representation: http://people.math.sc.edu/girardi/m142/handouts/10sTaylorPolySeries.pdf
// - Useful if you don't want to use JS.
// - With CSS Variables.
// - `calc()` can't do power (x ^ y) so I used multiplication instead.
@dotproto
dotproto / merge.js
Last active April 26, 2018 21:17
Merge async iterators
(async function() {
console.clear();
class Deferred {
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}

On Dec 3, 2017 [I asked Marcin Wichary][request] for advice on "font design" and he suggested I check out [Zach Leatherman's thread][zach_thread] where he asked a very similar question.

Books

  1. [How to create typefaces: from sketch to screen][book1]
  2. [Counterpunch][book2]
  3. [Designing Type][book3] by Karen Cheng
  4. [While You're Reading][book4] by Gerard Unger
  5. [Essential Type: An Illustrated Guide to Understand and Using Fonts][book5] by Tony Seddon
  6. [Lettering for Reproduction][boo6] by David Gates
@dotproto
dotproto / assignProps.js
Created November 27, 2017 18:50
Copy the specified enumerable properties (strings or symbols) from the source object to the destination object
function assignProps(source, dest, props) {
const descriptors = {};
props.forEach(name => {
let desc = Object.getOwnPropertyDescriptor(source, name);
if (desc && desc.enumerable) {
descriptors[name] = desc;
}
});
Object.defineProperties(dest, descriptors);
}
@dotproto
dotproto / default-params.js
Created November 22, 2017 01:03
Short collection of thoughts on a couple different approaches for default "options" values in a function
// Static defaults
function fn({a = 1, b = 2} = {}) {
return `${a}, ${b}`
}
fn() // 1, 2
fn({b: 'beta'}) // 1, beta
/**