Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve Coffman StevenACoffman

  • Khan Academy
  • Ann Arbor, MI
View GitHub Profile
View channels.md

You can think loosely of channels like pipes for fluid - pour it in one end and out at the other.

By including the arrow <- chan or chan <-, you are achieving three things:

  1. You are making it clear that the parameter is one end of a channel.
  2. You are expressing clearly which end is being supplied.
  3. You are giving more information to the compiler for checking. If the function body tries to use the wrong end of the channel, the compiler can raise an error. These are good reasons to show the channel end whenever possible.

| when you see | which end is of the channel is it for? |

@StevenACoffman
StevenACoffman / gvn.go
Last active Sep 10, 2020
Retrieve App Engine Version name from local git information in Pure JavaScript or in Pure Go
View gvn.go
package main
import (
"fmt"
"os"
"strings"
"github.com/go-git/go-git/v5"
)
View gcp-sql.md

Hi Steve,

You go to APIs and Services > Credentials in the console and you can either take one of the keys that are already there or you can create a new one with the "Create Credentials" button. This is the only way to create API keys, but they can be reused any amount of times. There is a feature request to create them with a gcloud command, however. You can follow it here if you're interested. https://issuetracker.google.com/76227920

Let me know if you have any other questions or concerns and I'll be happy to help.

Cheers!

View Office-Furniture.md
View time.md

From Go: Format a time or date

Consider just running dateparse:

go get -u github.com/araddon/dateparse/dateparse
dateparse --timezone="UTC" "2019-11-20T22:32:59.882Z"
dateparse --timezone="America/Detroit" "2017-07-19 03:21:00"

Go: Format a time or date

@StevenACoffman
StevenACoffman / go-swagger-ui.md
Created May 31, 2020
golang serve Swagger-ui
View go-swagger-ui.md

From https://medium.com/@ribice/serve-swaggerui-within-your-golang-application-5486748a5ed4

SwaggerUI can be downloaded from their GitHub Repo Releases page. Once downloaded, place the contents of dist folder somewhere in your Go project. For example, swaggerui. After that, also move your openapi.json or swagger.json file to swaggerui folder (or whatever you called it), and inside index.html change url to ./swagger.json (e.g. url: "./swagger.json").

Serve using net/http

fs := http.FileServer(http.Dir("./swaggerui"))
http.Handle("/swaggerui/", http.StripPrefix("/swaggerui/", fs))

Serve using Gorilla Mux (commit)

View opa-vs-casbin.md

Information in this Gist originally from this github issue, which is outdated.

As @RomanMinkin mentioned, you can also consider Casbin (https://github.com/casbin/casbin). It is the most starred authorization library in Golang. There are several differences between Casbin and OPA.

Feature Casbin OPA
Library or service? Library/Service Library/Service
How to write policy? Two parts: model and policy. Model is general authorization logic. Policy is concrete policy rule. A single part: Rego
RBAC hierarchy Casbin supports role hierarchy (a role can have a sub-role) Role hierarchies can be encoded in data. Also with the new graph.reachable() built-in function queries over those hierarchies are much more feasible now.
RBAC separation of duties Not supported Supported: two roles cannot be assigned together
View Phabricator-vs-github.md
Phabricator GitHub/GitFlow/Git Branches
Phabricator is based on diffs/patches, not tied to the git history/git tree. This is not inherently better or worse. Or maybe it is? I make no value judgement here. GitHub/GitFlow is based on branches and commits, intrinsically tied to git history/git tree. This is not inherently better or worse. Or maybe it is? I make no value judgement here.
You can munge around in your diffs, smash up history, rebase easily, reorder diffs, and pluck out and land top-of-stack diffs. Generally, stacked diffs are a little simpler to manage here, but when things go wrong, they can go very wrong! You have to be a lot more careful about preserving git history. Generally, stacked diffs can be a bit more annoying, but it’s a lot harder to really break things. You can still do all the things that you can do in Phab, though often it’s required to change history.
View Search my gists.md

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

You can’t perform that action at this time.