Skip to content

Instantly share code, notes, and snippets.

View markhibberd's full-sized avatar

markhibberd markhibberd

View GitHub Profile
@markhibberd
markhibberd / postmortem.md
Created June 21, 2018 01:47 — forked from mlafeldt/postmortem.md
Example Postmortem from SRE book, pp. 487-491

Shakespeare Sonnet++ Postmortem (incident #465)

Date

2015-10-21

Authors

  • jennifer
  • martym
@markhibberd
markhibberd / .profile
Created September 23, 2016 08:09 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@markhibberd
markhibberd / news.md
Last active August 29, 2015 13:56 — forked from nkpart/news.md
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten

Chef Cheat sheet

Configuring Chef

To install stuff needed to run chef in a solo mode (Small one or two server configuration):

gem install knife-solo

To setup chef after it has been installed:

case class Person(name: String, age: Int)
implicit val DecodePerson: DecodeJson[Person] = jdecode2L(Person(_: String, _: Int))("name", "age")
implicit val EncodePerson: EncodeJson[Person] = jencode2L((p: Person) => (p.name, p.age))("name", "age")
val decoded: Option[Person] = """{"name":"Fred","age":"40"}""".decodeOption[Person]
val encoded: Option[String] = decoded.map(_.jencode.nospaces)
object T {
implicit def XIntToInt(x: XInt): Int = x.n
// isomorphism to Int
case class XInt(n: Int)
case class Wibble[A](a: A) {
def wibble(implicit ev: A <:< Int) = a + 9
def map[B](f: A => B) =
val username: Option[String] \/ String = for {
parsed <- requestJson.parse.swapped(_.map(_.some)) // Parse the JSON.
jsonObject <- parsed.obj.toRight[Option[String]] // Get the JSON as a JsonObject instance.
userIDJson <- jsonObject("userid").toRight[Option[String]] // Get the "userid" field from the JsonObject.
userID <- userIDJson.string.toRight[Option[String]] // Get the value of the "userid" field.
user <- lookupUser(userID).toRight[Option[String]] // Get an instance of User for the user ID.
} yield user.username
import Data.Monoid
import Control.Monad.State
import Control.Monad.Reader
data RequestHeaders =
RequestHeaders [(String, String)]
data ResponseHeaders =
ResponseHeaders [(String, String)]
import Data.Text
import Control.Monad.Reader
data ZResult a =
ZVal a
| ZNotFound
| ZFail Text
| ZUnauth Text
newtype ZResultT m a = ZResultT {