Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Making Go Courses

Jon Calhoun joncalhoun

💻
Making Go Courses
View GitHub Profile
View builder.go
// 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
View messenger.go
type Messenger struct {
// Add this field here
Client *http.Client
mux *http.ServeMux
messageHandlers []MessageHandler
deliveryHandlers []DeliveryHandler
readHandlers []ReadHandler
postBackHandlers []PostBackHandler
optInHandlers []OptInHandler
View gotest.sh
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 Nov 27, 2020
Most of my settings for a new mac
View ..README.md

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 Aug 17, 2020
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2020-08-17T14:57:52.730Z","extensionVersion":"v3.4.3"}
View tests.sh
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 Jan 1, 2015
Quick demo of country select in a user.
View _user_country.html.erb
<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 Oct 29, 2012
EasyPost cURL Example Output
View output.json
{
"postages":["test.png"]
}
@joncalhoun
joncalhoun / easypost-curl.sh
Created Oct 29, 2012
EasyPost cURL Example
View easypost-curl.sh
curl https://www.easypost.co/api/postage/list \
-u cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi:
@joncalhoun
joncalhoun / easypost-curl.sh
Created Oct 29, 2012
EasyPost cURL Example
View easypost-curl.sh
curl https://www.easypost.co/api/postage/get \
-u cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi: \
-d 'label_file_name=test.png'
You can’t perform that action at this time.