Skip to content

Instantly share code, notes, and snippets.

Avatar

Davis Ford davisford

View GitHub Profile
View gist:2268065e9b1d3d02bcfafeb852a95a67
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@davisford
davisford / rfc3339.swift
Created May 2, 2019 — forked from kristopherjohnson/rfc3339.swift
Parsing or formatting an RFC 3339 timestamp using NSDateFormatter
View rfc3339.swift
import Foundation
/// Parse RFC 3339 date string to NSDate
///
/// :param: rfc3339DateTimeString string with format "yyyy-MM-ddTHH:mm:ssZ"
/// :returns: NSDate, or nil if string cannot be parsed
public func dateForRFC3339DateTimeString(rfc3339DateTimeString: String) -> NSDate? {
let formatter = getThreadLocalRFC3339DateFormatter()
return formatter.dateFromString(rfc3339DateTimeString)
}
View ginkgo-cheatsheet.md

FYI: I install ginkgo into $HOME/gocode. My .bash_profile does this:

export GOPATH=$HOME/gocode
export PATH=$PATH:$GOPATH/bin

And I do a custom GOPATH per project. I don't like global GOPATH for all projects. So on projectx, I have to cd projectx && export GOPATH=$(pwd):$GOPATH for example. It is a minor inconvenience, but I think it is cleaner.

This means, I want to install binaries like ginkgo into my global GOPATH and not necessarily my project path. Hope that makes sense.

@davisford
davisford / nats-cluster.txt
Last active May 4, 2017
Quick nats cluster
View nats-cluster.txt
docker run -it --rm -p 4222:4222 -p 6222:6222 -p 8222:8222 --name nats-main nats
docker run -it --rm --name=nats-2 --link nats-main nats --cluster=nats://0.0.0.0:6222 --routes=nats-route://ruser:T0pS3cr3t@nats-main:6222
docker run -it --rm --name=nats-3 --link nats-main nats --cluster=nats://0.0.0.0:6222 --routes=nats-route://ruser:T0pS3cr3t@nats-main:6222
You now have a 3-node nats cluster. See http://localhost:8222/
@davisford
davisford / Setup MongoDB on localhost as Replica Set
Last active Jul 28, 2021
Setup MongoDB replica set on local host with only a single primary
View Setup MongoDB on localhost as Replica Set
Add the `replication` section to the mongod.conf file:
```
$cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
engine: mmapv1
View hack.go
// super quick hack to test mongodb replica set. once the replica set is running
// attemtp rs.stepDown() or just kill the primary and observe the behavior.
package main
import (
"fmt"
mgo "gopkg.in/mgo.v2"
"time"
)
View stringview.js
"use strict";
/*\
|*|
|*| :: Number.isInteger() polyfill ::
|*|
|*| https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
|*|
\*/
View mdtopdf.sh
#!/bin/sh
if (( $# != 2))
then
echo "Usage: md2pdf.sh <input.md> <output.pdf>"
exit 1
fi
markdown $1 | htmldoc --cont --headfootsize 8.0 --linkcolor blue --linkstyle plain --format pdf14 - > $2
View gist:0823eb65508994c4622c
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans