Skip to content

Instantly share code, notes, and snippets.

@danisla
danisla / nest_api.py
Created May 7, 2022 16:13
Python Library for interacting with the Nest camera API including authorization flow.
#!/usr/bin/env python3
import json
import os
import time
from datetime import datetime
from urllib.parse import quote
from urllib import request, parse
import pytz
@danisla
danisla / kube-dns-metrics-exporter.yaml
Created May 21, 2020 18:51
KubeDNS Metrics Exporter to Stackdriver
# Copyright 2020 Google LLC
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@danisla
danisla / cloud_ep.sh
Created April 3, 2020 16:24
Create Cloud Endpoints DNS
#!/bin/bash
# Copyright 2019 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@danisla
danisla / README.md
Last active November 7, 2022 13:59
GKE GPU Sharing Daemonset

GPU Sharing on GKE DaemonSet

NOTE: This is not a Google supported product.

Example Usage

  1. Create a GKE cluster with a GPU node pool:
gcloud container clusters create gpu-sharing-demo --zone us-central1-c
@danisla
danisla / find_gpu.sh
Last active April 15, 2020 20:46
GCPing and GPU finder command line scripts
#!/bin/bash
# Copyright 2019 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@danisla
danisla / README.md
Created June 14, 2019 04:55
MacOS Workstation Setup

Disable Gamepad input for Plex Media Player

PLEX_DIR="${HOME}/Library/Application Support/Plex Media Player"
cat > "${PLEX_DIR}/inputmaps/dualshock4-xbox-emulate.json" <<EOF
{
  "name": "Playstation Dual Shock 4 Windows Mode",
  "idmatcher": "Microsoft.*joystick driver",
  "mapping": {
 }
@danisla
danisla / packer-install.sh
Created August 2, 2018 05:51
Packer Install Script
#!/usr/bin/env bash
function packer-install() {
OS=$(uname -s)
[[ -f ${HOME}/bin/packer ]] && echo "`${HOME}/bin/packer version` already installed at ${HOME}/bin/packer" && return 0
LATEST_URL=$(curl -sL https://releases.hashicorp.com/packer/index.json | jq -r '.versions[].builds[].url' | sort -n | egrep -v 'rc|beta' | egrep "${OS,,}.*amd64" |tail -1)
curl ${LATEST_URL} > /tmp/packer.zip
mkdir -p ${HOME}/bin
(cd ${HOME}/bin && unzip /tmp/packer.zip)
if [[ -z $(grep 'export PATH=${HOME}/bin:${PATH}' ~/.bashrc 2>/dev/null) ]]; then
@danisla
danisla / terraform-install.sh
Last active August 27, 2023 17:05
Terraform latest version install script
#!/bin/bash
function terraform-install() {
[[ -f ${HOME}/bin/terraform ]] && echo "`${HOME}/bin/terraform version` already installed at ${HOME}/bin/terraform" && return 0
LATEST_URL=$(curl -sL https://releases.hashicorp.com/terraform/index.json | jq -r '.versions[].builds[].url' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | egrep -v 'rc|beta' | egrep 'linux.*amd64' |tail -1)
curl ${LATEST_URL} > /tmp/terraform.zip
mkdir -p ${HOME}/bin
(cd ${HOME}/bin && unzip /tmp/terraform.zip)
if [[ -z $(grep 'export PATH=${HOME}/bin:${PATH}' ~/.bashrc) ]]; then
echo 'export PATH=${HOME}/bin:${PATH}' >> ~/.bashrc
@danisla
danisla / .kubefunc.bash
Created October 18, 2017 21:54
Kubernetes Bash Helper Functions
function kube-pod() {
kubectl get pods --selector=run=$1 --output=jsonpath={.items..metadata.name}
}
function helm-install-rbac() {
kubectl create serviceaccount tiller --namespace kube-system
kubectl create clusterrolebinding tiller-cluster-rule \
--clusterrole=cluster-admin \
--serviceaccount=kube-system:tiller
helm init --service-account=tiller
@danisla
danisla / docker-terraform.bash
Last active November 9, 2017 08:42
Terraform with Docker for Linux, OSX and Google Cloud Shell
function terraform()
{
if [[ -e ${HOME}/.config/gcloud/credentials.json ]]; then
GOOGLE_CREDENTIALS="$(cat ${HOME}/.config/gcloud/credentials.json | tr '\n' ' ')";
fi;
GOOGLE_PROJECT=${DEVSHELL_PROJECT_ID:-$(gcloud config get-value project 2>/dev/null)};
VERSION=latest
docker run -u "${UID}:${UID}" -it --rm -v ${HOME}:${HOME} --env-file <(env|awk '/^.+=/'|grep -v TMPDIR) -e GOOGLE_CREDENTIALS="${GOOGLE_CREDENTIALS}" -e GOOGLE_PROJECT="${GOOGLE_PROJECT}" -w $PWD hashicorp/terraform:${VERSION} $@
}