Skip to content

Instantly share code, notes, and snippets.

View ryanschwartz's full-sized avatar

Ryan Schwartz ryanschwartz

View GitHub Profile
@ryanschwartz
ryanschwartz / README.md
Last active November 1, 2016 19:58 — forked from adambom/README.md
Backup Kubernetes Cluster State

Run this in order to backup all you k8s cluster data. It will be saved in a folder bkp. To restore the cluster, you can run kubectl apply -f bkp.

Please note: this recovers all resources correctly, including dynamically generated PV's. However, it will not recover ELB endpoints. You will need to update any DNS entries manually, and manually remove the old ELB's.

Please note: This has not been tested with all resource types. Supported resource types include:

  • services
  • replicationcontrollers
  • secrets
  • deployments
  • horizontal pod autoscalers

kubeenv for lazy typers...

Usage

  1. Copy the below into your .bash_profile or similar
  2. k8 <your-context>, where your-context is the shortcut name you'd like to use
  3. gcloud container clusters get-credentials <clustername>
  4. Repeat step 3 for each of the k8s contexts you want to have available
  5. To use, run k8 <your-context> to change contexts.
@ryanschwartz
ryanschwartz / README.md
Last active March 22, 2017 16:15
Mac OS Sierra Caps Lock as tap-to-Escape press-to-Control

This has only been tested on macOS Sierra, 10.12. YMMV, caveat emptor, yadda-yadda...

You need to install Karabiner-Elements from this fork: https://github.com/wwwjfy/Karabiner-Elements, then the following will set up the default function keys and the capslock functionality (via this issue).

{
    "global": {
        "check_for_updates_on_startup": true,
        "show_in_menu_bar": false,
        "show_profile_name_in_menu_bar": false
@ryanschwartz
ryanschwartz / transform.js
Created September 10, 2018 22:41
UDF for pubsub to bigquery pipeline
/**
* A transform function which filters docker_log_auxiliary_field fields containing "no value" and renames "@timestamp" to "timestamp"
* @param {string} inJson
* @return {string} outJson
*
* Sample event: {"@timestamp":"2018-09-07T00:44:27+00:00","appname":"reporter-dev","body_bytes_sent":"5","client_ip":"10.142.0.19","fling.source":"/webapp/log/nginx/access.jlog","forwarded_for_ip":"-","generator":"nginx","http_host":"10.142.0.19","http_referrer":"-","http_user_agent":"GoogleHC/1.0","json":{"docker_log_auxiliary_field":"\u003cno value\u003e"},"remote_user":"-","request":"GET /healthz HTTP/1.1","request_method":"GET","request_time":"0.000","srchost":"reporter-dev-app-7cbb779c7-9dmmx","status":"200"}
* Sample event escaped: "{\"@timestamp\":\"2018-09-07T00:44:27+00:00\",\"appname\":\"reporter-dev\",\"body_bytes_sent\":\"5\",\"client_ip\":\"10.142.0.19\",\"fling.source\":\"/webapp/log/nginx/access.jlog\",\"forwarded_for_ip\":\"-\",\"generator\":\"nginx\",\"http_host\":\"10.142.0.19\",\"http_referrer\":\
@ryanschwartz
ryanschwartz / gist:72af0780b360e327cbf50c115984de7f
Created November 28, 2018 18:55
Switch Caps-Lock to Control key with long press, Escape with short press/tap
Step 1: Install karabiner-elements. https://github.com/tekezo/Karabiner-Elements/releases
Step 2: Visit https://pqrs.org/osx/karabiner/complex_modifications/#modifier-keys and click import button on "Change caps_lock key (rev 2)"
Step 3: When karabiner prompts, click Import to import ruleset.
Step 4: Click :heavy_plus_sign: to enable the "Change caps_lock to control if pressed with other keys, to escape if pressed alone." rule.
Step 5: *Never use the TouchBar escape key again.*