Skip to content

Instantly share code, notes, and snippets.

View kentbrew's full-sized avatar

Kent Brewster kentbrew

View GitHub Profile
@kentbrew
kentbrew / white_elephant.md
Last active December 7, 2021 02:45
The One True White Elephant Gift Exchange Ruleset

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 / wholikesmitt.html
Created November 11, 2012 02:00
Who Likes Mitt?
<html>
<head>
<title>Who Likes Mitt?</title>
<style>
pre#output {
height: 12em;
width: 500px;
overflow: auto;
}
</style>
/* 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 / setMultiHeaders.js
Created January 10, 2011 22:57
Setting multiple cookies (or whatever) per header with Node. Bonus: p3p line prevents IE from spazzing out.
response.writeHead(200, {
'p3p': ['policyref="http://foo.com/p3p.xml"', 'CP="OOO EEE OOH AH AHH"'],
'Set-Cookie': ['ting="tang; expires=0; path=/;"', 'wallawalla="bingbang; expires=123456789; path=/;"'],
'Content-Type': 'text/html'
});
@kentbrew
kentbrew / tinymce_wordpress.txt
Created October 1, 2012 15:46
How to turn off TinyMCE in Wordpress
In wordpress/wp-includes/class-wp-editor.php, look for the tinymce setting:
public static function parse_settings($editor_id, $settings) {
$set = wp_parse_args( $settings, array(
...
'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
...
) );
Set it to false and you should be good to go.
@kentbrew
kentbrew / stub.html
Last active June 9, 2020 21:58
A stub file for new HTML projects.
<!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" href="presentation.css">
</head>
<body>
<script src="behavior.js"></script>
</body>
@kentbrew
kentbrew / testing_extensions_on_chrome_canary.md
Created November 13, 2019 21:57
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:

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 October 31, 2019 22:04
Avoiding repetition when deciding whether a member exists several layers deep inside an object.

Object Spelunking

This is trouble:

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

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 &amp;&amp; typeof input === "object") {
@kentbrew
kentbrew / bpsh.md
Created March 4, 2019 01:23
Hiding Ads from All Facebook Advertisers who have Added You From a Contact List

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.