Skip to content

Instantly share code, notes, and snippets.

View andrewstuart's full-sized avatar
👋

Andrew Stuart andrewstuart

👋
View GitHub Profile
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
inoremap jk <Esc>
call pathogen#infect()
filetype plugin indent on
set nocompatible "This fixes the problem where arrow keys do not function properly on some systems.
set t_Co=256 "256 colors.
set background=dark
set cursorline "Highlight the cursor row.
set cursorcolumn "Highlight the cursor column.
set title "Make the window title awesome."
colors molokai
@andrewstuart
andrewstuart / .gitlab-ci.yml
Last active June 12, 2023 17:44
One Deployment Per branch, plus CI CD, gitlab and helm setup
image: docker.mydomain.com/build/kube-go-make
variables:
DOCKER_TAG: docker.mydomain.com/myapp/home:$CI_COMMIT_REF_SLUG
DOCKER_HOST: tcp://localhost:2375
DOCKER_DRIVER: overlay
PROD_RSYNC_HOST: myprodserver.com
DOMAIN: mydomain.com
CHART_DIR: chart
@andrewstuart
andrewstuart / docker-apiserver-logs.log
Last active September 26, 2016 20:34
API server yaml
I0926 20:16:31.820147 7 genericapiserver.go:630] Will report 192.168.16.12 as public IP address.
I0926 20:16:31.820858 7 reflector.go:200] Starting reflector *api.LimitRange (0) from k8s.io/kubernetes/plugin/pkg/admission/limitranger/admission.go:154
I0926 20:16:31.820998 7 server.go:297] Initalizing cache sizes based on 0MB limit
I0926 20:16:31.821012 7 genericapiserver.go:301] Setting GenericAPIServer service IP to "10.254.0.1" (read-write).
I0926 20:16:31.821059 7 reflector.go:249] Listing and watching *api.LimitRange from k8s.io/kubernetes/plugin/pkg/admission/limitranger/admission.go:154
I0926 20:16:31.821086 7 reflector.go:211] Starting reflector *api.ResourceQuota (0) from k8s.io/kubernetes/plugin/pkg/admission/resourcequota/resource_access.go:83
I0926 20:16:31.821124 7 reflector.go:249] Listing and watching *api.ResourceQuota from k8s.io/kubernetes/plugin/pkg/admission/resourcequota/resource_access.go:83
E0926 20:16:31.821513 7 reflector.go:203] k8s.io/k
@andrewstuart
andrewstuart / golang-err-structured.md
Last active May 3, 2019 10:23
Golang: Err on the Side of Structured

Golang: Err on the Side of Structured.

TL;DR: Implement the error interface with as much contextual and relevant information as you can in a struct. Then use type switching, not equality or string parsing, to inspect the error.

if err != nil {
  if !strings.Contains(err.Error(), "reader returned negative count from Read") {
    //Do something
 }
I0815 11:32:41.546165 26073 genericapiserver.go:598] Will report 192.168.16.12 as public IP address.
I0815 11:32:41.547146 26073 reflector.go:200] Starting reflector *api.LimitRange (0) from k8s.io/kubernetes/plugin/pkg/admission/limitranger/admission.go:154
I0815 11:32:41.547197 26073 reflector.go:211] Starting reflector *api.ServiceAccount (0) from k8s.io/kubernetes/plugin/pkg/admission/serviceaccount/admission.go:103
I0815 11:32:41.547204 26073 reflector.go:211] Starting reflector *api.Secret (0) from k8s.io/kubernetes/plugin/pkg/admission/serviceaccount/admission.go:119
I0815 11:32:41.547261 26073 server.go:287] Initalizing cache sizes based on 0MB limit
I0815 11:32:41.547377 26073 reflector.go:249] Listing and watching *api.ServiceAccount from k8s.io/kubernetes/plugin/pkg/admission/serviceaccount/admission.go:103
I0815 11:32:41.547439 26073 reflector.go:249] Listing and watching *api.LimitRange from k8s.io/kubernetes/plugin/pkg/admission/limitranger/admission.go:154
I0815 11:32:41.547445
angular.module('app')
.directive('withService', function($injector) {
/**
* @ngdoc directive
* @name app.directive:withService
* @param {String} The name of the service to inject. May be
* an expression "X as Y" in which case the X service will be exposed by
* the name Y.
* @description Injects a service into a new scope the DOM element.
* @scope
@andrewstuart
andrewstuart / defaultValue.js
Created September 17, 2015 21:28
Angular Default Value Directive
app.directive('defaultValue', function() {
/**
* @ngdoc directive
* @name App.directive:defaultValue
* @param {Expression} defaultValue An angular expression for the default
* value of the model
* @requires ngModel
* @description the `default-value` directive allows you to set some
* dynamic default value for anything with an `ngModel`. The model value

The problem with using Angular controllerAs

For a while now, I've been silently bothered by the popularity of controllerAs syntax, how often I hear it recommended, and the reasons it's recommended. It's taken me the better part of two years to take the time to think about and write out why it goes against my gut so strongly, but I think I've figured it out.

It's not the "as" pattern itself. I love having templates that name their dependencies inline. It lowers the cognitive overhead required when reasoning about what your template is doing and displaying, and you don't have to hunt

<ul ng-controller="TabController" id="portalNavigationList" class="menu fl-tabs flc-reorderer-column ng-scope">
<!-- ngIf: layout.currentPortlet -->
<!-- ngRepeat: folder in layout.navigation.content track by folder.ID --><li class="folder-tab ng-scope active" ng-class="{'active': layout.currentFolder === folder}" ng-repeat="folder in layout.navigation.content track by folder.ID">
<!-- ngIf: !folder.edit --><a ng-if="!folder.edit" ng-click="folder.toggleEdit()" ng-href="/uPortal/f/u27l1s300/normal/render.uP" class="ng-binding ng-scope" tabindex="0" href="/uPortal/f/u27l1s300/normal/render.uP">
MSJC
<span ng-click="layout.navigation.remove(folder)" class="remove-folder" role="button" tabindex="0">
<span class="glyphicon glyphicon-remove"></span>
</span>
</a><!-- end ngIf: !folder.edit -->
<!-- ngIf: folder.edit -->