Skip to content

Instantly share code, notes, and snippets.

View joncalhoun's full-sized avatar
💻
Making Go Courses

Jon Calhoun joncalhoun

💻
Making Go Courses
View GitHub Profile
// The builder pattern makes it really hard to return errors during a build
// step. Consider using functional options instead, which work much better with
// incremental errors.
// Let's say you have the builder pattern.
type T struct { ... }
func (t *T) A(arg string) *T {
// do stuff here with t and arg
return t
type Messenger struct {
// Add this field here
Client *http.Client
mux *http.ServeMux
messageHandlers []MessageHandler
deliveryHandlers []DeliveryHandler
readHandlers []ReadHandler
postBackHandlers []PostBackHandler
optInHandlers []OptInHandler
gotest() {
go test $* | sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'' | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'' | GREP_COLOR="01;33" egrep --color=always '\s*[a-zA-Z0-9\-_.]+[:][0-9]+[:]|^'
}
@joncalhoun
joncalhoun / ..README.md
Last active May 30, 2023 05:29
Most of my settings for a new mac

Chrome

  • Download & install Chrome
  • Login & sync settings/whatever else

Mac OS settings

  • General -> Use dark menu bar
  • General -> Default web browser: Google Chrome
@joncalhoun
joncalhoun / cloudSettings
Last active August 17, 2020 14:57
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-08-17T14:57:52.730Z","extensionVersion":"v3.4.3"}
tests=($(ls spec/features))
for i in "${tests[@]}"; do
firstChar=${i:0:1}
if [[ $firstChar < "l" ]]
# Replace this w/ test running.
then echo "bundle exec rspec spec/features/$i"
fi
done
@joncalhoun
joncalhoun / _user_country.html.erb
Created January 1, 2015 20:58
Quick demo of country select in a user.
<div class="form-group #{attribute.errrors? ? "has-error" : ""}">
<label for="#{attribute.form_id}">
<%= attribute.label_name %>
</label>
<%= country_select("user", "country", selected: attribute.value) %>
</div>
@joncalhoun
joncalhoun / output.json
Created October 29, 2012 16:55
EasyPost cURL Example Output
{
"postages":["test.png"]
}
@joncalhoun
joncalhoun / easypost-curl.sh
Created October 29, 2012 16:55
EasyPost cURL Example
curl https://www.easypost.co/api/postage/list \
-u cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi:
@joncalhoun
joncalhoun / easypost-curl.sh
Created October 29, 2012 16:44
EasyPost cURL Example
curl https://www.easypost.co/api/postage/get \
-u cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi: \
-d 'label_file_name=test.png'