Skip to content

Instantly share code, notes, and snippets.

🖕
none of your business

Chris Zarate chriszarate

🖕
none of your business
View GitHub Profile
@chriszarate
chriszarate / debug-fastly.md
Last active Jun 1, 2020
Debug Fastly response
View debug-fastly.md

Debugging browser requests to Fastly objects

Fastly allows you to add a special header to your request which instructs it to include detailed cache information in the response. This information is useful in debugging cache issues, especially around max-age and surrogate keys.

In Firefox

Firefox's dev tools make it easy to edit and resend an HTTP request. Use this flow to add the Fastly debug header in the browser:

  1. Open Dev Tools and switch to the Network tab. You may need to refresh the page to capture the request for the current page.
View git-add.patch
$ git add -p src
diff --git a/src/publish.js b/src/publish.js
index 196e8aa..e1fa7df 100644
--- a/src/publish.js
+++ b/src/publish.js
@@ -43,11 +43,10 @@ module.exports = async () => {
// Render aggregation pages.
await publishHtml( 'home', 'index.html', { posts } );
- await publishHtml( 'archive', 'archive', { posts } );
View apollo-client-log-queries.js
networkInterface.use([{
applyMiddleware(req, next) {
console.log(req.request);
next();
}
}]);
@chriszarate
chriszarate / vnc-over-ssh.sh
Created Jul 15, 2015
VNC over SSH via bastion
View vnc-over-ssh.sh
# You want to VNC to Box A but you don't have access to it
# over public Internet. You do have SSH access to Box B in
# the same private network.
# firewall
# ┌─────┐ ╏╏ ┌─────┐
# │ You │──SSH──╏╏────│ B │ bastion
# └─────┘ ╏╏ └──┬──┘
# ╏╏ SSH
# ╏╏ ┌──┴──┐
@chriszarate
chriszarate / update-site-urls.sh
Created Mar 2, 2015
WordPress Multisite HTTP to HTTPS migration
View update-site-urls.sh
!/bin/bash
# WordPress Multisite HTTP to HTTPS migration
# Use wp-cli to assist HTTP to HTTPS migration for a WP Multisite installation.
# Update site metadata for the main site as well as each site in the network.
WP_PATH=/var/www
WPCLI_PATH=/home/admin/bin/wp-cli.phar
@chriszarate
chriszarate / thumbnail.png
Last active Aug 16, 2018
Identify your tmux windows with food emoji
@chriszarate
chriszarate / flickr-biggest.js
Created May 23, 2013
Bookmarklet to get largest available photo from a Flickr photo page. Fits in a tweet! (82 characters)
View flickr-biggest.js
javascript:P=FLICKR.photo.getSizes();window.location=P[Object.keys(P).pop()].url;
View A cheapskate on Amazon EC2.md

September 29 2010, 9:23 PM

Amazon’s EC2 service now allows you to boot from persistent EBS volumes—a boon to those of us who like to run the occasional server-hour but don’t want to mess with bundling AMIs and other atrocities. The [AWS Management Console][1] automates most tasks, but you might find yourself quickly running into a two-part annoyance: (1) if you use public AMIs, the size of your EBS volume is chosen for you; and (2) EBS volumes are not resizable—at least, [not downwards][2]. Since Amazon charges you for allotted space on EBS volumes, this “annoyance” can literally cost you [tens of cents][3] per month!

Luckily, there is a workaround, and it has the side benefit of allowing you to boot one EBS volume on different instance types—that is, boot up your volume on an “m1.small” instance one day, a “c1.medium” the next, and so on. What follows assumes familiarity with Amazon Web Services and EC2, UNIX/Linux, the command-line, computers, typing, pants-wearing, etc.

Ok: Launch an EC2 instance fr

@chriszarate
chriszarate / getTextNodesBetween.js
Last active Aug 30, 2019
Native JavaScript function to get all *text* nodes contained in a selection object.
View getTextNodesBetween.js
// Get all *text* nodes contained in a selection object.
// Adapted from code by Tim Down.
// http://stackoverflow.com/questions/4398526/how-can-i-find-all-text-nodes-between-to-element-nodes-with-javascript-jquery
function getTextNodesBetween(selection) {
var range = selection.getRangeAt(0), rootNode = range.commonAncestorContainer,
startNode = range.startContainer, endNode = range.endContainer,
startOffset = range.startOffset, endOffset = range.endOffset,
pastStartNode = false, reachedEndNode = false, textNodes = [];
function getTextNodes(node) {
var val = node.nodeValue;
View upgrade-trac-1.0.sh
# as root
/etc/init.d/apache2 stop
easy_install --upgrade Trac==1.0
trac-admin /var/trac/sites/my-trac upgrade
trac-admin /var/trac/sites/my-trac wiki upgrade
/etc/init.d/apache2 start
You can’t perform that action at this time.