Skip to content

Instantly share code, notes, and snippets.

View kevincantu's full-sized avatar

Kevin Cantú kevincantu

  • Palo Alto Networks
  • Oakland, California
View GitHub Profile
@mdwhatcott
mdwhatcott / custom_json.go
Created July 29, 2015 17:15
Example of implementing MarshalJSON and UnmarshalJSON to serialize and deserialize custom types to JSON in Go. Playground: http://play.golang.org/p/7nk5ZEbVLw
package main
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
)
func main() {
@nitely
nitely / nm-resume.service
Created October 23, 2015 00:14
Ubuntu +15.04 systemd restart network after resume
# sudo nano /lib/systemd/system/nm-resume.service
# sudo systemctl enable nm-resume.service
[Unit]
Description=Restart NetworkManager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
[Service]
ExecStart=/bin/systemctl --no-block restart NetworkManager.service
@shu8
shu8 / stopAutoplayingGifs.user.js
Created March 31, 2016 18:08
A userscript that stops auto-playing GIFs in chat
// ==UserScript==
// @name Stop GIFs auto-playing
// @namespace http://stackexchange.com/users/4337810/
// @version 1.0
// @description A userscript that stops auto-playing GIFs in chat
// @author ᔕᖺᘎᕊ (http://stackexchange.com/users/4337810/)
// @match *://chat.stackoverfow.com/*
// @match *://chat.meta.stackexchange.com/*
// @match *://chat.stackexchange.com/*
// @require https://rawgit.com/krasimir/gifffer/master/build/gifffer.min.js
@kevincantu
kevincantu / steps to do big updates to a .gitattributes file.bash
Last active March 17, 2021 02:03
User experience rebasing a working branch to origin/master after we've merged (currently AKA: origin/kevin-eol-cleanup)
# update the .gitattributes
git add .gitattributes
git commit -am "cleaning up line endings"
# force Git to re-index everything
rm .git/index
git reset
git add -u
# now modify that commit
@bojand
bojand / index.md
Last active July 15, 2024 02:51
gRPC and Load Balancing

Just documenting docs, articles, and discussion related to gRPC and load balancing.

https://github.com/grpc/grpc/blob/master/doc/load-balancing.md

Seems gRPC prefers thin client-side load balancing where a client gets a list of connected clients and a load balancing policy from a "load balancer" and then performs client-side load balancing based on the information. However, this could be useful for traditional load banaling approaches in clound deployments.

https://groups.google.com/forum/#!topic/grpc-io/8s7UHY_Q1po

gRPC "works" in AWS. That is, you can run gRPC services on EC2 nodes and have them connect to other nodes, and everything is fine. If you are using AWS for easy access to hardware then all is fine. What doesn't work is ELB (aka CLB), and ALBs. Neither of these support HTTP/2 (h2c) in a way that gRPC needs.

@kevincantu
kevincantu / multi-line-grep.bash
Created July 12, 2018 22:44
multi-line grepping
grep -Plrz "Notebook[[]{\n}" *
@nownabe
nownabe / deployment.yaml
Created August 22, 2018 13:38
Deserialize Kubernetes objects in Go
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: my-namespace
name: memcached
spec:
replicas: 1
selector:
matchLabels:
app: memcached
@lizthegrey
lizthegrey / attributes.rb
Last active September 24, 2024 14:33
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@pydevops
pydevops / private-k8s.md
Last active August 20, 2024 00:55
how to set up kubectl on laptop for private endpoint ONLY k8s cluster (AWS/GCP/On prem)

HTTP tunnel

On prem k8s cluster set up with bastion vm

  1. Create a bastion vm in your data center or in cloud with connectivity set up (usually vpn) to the on prem data center.
  2. Install tinyproxy on the bastion vm and pick a random port as it would be too easy for spam bot with default 8888, set up as systemd service according to https://nxnjz.net/2019/10/how-to-setup-a-simple-proxy-server-with-tinyproxy-debian-10-buster/. Make sure it works by validating with curl --proxy http://127.0.0.1:<tinyproxy-port> https://httpbin.org/ip. And I don't use any user authentication for proxy, so I locked down the firewall rules with my laptop IP/32.
  3. Download the kubeconfig file for the k8s cluster to your laptop
  4. From your laptop, run
HTTPS_PROXY=<bastion-external-ip>:<tinyproxy-port> KUBECONFIG=my-kubeconfig kubectl get nodes
@limed
limed / maws-federate.py
Last active June 4, 2022 22:31
Federate into aws console when you have aws keys exported
#!/usr/bin/env python3
import json
import sys
import requests
import click
from webbrowser import open_new_tab
from urllib.parse import quote_plus
from os import getenv, environ