Skip to content

Instantly share code, notes, and snippets.

Avatar

Kent Brewster kentbrew

View GitHub Profile
View game.js
/* use strict */
const me = {
// we could potentially set this in game.create from game["_gridWidth"]
// instead of hard-coding the number 24
board: {
height: 24,
width: 24
},
// starting score should be 0
@kentbrew
kentbrew / insta_pinterest_rss.md
Last active Mar 5, 2020
Instagram RSS via Pinterest
View insta_pinterest_rss.md

Instagram RSS via Pinterest

Curious reader @plasticmind asked this question on the Twitter:

Dear lazyweb: does anyone know of a way to pull the Instagram feed for a particular user into a site automatically without needing to pay a monthly subscription for a service? Happy to entertain dev-related options.

The answer is, as always, "it depends." If it's your account, you can do this with Pinterest, and along the way make sure that any time one of your Instagram posts winds up on Pinterest it will have correct attribution.

To get a feed of Instagram posts onto a Web site:

@kentbrew
kentbrew / cookies.md
Last active Feb 7, 2020
Quick-read cookies via browser extension
View cookies.md

Here's a thing you can do to quickly reveal any or all cookies set on your WebExtensions-compatible browser from any domain. For this example we'll use Chrome but it should work wherever you can debug a browser extension.

You need to have at least one add-on installed that has a background page; to find it, go to chrome://extensions, be sure Developer Mode is on (top right sliding switch) and see if any of your installed extensions has a link to background page next to Inspect Views.

Once you find a link to a background page, click it. A Web inspector should appear; when it does, go to the Console tab and paste this:

chrome.cookies.getAll(
  {domain: "facebook.com"},
 results => {
@kentbrew
kentbrew / white_elephant.md
Last active Dec 7, 2021
The One True White Elephant Gift Exchange Ruleset
View white_elephant.md

The One True White Elephant Gift Exchange Ruleset

Gifts must:

  • Number the exact number of players.
  • Be wrapped so their contents cannot be visually discerned.

Setup:

  • All gifts must be placed in a location where players can see all of them.
@kentbrew
kentbrew / testing_extensions_on_chrome_canary.md
Created Nov 13, 2019
Testing Extensions on Chrome Canary
View testing_extensions_on_chrome_canary.md

Testing Extensions on Chrome Canary

Kent Brewster, 2019-11-13. For fastest contact, Twitter is your best bet; I'm @kentbrew there and everywhere else that hasn't already kicked me off.

At long last it's time to get serious about Manifest V3:

https://developer.chrome.com/extensions/migrating_to_manifest_v3

https://developer.chrome.com/extensions/migrating_to_service_workers

Problem: all the cool new toys only work in Chrome Canary. If you're like me, your chrome://extensions page is already a giant mass of internally-conflicting test extensions and you dislike the taste of coal dust, so you've avoided Canary versions of Chrome at all costs.

@kentbrew
kentbrew / object_spelunking.md
Last active Oct 31, 2019
Avoiding repetition when deciding whether a member exists several layers deep inside an object.
View object_spelunking.md

Object Spelunking

This is trouble:

if (foo.bar.baz.woo.yay === 8675309) {
  doStuff();
}
@kentbrew
kentbrew / sortByKeys.md
Last active Aug 30, 2019
Sorting a JSON Object by Key Name
View sortByKeys.md

Sorting a JSON Object by Key Name

While performing eyeball-based QA for an API update I needed a fast way to reformat output so that all keys would be in the same order. Here's what I came up with:

sortByKeys = input => {
  // default: return anything whose typeof is NOT "object"
  let result = input;
  // do we have an object? look inside
 if (input && typeof input === "object") {
@kentbrew
kentbrew / bpsh.md
Created Mar 4, 2019
Hiding Ads from All Facebook Advertisers who have Added You From a Contact List
View bpsh.md

Hiding Ads from All Facebook Advertisers who have Added You From a Contact List

Here's a scary page:

https://www.facebook.com/ads/preferences/?entry_product=ad_settings_screen

Open up the Advertisers section and check out that first section: advertisers who use a contact list added to Facebook. Unlike the other tabs in this section, these ads have nothing to do with your behavior on Facebook or elsewhere on the Internet. All these advertisers got your name the old-fashioned way: by trading something of value for a list containing your contact information.

Per Facebook's vague-but-cheerful explainer, this is "typically" your e-mail address or phone number, but there's really no way to know for sure.

@kentbrew
kentbrew / how_to_get_your_stuff_on_pinterest.md
Last active Aug 16, 2022
How To Get Your Stuff On Pinterest
View how_to_get_your_stuff_on_pinterest.md

Here's a doc we never published while I was at Pinterest. Some or all of it may be useful; please keep in mind that I've been ex-Pinterest since March 2022 and cannot help if it doesn't work.

I apologize in advance for the chirpy Pinterest editorial tone throughout; it's a Thing there.

How To Get Your Stuff On Pinterest

Hi, all. Kent Brewster here, oldest surviving engineer at Pinterest. For the past ten years we've been working on a handful of things that help people who love Pinterest find new inspiration from the Web and share it as easily as possible.

These things are:

@kentbrew
kentbrew / finding_twitter_user_id.md
Last active Jan 31, 2022
Finding Twitter User IDs
View finding_twitter_user_id.md

Finding Twitter User IDs

User accounts on Twitter are commonly identified by screen name, which may be changed by operators when they take over an account, or have been sitting on an old account for a long time and want to transition it into malicious use.

User IDs, however, are permanent. There are several services out there that will try to find them for you but it seems like a bad idea to me, since you're alerting them to the fact that there's something interesting about this account. There's also plenty of bad advice that uses many long-since-abandoned Twitter API endpoints.

As of this writing (2018-02-18) you can view source and search for /profile_banners/, which will show something like this:

.enhanced-mini-profile .mini-profile .profile-summary {