Skip to content

Instantly share code, notes, and snippets.

View mrcampbell's full-sized avatar

Mike Campbell mrcampbell

  • Divvy
  • Northern Utah
View GitHub Profile
// Decode the request
type TargetObject struct {
ID string `json:"id"`
}
// binaryOfOurSourcePayload = []byte(`{"id": "ABC123"}`)
var targetObject TargetObject
err = json.Unmarshal(binaryOfOurSourcePayload, &targetObject)
if err != nil {
{
"attributes": {
"type": "Account",
"url": "/services/data/v43.0/sobjects/Account/XXX1234567890"
},
"Id": "XXX1234567890",
"IsDeleted": false,
"Name": "Sample Account",
"Phone": "8015551234",
"Welcome_Call_Completed__c": false,
<!DOCTYPE html>
<html>
<ul id="todo-list">
</ul>
// [{"name":"Hit the Gym","is_completed":false},{"name":"Go to the store","is_completed":true}, {"name": "get guhd", "is_completed": true}]
<script>
const LOCAL_STORAGE_TODO_LIST = "LOCAL_STORAGE_TODO_LIST";
@mrcampbell
mrcampbell / main.css
Created April 7, 2020 16:54
Super, Ultra Basic Built React App
body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,"Courier New",monospace}.App{text-align:center}.App-logo{height:40vmin;pointer-events:none}@media (prefers-reduced-motion:no-preference){.App-logo{-webkit-animation:App-logo-spin 20s linear infinite;animation:App-logo-spin 20s linear infinite}}.App-header{background-color:#282c34;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:calc(10px + 2vmin);color:#fff}.App-link{color:#61dafb}@-webkit-keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
/*# sourceMappingURL=main.5f361e03.chunk.css.map */
# NESTED FOR LOOP
def create_deck do
values = ["Ace", "Two", "Three", "Four", "Five"]
suits = ["Spades", "Clubs", "Hearts", "Diamonds"]
# list comprehension. Basically a .map() function
for suit <- suits, value <- values do
"#{value} of #{suit}"
end
end
// an abbreviated, fictional example of a database method you might find at Weave
func (p personService) CreateOrUpdate(ctx context.Context, person app.Person) (app.Person, error) {
var result app.Person
query := `
INSERT INTO persons
(
id,
first_name,
last_name,
function createUser(name, age, address) {
try {
validateUser({name, age, address})
} catch (err) {
throw Error("User is not valid")
}
// insert into database, then return result
return db.insertUser({name, age, address})
}
@mrcampbell
mrcampbell / simple.js
Last active December 8, 2019 21:47
gist for "tests: another form of documentation", medium blog post
function createUser(name, age, address) {
if (age < 13) {
throw Error("user must be older than 13 to register")
}
// insert into database, then return result
return db.insertUser({name, age, address})
}
@mrcampbell
mrcampbell / medium_sqlc_query.sql
Created December 4, 2019 20:36
SQLC Medium Article
-- name: SetPreProvisionFields :exec
UPDATE provisions
SET provisioned_at = now(),
location_id = $2
WHERE salesforce_opportunity_id = $1;
@mrcampbell
mrcampbell / Test_functionA.go
Last active July 8, 2019 20:18
Medium Article: Unit Tests: A Form of Documentation. Exhibit "Express expectations of the current functionality"
func Test_functionA(t *testing.T) {
type args struct {
a int
b int
}
tests := []struct {
name string
args args
want int
wantErr bool