Skip to content

Instantly share code, notes, and snippets.

Making an impact

Mark McDonnell Integralist

Making an impact
View GitHub Profile
Integralist / difference between URL host and Request Header
Created Jul 29, 2021
[difference between URL host and Request Header Host] #go #golang #http #url #host
View difference between URL host and Request Header

The r.URL field is created by parsing the HTTP request URI.

The r.Host field is the value of the Host request header. It's the same value as calling r.Header.Get("Host").

If the HTTP request on the wire is:

GET /pub/WWW/TheProject.html HTTP/1.1
Integralist / word-motion-to-be-camelcase-sensitive.viml
Created Jul 27, 2021
[Vim word motion to be camelcase sensitive] #vim #viml
View word-motion-to-be-camelcase-sensitive.viml
function! Word()
" Get cursor current position
let curpos = getpos(".")
" Apply movement
normal! w
" Get cursor potential next position
let wcurpos = getpos(".")
" Return cursor to original place
call setpos(".", curpos)
" Get the string between the two cursor positions
Integralist / Go API JSON
Created Jun 23, 2021
[Go API JSON Issues] #go #golang #json #api #omitempty


If a struct field isn't populated, and is marshalled to JSON, then the field's zero value will be used (e.g. type string zero value == "", type int zero value == 0).

You can use omitempty to prevent the field from being marshalled, but then you won't know if the zero value was intentional or not (e.g. a user might want to set an type int field to zero or a type string field to an empty string).

To avoid that situation you need to have the field be set to a pointer of the type. This is because the zero value for a pointer is nil. This means if the field is nil then the field was never set but if it looks like a zero value for the type being pointed to, then you know it was set to the zero value intentionally.

Integralist / kbd vs code vs pre vs
Last active Jun 22, 2021
[kbd vs code vs pre vs samp] #kbd #markup #render #code
View kbd vs code vs pre vs
  • <kbd> represents keyboard input.
  • <samp> represents sample computer output.
  • <code> represents programming code input as an inline element.
  • <pre> represents programming code input as a block-level markup.
Integralist / PHP - setup Composer with local
Last active Jun 10, 2021
[PHP: setup Composer with local code] #php #composer #local
View PHP - setup Composer with local

Install Composer

  • macOS comes with php version 7.3.24
  • Download composer (instructions) and move binary to your $PATH
  • Create a new project directory (e.g. ~/path/to/your/code/project)
  • Run $ composer init and select the 'project' package type.


For debugging use (e.g. composer require tacnoman/dephpugger).

Integralist / go type asserting coercing.go
Created Jun 8, 2021
[go type asserting/coercing] #go #golang #type #assert #coerce
View go type asserting coercing.go
bar and baz are structs with pointer reference to a foo struct.
there's a fooer interface for the foo struct
we also have a function that accepts a fooer
the purpose of the function is to coerce the arg from an interface type to a concrete type
package main
import (
Integralist / golang embed static file inside of compiled binary.go
Last active Jun 2, 2021
[golang embed static file inside of compiled binary] #go #golang #embed #static
View golang embed static file inside of compiled binary.go
// Refer to for lots of examples
// Here are some embed patterns to try (these can be layered on top of each other with a single variable!):
// downloads/* -> embed.FS
// image/ css/ js/ -> embed.FS
// favicon.ico robots.txt index.html -> embed.FS
// When using `var f embed.FS` you can then utilise that type's methods:
Integralist /
Last active Jun 3, 2021
[golang custom http client] #go #golang #http #client #timeouts
Integralist / git multiple branches.bash
Created Jun 2, 2021
[git multiple branches] #git
View git multiple branches.bash
# do some work
cd ./repo
git checkout some_feature
# I need to make a hotfix, but I don't want to disturn my messy 'some_feature' branch
# I don't want to have to stash things and get things cleaned up
# So I create a new 'worktree'
git worktree list
git worktree add ../hotfix
Integralist / Nested struct embedding.go
Created May 25, 2021
[Go nested struct embedding] #go #golang #struct #embed
View Nested struct embedding.go
package main
import (
type Optional struct {
WasSet bool