Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Actively recommending people not to use WordPress!

Michael Bøcker-Larsen mblarsen

💭
Actively recommending people not to use WordPress!
View GitHub Profile
@mblarsen
mblarsen / toilet-demo.sh
Created Oct 24, 2020
Small script so showcase all fonts for figlet and toilet
View toilet-demo.sh
#!/usr/bin/env bash
for f in $(ls /usr/share/figlet/*{flf,tlf}); do
f=$(basename -s .tlf $f)
f=$(basename -s .flf $f)
figlet -f $f $f
toilet --gay -S -f $f $f
echo $f
done
@mblarsen
mblarsen / zsh-fix-mv.sh
Last active May 14, 2019
zsh: fix command not found: _mv
View zsh-fix-mv.sh
rm -f ~/.zcompdump*
exec zsh -l
@mblarsen
mblarsen / example.go
Last active Apr 19, 2019
A small CLI wrapper + Go test wrapper for @serverless/event-mocks
View example.go
func TestHandler(t *testing.T) {
req := api.Req{}
reqBody, _ := json.Marshal(map[string]interface{}{
"requestContext": map[string]interface{}{
"Authorizer": map[string]interface{}{
"claims": map[string]interface{}{
"cognito:username": "my user",
},
},
},
@mblarsen
mblarsen / test_match.sh
Created Apr 17, 2019
Query buildkit builds for changes since last
View test_match.sh
#!/usr/bin/env bash
set -euo pipefail
function builds() {
curl -s https://graphql.buildkite.com/v1 \
-H "Authorization: Bearer $GRAPHQL_KEY" \
-d '{
"query": "query SuccessfullBuilds { pipeline(slug: \"'"$BUILDKITE_ORGANIZATION_SLUG/$BUILDKITE_PIPELINE_SLUG"'\") { builds { edges { node { id commit message state } } } } }",
"variables": "{ }"
}'
View keybase.md

Keybase proof

I hereby claim:

  • I am mblarsen on github.
  • I am mblarsen (https://keybase.io/mblarsen) on keybase.
  • I have a public key ASDazMiuoLmVqtEF123TAjZvE7S47WTshQTiHzeg1-H7lAo

To claim this, I am signing this object:

@mblarsen
mblarsen / array.js
Created Mar 1, 2018
Array.prototype extensions
View array.js
Object.defineProperty( // eslint-disable-line
Array.prototype, 'flatMap', {
value: function (mapFunction) {
return Array.prototype.concat.call([], ...this.map(mapFunction))
}
}
)
Object.defineProperty( // eslint-disable-line
Array.prototype, 'tap', {
@mblarsen
mblarsen / SourceText.vue
Created Nov 13, 2017
Vue Editor Tutorial - Step 1 - SourceText.vue
View SourceText.vue
<template>
<div class="source-text">
<div class="source-text__code" ref="content" @input="throttledUpdate" contenteditable="true" spellcheck="false"></div>
<div class="has-text-left">
<button @click="$emit('input', '')" class="button is-success">Clear</button>
</div>
</div>
</template>
<script>
import {debounce} from 'lodash-es'
@mblarsen
mblarsen / App.vue
Last active Nov 13, 2017
Vue Editor Tutorial - Step 1 - App.vue
View App.vue
<template>
<div class="split">
<div class="split__item">
<cms-page v-model="content"></cms-page>
<source-text v-model="content"></source-text>
</div>
<div class="split__item">
<front-page v-model="content"></front-page>
</div>
</div>
@mblarsen
mblarsen / package.json
Last active Nov 9, 2017
gitschwifty package.json scripts
View package.json
"scripts": {
"begin": "git reset --hard start",
"complete": "git reset --hard complete",
"previous": "git reset --hard complete",
"next": "git reset --hard $(git describe --tags)",
"reset": "git reset --hard $(git describe --tags)",
"current": "echo \"You are at step \"$(git describe --tags)"
}
View main.js
import Vue from 'vue'
import Acl from 'vue-browser-acl'
Vue.use(Acl, user, (acl) => {
acl.rule(view, Post)
acl.rule([edit, delete], Post, (user, post) => post.userId === user.id)
acl.rule('moderate', Post, (user) => user.isModerator())
})