Skip to content

Instantly share code, notes, and snippets.

View markbates's full-sized avatar

Mark Bates markbates

View GitHub Profile
package cli
import (
"io"
"os"
)
// IO represents the standard input, output, and error stream.
type IO struct {
In io.Reader // standard input
@markbates
markbates / github-workflows-goreleaser.yml
Last active March 7, 2020 09:00
Run Go tests in Windows, Mac, Linux. Go version 1.12/1.13 both with Modules and GOPATH.
name: Release
on:
release:
types:
- published
jobs:
release:
name: Release
runs-on: ubuntu-latest
@markbates
markbates / errors.go
Last active June 29, 2019 08:22
Unwrap Go errors from the go 2 errors proposal as well as github.com/pkg/errors
package foo
// go2 errors
type wrapper interface {
Unwrap() error
}
// pkg/errors
type causer interface {
Cause() error
//
// return x
// // this is a comment
// // there are many like it
// // but this is mine
if false {
fmt.Println("in if")
} else if (1 == 2) {
fmt.Println("in else")
} else if true {
package main
import (
"bytes"
"encoding/json"
"fmt"
"text/tabwriter"
)
type Beatle struct {
module github.com/markbates/mysite
require github.com/gobuffalo/packr v1.15.0
@markbates
markbates / client-app.go
Last active November 1, 2018 18:34
store and resolver implementation using s3 for Packr v2
package main
import (
"fmt"
"net/http"
_ "github.com/gobuffalo/buffalo"
"github.com/gobuffalo/packr/v2"
"github.com/markbates/s3packr/s3packr"
)
@markbates
markbates / ruby-install
Last active October 23, 2018 08:50 — forked from msolli/ruby-install
Install Ruby 2.2 on OS X Yosemite with Fish shell
brew update
brew install chruby chruby-fish ruby-install openssl readline libyaml gdbm libffi
brew cleanup
brew tap raggi/ale
brew install openssl-osx-ca
echo ". /usr/local/share/chruby/chruby.fish" >> .config/fish/config.fish
echo ". /usr/local/share/chruby/auto.fish" >> .config/fish/config.fish
ruby-install ruby 2.3.0
echo "ruby-2.3" > .ruby-version
// option 1:
// actions/render.go
"isCurrentPathName": func(name string, help plush.HelperContext) bool {
if cp, ok := help.Value("current_route").(buffalo.RouteInfo); ok {
return cp.PathName == name
}
return false
},
// template.html
<%= f.InputTag("Title") %>
<%= f.TextArea("Body", {rows: 10}) %>
<div id="body-preview"></div>
<button class="btn btn-success" role="submit">Save</button>