Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
@Integralist
Integralist / Let Destructuring.md
Last active Nov 24, 2020
Clojure destructuring using `let` (which allows local storage inside of a function, we would say a local "variable" but that would be misleading because all data is immutable in Clojure)
View Let Destructuring.md

In Clojure you can apply destructuring within either a let binding list; function parameter list or even a macro.

A simple example would be:

(def coords [5 7]) ; define a symbol "coords" that points to a vector [5 7]
(let [[x y] coords] (println "x:" x "y:" y))
; => x: 5 y: 7
@Integralist
Integralist / Google Doc Code Syntax.md
Last active Nov 20, 2020
[Google Doc Code Syntax] #google #doc #code #syntax #brew #highlight
View Google Doc Code Syntax.md
brew install highlight

Now copy some code to your clipboard, followed by running:

pbpaste | highlight --syntax=go -O rtf | pbcopy
@Integralist
Integralist / Github GPG Commit Signing Key.md
Last active Nov 18, 2020
[Github GPG Commit Signing Key] #gpg #github #commit #sign #key
View Github GPG Commit Signing Key.md
gpg --full-generate-key
git config --global --edit
[user]
@Integralist
Integralist / sed replace content across multiple files.bash
Last active Nov 18, 2020
[sed replace content across multiple files] #sed #replace #global #multiple #files #bash
View sed replace content across multiple files.bash
gsed -i 's/metrics.NewWriter(/metrics.NewLegacyWriter(/' **/*.go
# UPDATE: glob/wildcard doesn't appear to work any more, needs to be individual file streams
find . -type f -name *.go -exec gsed -i 's/foo/bar/' {} \;
@Integralist
Integralist / Populate (or update) pkg.go.dev with new package.md
Created Nov 18, 2020
[Populate (or update) pkg.go.dev with new package] #go #golang #dev #pkg
View Populate (or update) pkg.go.dev with new package.md

If you want a project to appear in https://pkg.go.dev then visit the expected page and click on the "Request ..." button.

e.g.

https://pkg.go.dev/github.com/integralist/go-flags

I clicked on the button "Request github.com/integralist/go-flags" and it started to populate.

@Integralist
Integralist / GitHub curl.sh
Last active Nov 13, 2020 — forked from madrobby/gist:9476733
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
View GitHub curl.sh
curl --header 'Authorization: token INSERTACCESSTOKENHERE' \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location https://api.github.com/repos/owner/repo/contents/path
# Example...
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
@Integralist
Integralist / Security Types - Encryption, Hashing, Signatures.md
Created Nov 12, 2020
[Security Types - Encryption, Hashing, Signatures] #security #sec #encryption #hash #signatures #hmac
View Security Types - Encryption, Hashing, Signatures.md
  • Encryption helps ensure confidentiality.
  • Hashing can help ensure integrity.
  • Digital signatures or message authentication codes (MAC, including keyed hashing such as HMAC) can be used to verify authenticity.
@Integralist
Integralist / Ruby RVM.bash
Last active Nov 11, 2020
[Ruby RVM] #ruby #rvm
View Ruby RVM.bash
# install rvm
#
curl -sSL https://get.rvm.io | bash
# lookup available ruby interpreters
#
rvm list known
# install specific ruby version
#
@Integralist
Integralist / CLI terminology flags vs arguments vs options.md
Created Nov 11, 2020
[CLI terminology flags vs arguments vs options] #cli #terminology #flags #arguments #args #options
View CLI terminology flags vs arguments vs options.md

Example binary execution:

<command> <flags|options> <arguments>

Note: 'options' was historically used to suggest the input as being 'optional' and so it typically maps to .

@Integralist
Integralist / 1. WindowMock.js
Last active Nov 9, 2020
Mocking the `window` object in JavaScript unit tests
View 1. WindowMock.js
define([
'module/bootstrap', // this is jQuery and PubSub libs
], function (lib) {
var windowMock = {
resizeSet: false, // set within the fake `lib` object below
createFakeWindow: function(width, height) {
return {
document: {
documentElement: {
You can’t perform that action at this time.