Skip to content

Instantly share code, notes, and snippets.

View keegancsmith's full-sized avatar

Keegan Carruthers-Smith keegancsmith

View GitHub Profile
diff --git a/store/unit_store.go b/store/unit_store.go
index 515ed9c..e145bd0 100644
--- a/store/unit_store.go
+++ b/store/unit_store.go
@@ -90,10 +90,8 @@ func (s unitStores) Refs(f ...RefFilter) ([]*graph.Ref, error) {
}
c_unitStores_Refs_last_numUnitsQueried = 0
- var (
- allRefs []*graph.Ref
@keegancsmith
keegancsmith / git-grep.el
Created August 5, 2015 07:08
M-x rgrep, but using git grep from the top-level git dir
;; M-x rgrep, but using git grep from the top-level git dir.
;; Based on http://stackoverflow.com/questions/25633490/how-can-i-use-m-x-rgrep-with-the-git-grep-command-in-emacs
(defcustom git-grep-command "git --no-pager grep --no-color --line-number <C> <R> | sed 's|^|./|'"
"The command to run with M-x git-grep.")
(defun git-grep (regexp)
"Search for the given regexp using `git grep' in the current directory."
(interactive "sRegexp: ")
(unless (boundp 'grep-find-template) (grep-compute-defaults))
(let ((old-command grep-find-template))
(grep-apply-setting 'grep-find-template git-grep-command)
@keegancsmith
keegancsmith / compare.go
Created November 30, 2015 14:24
Scripts to ensure no regressions in srclib-go go1.5.1 toolchain upgrade
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"reflect"
@keegancsmith
keegancsmith / pgsql_capture.sh
Created March 16, 2016 17:16
Capture querys for pgsql on kubernetes
#!/bin/bash
# This script automates the process of collecting pgsql query logs from
# kubernetes. The idea comes from a fabric script used by instagram (circa
# 2012) https://gist.github.com/mikeyk/2307647
#
# Usage ./pgsql_capture.sh namespace -l app=pgsql
#
# The arguments are passed to `kubectl get pods --namespace` to find the pod to run against
@keegancsmith
keegancsmith / docker-get-manifest.go
Created June 21, 2016 13:02
Outputs to stdout the manifest for an image from dockerhub registry
package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
"os"
@keegancsmith
keegancsmith / k8s-patch.sh
Created October 28, 2016 07:58
A way to more easily bulk update `k8s` specs, requires modification for your use case. Thought I'd share, since there is no nice way in k8s to partially update a bunch of resources. In this case I wanted to update resource constraints of most our deployments. `find some-magic-here | xargs -n1 ./k8s-patch.sh force`
#!/bin/bash
# Use this script as an example of how to patch k8s resources. It currently
# patches the resource constraints.
set -e
ns=$(cat "$2" | jq -r '.metadata.namespace')
name=$(cat "$2" | jq -r '.kind + "/" + .metadata.name')
patch=$(cat "$2" | jq -c '{spec: {template: {spec: {containers: [.spec.template.spec.containers[] | {name: .name, resources: .resources}]}}}}')
@keegancsmith
keegancsmith / keybase.md
Created March 27, 2018 19:25
keybase.md

Keybase proof

I hereby claim:

  • I am keegancsmith on github.
  • I am keegancsmith (https://keybase.io/keegancsmith) on keybase.
  • I have a public key ASDxe-dA0IVfvuE7Jylvmjdc_jVRwRd8Qe5e0U8Q7cm8lwo

To claim this, I am signing this object:

@keegancsmith
keegancsmith / lastline.go
Created April 24, 2018 11:03
Using bufio.Scanner to get the last available line
package main
import (
"bufio"
"bytes"
"fmt"
"log"
"os"
)
(use-package org-gcal
:config
(setq org-gcal-client-id "REDACTED"
org-gcal-client-secret "REDACTED"
org-gcal-file-alist '(("REDACTED" . "~/org-files/gcal.org")
("REDACTED" . "~/org-files/office.org")
("REDACTED" . "~/org-files/oncall.org")))
;; org-gcal wrappers to only sync with a timeout
(defvar org-gcal-fetch-last-run (current-time)
"Timestamp of the last time org-gcal-fetch-store-time was run")
@keegancsmith
keegancsmith / beams.py
Last active September 6, 2019 21:50
Randomized greedy algorithm for allocating presized beams
import random, collections
sizes = [6, 6.6, 7.2, 7.8, 8.4, 9.6, 12]
beams = [
(6, 3.700),
(37, 6.700),
(4, 5.600),
(40, 7.800),
(2, 1.100),