Skip to content

Instantly share code, notes, and snippets.

View kentbrew's full-sized avatar

Kent Brewster kentbrew

View GitHub Profile
@kentbrew
kentbrew / pinmarklet.md
Last active April 9, 2024 18:34
How to recreate your long-lost Pinterest bookmarklet.

How to recreate your long-lost Pinterest bookmarklet.

Right-click your bookmarks bar and choose Add Page (Chrome) or New Bookmarklet (Firefox).

In Name, put this:

Pin It

In URL, put this:

@kentbrew
kentbrew / lang_chrome_osx.md
Last active April 8, 2024 14:22
How to change the Chrome default language on OSX

How to Change your Chrome Default Language

Open up a Terminal window. (If you have never seen Terminal before, go to Spotlight Search and type "Terminal.")

In the Terminal box, try this:

defaults read com.google.Chrome AppleLanguages

If you see this:

@kentbrew
kentbrew / favicon-interceptor.js
Created January 3, 2011 19:32
How to short-circuit those annoying favicon requests in node.js
// early experiments with node had mysterious double requests
// turned out these were for the stoopid favicon
// here's how to short-circuit those requests
// and stop seeing 404 errors in your client console
var http = require('http');
http.createServer(function (q, r) {
// control for favicon
@kentbrew
kentbrew / finding_twitter_user_id.md
Last active March 24, 2024 16:42
Finding Twitter User IDs

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 {
@kentbrew
kentbrew / node-on-ec2-port-80.md
Last active February 4, 2024 19:14
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);
@kentbrew
kentbrew / cookies.md
Last active January 7, 2024 10:53
Quick-read cookies via browser extension

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 / insta_pinterest_rss.md
Last active March 14, 2023 01:19
Instagram RSS via Pinterest

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 / tootski.md
Last active March 14, 2023 01:10
Tootski, a sharing bookmarklet for Mastodon

Tootski, a sharing bookmarklet for Mastodon

Kent Brewster

Tootski is a bookmarklet that will share the page you're on to your Mastodon instance, including the title, address, and any text you may have selected. If you have any questions or need help, please find me at https://xoxo.zone/@kentbrew.

Before You Begin

You need to know the name of your Mastodon instance if it's not mastodon.social. To find it, visit your home page on Mastodon and copy out the part between the second and third slash. My home URL looks like this:

@kentbrew
kentbrew / how_to_get_your_stuff_on_pinterest.md
Last active October 14, 2022 03:19
How To Get Your Stuff On Pinterest

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 / DOMParser_input_cleaner.md
Last active June 2, 2022 19:49
Using DOMParser to clean HTML input

Old School:

  var clean = function (input) {
    var testMe = input, dupeTest = '';
    while (testMe !== dupeTest) {
      testMe = new DOMParser().parseFromString(testMe, "text/html").documentElement.textContent;
      dupeTest = testMe;
    }
    testMe = testMe.replace(/</g, '&lt;');

return testMe;