Skip to content

Instantly share code, notes, and snippets.

View chriszarate's full-sized avatar
👋
hi

Chris Zarate chriszarate

👋
hi
View GitHub Profile
@chriszarate
chriszarate / getTextNodesBetween.js
Last active April 1, 2023 13:45
Native JavaScript function to get all *text* nodes contained in a selection object.
// 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;
@chriszarate
chriszarate / vnc-over-ssh.sh
Created July 15, 2015 03:39
VNC over SSH via bastion
# 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 / wp-graphql-co-authors-plus.php
Created March 1, 2022 00:45
WPGraphQL CoAuthorsPlus
<?php
/**
* Plugin Name: GraphQL integration with Co-Authors Plus
* Author: WPGraphQL
* Version: 0.1.0
* Requires at least: 5.0.0
*
* @package wp-graphql-co-authors-plus
*/
@chriszarate
chriszarate / thumbnail.png
Last active March 17, 2021 00:57
Identify your tmux windows with food emoji
thumbnail.png
@chriszarate
chriszarate / debug-fastly.md
Last active June 1, 2020 16:47
Debug Fastly response

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.
$ 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 } );
networkInterface.use([{
applyMiddleware(req, next) {
console.log(req.request);
next();
}
}]);
@chriszarate
chriszarate / imgcat.sh
Created June 8, 2012 13:12
Concatenate images with ImageMagick
# If you want to append images horizontally, use this command
convert image1.jpg image2.jpg image3.jpg +append result.jpg
# If you want to append them vertically, change the + to a -
convert image1.jpg image2.jpg image3.jpg -append result.jpg
# Source: http://snipplr.com/view/10360/
@chriszarate
chriszarate / flickr-biggest.js
Created May 23, 2013 17:06
Bookmarklet to get largest available photo from a Flickr photo page. Fits in a tweet! (82 characters)
javascript:P=FLICKR.photo.getSizes();window.location=P[Object.keys(P).pop()].url;

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