Skip to content

Instantly share code, notes, and snippets.

View montmanu's full-sized avatar

Chris Montoro montmanu

  • New York Times
  • New York, NY
View GitHub Profile
@montmanu
montmanu / README.md
Last active December 20, 2023 07:33
Processing kubectl YAML Output with yq
@montmanu
montmanu / summarize-restarts.sh
Created May 18, 2018 06:37
k8s container restarts by namespace, pod, container, service
#!/usr/bin/env bash
kubectl get pods --all-namespaces -o json | jq '[
.items[] | (
{
namespace: .metadata.namespace,
pod: .metadata.name,
statuses: (
[
.status.containerStatuses[] | { name, ready, restartCount }
@montmanu
montmanu / nginx.conf
Created March 2, 2018 02:14
Sample Cloud Endpoints nginx Configuration
# /usr/sbin/nginx -c /etc/nginx/endpoints/nginx.conf -T
# configuration file /etc/nginx/endpoints/nginx.conf:
# Auto-generated by start_esp
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@montmanu
montmanu / index.html
Created September 13, 2017 04:04
Moment Timezone Examples // source https://jsbin.com/jaweyowaru
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Moment Timezone Examples</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.13/moment-timezone.min.js"></script>
<style id="jsbin-css">
html, body {
@montmanu
montmanu / parseQueryString.js
Created September 5, 2017 16:59
naive query string parser
function parseQueryString(qs) {
return (
qs.slice(1).split('&')
.map((pair) => {
const [key, value] = pair.split('=');
let transformedValue = decodeURIComponent(value);
if (/^[{|\]]/.test(transformedValue)) {
transformedValue = JSON.parse(transformedValue);
}
return { key: key, value: transformedValue };
@montmanu
montmanu / filter-3p-resources.js
Last active May 24, 2017 22:19
Get array of unique, 3rd party resources
var firstPartyHostnamePattern = /^(?:.*)(?:nytimes\.com|nyt\.com|nyt\.net)$/;
// filter out 1st party resources
var thirdPartyResources = window.performance.getEntriesByType('resource').filter(function (entry){
var url = new URL(entry.name);
return !firstPartyHostnamePattern.test(url.hostname);
});
// reduce to unique host names
var thirdPartyHostnames = thirdPartyResources.map(function (entry){
@montmanu
montmanu / open-as-hybrid-bookmarklet.js
Last active February 7, 2017 00:00
bookmarklet to load a hybrid version of current article
javascript:!function(a,b){function c(){let b="production";const c=a.location.hostname,d=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;return(/local/.test(c)||d.test(c))&&(b="local"),/dev/.test(c)&&(b="development"),/stg/.test(c)&&(b="staging"),b}function d(){let a="article";const c=b.querySelector('meta[name="PT"]');return c&&c.getAttribute("content")&&/blog/i.test(c.getAttribute("content"))&&(a="blogpost"),a}function e(){let a="";const c=b.querySelector('meta[name="articleid"]');return c&&c.getAttribute("content")&&/\d{13,19}/.test(c.getAttribute("content"))&&(a=c.getAttribute("content")),a}function f(){const a=d(),b=e(),c=`/hybrid/${a}/${b}.html`;return c}function g(){const a={local:"local.sbx.nytimes.com",development:"mobile.dev.nytimes.com",staging:"mobile.stg.nytimes.com",production:"mobile.nytimes.com"},b=c();return a[b]}function h(){const a={local:"http:",development:"https:",staging:"ht
@montmanu
montmanu / gdx.sh
Created September 17, 2016 20:04
Exclude files from git diff
git status --porcelain | grep -v -E 'docs|lib' | awk '{print $2}' | xargs git diff
@montmanu
montmanu / keybase.md
Created August 13, 2016 18:23
keybase.io verification

Keybase proof

I hereby claim:

  • I am montmanu on github.
  • I am montmanu (https://keybase.io/montmanu) on keybase.
  • I have a public key ASDvEVsg23x4DW9iMJEIYrWr3nwJnkQHkcmEFyIzbVzUkgo

To claim this, I am signing this object: