Skip to content

Instantly share code, notes, and snippets.

Kent Brewster kentbrew

Block or report user

Report or block kentbrew

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kentbrew /
Last active Mar 13, 2020
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:

kentbrew /
Last active Mar 8, 2020
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 /
Last active Mar 5, 2020
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 / setMultiHeaders.js
Created Jan 10, 2011
Setting multiple cookies (or whatever) per header with Node. Bonus: p3p line prevents IE from spazzing out.
View setMultiHeaders.js
response.writeHead(200, {
'p3p': ['policyref=""', 'CP="OOO EEE OOH AH AHH"'],
'Set-Cookie': ['ting="tang; expires=0; path=/;"', 'wallawalla="bingbang; expires=123456789; path=/;"'],
'Content-Type': 'text/html'
kentbrew / favicon-interceptor.js
Created Jan 3, 2011
How to short-circuit those annoying favicon requests in node.js
View favicon-interceptor.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 /
Last active Feb 7, 2020
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:

  {domain: ""},
  results => {
kentbrew /
Last active Dec 22, 2019
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 AppleLanguages

If you see this:

kentbrew /
Created Dec 2, 2019
The One True White Elephant Gift Exchange Ruleset

The One True White Elephant Gift Exchange Ruleset

Gifts must:

  • Cost less than the maximum price limit, to be announced beforehand. (Yes, zero is less than the maximum price limit, as is the negative value of a truly awful white elephant.)
  • Be placed in a location where players can see all of them without touching them.
  • Be wrapped for easy extraction. Gift bags are best.
  • Number the exact number of players.

Players must:

kentbrew /
Created Nov 13, 2019
Testing Extensions on Chrome Canary

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:

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 /
Last active Oct 31, 2019
Avoiding repetition when deciding whether a member exists several layers deep inside an object.

Object Spelunking

This is trouble:

if ( === 8675309) {
You can’t perform that action at this time.