Skip to content

Instantly share code, notes, and snippets.

View ryanschwartz's full-sized avatar

Ryan Schwartz ryanschwartz

View GitHub Profile
@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.*
@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 / 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

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 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
@ryanschwartz
ryanschwartz / create-multi-region-l7-lb.sh
Created October 3, 2016 23:44
Creates a http/https load balancer in GCE using provided parameters
#! /bin/bash
# sourced from https://gist.github.com/bprashanth/3827059fc46cba4ffbe1651ee3e9a78f#gistcomment-1828832
show_usage() {
echo ""
echo -e "Usage: $0 balancer-name \"ig1,ig1_zone;ig2,ig2_zone[;ig3...]\" project static-ip hc-path port certname"
echo ""
echo "List manage instance groups: gcloud compute instance-groups managed list"
echo "List project global IPs: gcloud compute addresses list --global --project $PROJECT"
echo "Reserve a new IP: gcloud compute addresses create <name> --global --project $PROJECT"
@ryanschwartz
ryanschwartz / -
Created September 22, 2016 18:49
test
--- ProxySQL_GloVars.cpp
+++ ProxySQL_GloVars.cpp.new
@@ -16,6 +16,7 @@
#ifdef DEBUG
// malloc_stats_print(NULL, NULL, "");
#endif
+#ifdef __GLIBC__
void *arr[20];
size_t s;
@ryanschwartz
ryanschwartz / 1. Defined RC
Created May 19, 2016 03:09
kubectl expose not creating correct ports
✓ ( 22:04:47 ) ⦿ ryan@juniper
▶︎ ~ ▶︎ kg rc vpn -o yaml
apiVersion: v1
kind: ReplicationController
metadata:
creationTimestamp: 2016-05-19T02:27:08Z
generation: 2
labels:
app: vpn
name: vpn
[zion:/var/www/sites/doesfollow.com/current] root# cat config.ru
require 'rubygems'
require 'sinatra'
#require 'newrelic_rpm'
require 'redis'
require 'resque'
set :environment, ENV['RACK_ENV'].to_sym
disable :run, :reload