Skip to content

Instantly share code, notes, and snippets.

Simeon Vincent dotproto

View GitHub Profile
@dotproto
dotproto / background.js
Created Feb 26, 2020
Simple Chrome Extension messaging demo modeled after the TCP/IP handshake (SYN, SYN-ACK, ACK)
View background.js
// 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 Nov 15, 2019
Minimal working Manifest V3 extension.
View LICENSE
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 Oct 4, 2019
Open transcription suggestion for current YT video
View yt-translation.js
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 Jun 13, 2019
Simple extension that injects a script before the page loads
View LICENSE
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 Jul 10, 2018 — forked from stereokai/index.css
Trigonometry in CSS
View index.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 Apr 26, 2018
Merge async iterators
View merge.js
(async function() {
console.clear();
class Deferred {
constructor() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
View typeface_advice.md

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 Nov 27, 2017
Copy the specified enumerable properties (strings or symbols) from the source object to the destination object
View assignProps.js
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 Nov 22, 2017
Short collection of thoughts on a couple different approaches for default "options" values in a function
View default-params.js
// Static defaults
function fn({a = 1, b = 2} = {}) {
return `${a}, ${b}`
}
fn() // 1, 2
fn({b: 'beta'}) // 1, beta
/**
@dotproto
dotproto / async_playground.js
Created Nov 15, 2017
An async iteration experiment. I was thinking about RxJS-like observables.
View async_playground.js
function clickPromise(el) {
// Create pointers for proimse chain methods
let _resolve = null
let _reject = null
const p = new Promise((resolve, reject) => {
// Cache the promise chain methods for future use
_resolve = resolve
_reject = reject
You can’t perform that action at this time.