Skip to content

Instantly share code, notes, and snippets.

View jbeda's full-sized avatar
💭
E_TOOMANYRESPONSIBILTIES - Poke me on email/slack/twitter for response.

Joe Beda jbeda

💭
E_TOOMANYRESPONSIBILTIES - Poke me on email/slack/twitter for response.
View GitHub Profile
@jbeda
jbeda / gist:3153147
Created July 20, 2012 20:51
Management Service -> GCE auth

For a Management Service to talk to Cloud APIs such as GCE, you can use Service Accounts. The blog post introducing these has a lot of pointers.

Option 1: Single Service Account

In this case, the management service would have a single (or handful) of service accounts when talking to Google. This is slightly simpler but results in a single set of credentials between the Management Service and Google for a large number of projects/accounts.

  1. Create an API project at the API console. This will represent the Management Service in the Google world.
  2. Create a 'Service Account' inside of that project. Instructions to do that are here. This Service Account has an email address that can be added to ACLs at Google. It is an expression of code/service into the Google user system. You can think of it as a supported w
@jbeda
jbeda / pick_number.py
Created December 5, 2012 18:21
Pick a winner out of a hat
import sys
import random
# Pick the number
magic = random.randint(0, 99)
print "Magic number is %d" % magic
candidates = sys.argv[1:]
for candidate in candidates:
@jbeda
jbeda / manifest-template.yaml
Created October 23, 2014 22:28
Script to create VM to host private docker registry on GCE backed by GCS
# Copyright 2014 Google Inc. All rights reserved.
#
# 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,
@jbeda
jbeda / gke-kubecfg.sh
Last active August 29, 2015 14:08
Use kubecfg against GKE cluster
#!/bin/bash
# Copyright 2014 Google Inc. All rights reserved.
#
# 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
#
@jbeda
jbeda / gist:16191ad2cec4835de40b
Last active May 10, 2019 11:48
IP CIDR math in bash
function increment_ipv4 {
local ip_base=$1
local incr_amount=$2
local -a ip_components
local ip_regex="([0-9]+).([0-9]+).([0-9]+).([0-9]+)"
[[ $ip_base =~ $ip_regex ]]
ip_components=("${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}" "${BASH_REMATCH[4]}")
ip_dec=0
local comp
for comp in "${ip_components[@]}"; do
@jbeda
jbeda / gist:2cae7dd22a453c3caa94
Last active November 7, 2020 18:26
URLs for kubernetes release artifacts
$ gsutil ls -R gs://kubernetes-release/release/v0.5.4 | sed 's|gs://kubernetes-release|https://storage.googleapis.com/kubernetes-release|; /^.*:$/d; /^$/d'
https://storage.googleapis.com/kubernetes-release/release/v0.5.4/kubernetes-client-darwin-386.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v0.5.4/kubernetes-client-darwin-amd64.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v0.5.4/kubernetes-client-linux-386.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v0.5.4/kubernetes-client-linux-amd64.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v0.5.4/kubernetes-client-linux-arm.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v0.5.4/kubernetes-salt.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v0.5.4/kubernetes-server-linux-amd64.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v0.5.4/kubernetes.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v0.5.4/bin/darwin/386/kubecfg
@jbeda
jbeda / gist:4ab372c41a324c4988c8
Last active August 29, 2015 14:14
keybase.md
### Keybase proof
I hereby claim:
* I am jbeda on github.
* I am jbeda (https://keybase.io/jbeda) on keybase.
* I have a public key whose fingerprint is 5C24 BBED 521C DD97 489D 6490 01AD FF89 FA0B 63B6
To claim this, I am signing this object:
[jbeda@web:/tmp/foo]$ mkdir -p reala/a
[jbeda@web:/tmp/foo]$ mkdir -p realb/b
[jbeda@web:/tmp/foo]$ mkdir virtual
[jbeda@web:/tmp/foo]$ ln -s v^Ctual ../
[jbeda@web:/tmp/foo]$ cd virtual/
[jbeda@web:/tmp/foo/virtual]$ ln -s ../reala/a a
[jbeda@web:/tmp/foo/virtual]$ ln -s ../realb/b b
[jbeda@web:/tmp/foo/virtual]$ cd a
[jbeda@web:/tmp/foo/virtual/a]$ pwd
/tmp/foo/virtual/a
@jbeda
jbeda / nar-spec.md
Created September 1, 2015 23:04
Nix Archive (NAR) file specification

This is taken directly from Figure 5.2 in http://nixos.org/~eelco/pubs/phd-thesis.pdf. It is presented here to be more directly linkable.

serialise(fso) = str("nix-archive-1") + serialise1(fso)

serialise1(fso) = str("(") + seralise2(fso) + str(")")

serialise2(type=Regular, exec, contents) =
  str("type") + str("regular")
 + (
@jbeda
jbeda / hello.xml
Created September 29, 2015 22:46
Minimal OOXML file
<?xml version="1.0" encoding="utf-8"?>
<?mso-application progid="Word.Document"?>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
<pkg:part pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:name="/_rels/.rels" pkg:padding="512">
<pkg:xmlData>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Target="word/document.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"/>
</Relationships>
</pkg:xmlData>
</pkg:part>