Skip to content

Instantly share code, notes, and snippets.

View Addono's full-sized avatar
🛠️
Solving software problems, one line of code (or long Slack message) at a time

Adriaan Knapen Addono

🛠️
Solving software problems, one line of code (or long Slack message) at a time
View GitHub Profile
@Addono
Addono / index.ts
Last active October 10, 2020 13:29
Updated imports Docusaurus plugin
import { LoadContext, Plugin } from '@docusaurus/types'
function pluginGoatcounter({ siteConfig: { themeConfig }}: LoadContext): Plugin<void> {
// ... remainder of your your plugin
}
export default pluginGoatcounter
@Addono
Addono / index.js
Created October 10, 2020 13:28
Original export of JavaScript based Docusaurus plugin
module.exports = function (context) {
const { siteConfig } = context
const { themeConfig } = siteConfig
// ... remainder of your plugin
}
<script data-goatcounter="https://MYCODE.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script>
const path = require('path')
module.exports = {
// ...
themeConfig: {
// ...
goatcounter: {
code: 'MYCODE',
},
},
@Addono
Addono / plugin.js
Last active October 10, 2020 13:25
Docusaurus in-project plugin
module.exports = function (context) {
const { siteConfig } = context // Siteconfig is the content of docusaurus.config.js
const { themeConfig } = siteConfig
if (!themeConfig.goatcounter) {
throw new Error(
'You need to specify `goatcounter` object in `themeConfig` '
+ 'with `code` field in it to use docusaurus-plugin-goatcounter'
)
}
if (!themeConfig.goatcounter.code) {
@Addono
Addono / machine.js
Last active July 15, 2020 08:31
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'verifiedLocation',
initial: 'registeringListener',
states: {
registeringListener: {
on: { LISTENING: 'listening' },
},
listening: {
on: { READY: 'ready' },
@Addono
Addono / apollo-client-server-side.ts
Last active July 2, 2020 11:13
Server side Apollo Client usage example
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client'
// Create GraphQL Client for FaunaDB, replace HttpLink configuration
// with your own GraphQL endpoint configuration.
const client = new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: 'https://graphql.fauna.com/graphql',
headers: {
"Authorization": `Bearer ${process.env.FAUNADB_SECRET}`,
@Addono
Addono / docker-compose.yaml
Created April 5, 2020 18:55
Create an Apache Zeppelin container with Docker Compose
zeppelin:
image: apache/zeppelin:0.9.0
environment:
ZEPPELIN_LOG_DIR: /logs
ZEPPELIN_NOTEBOOK_DIR: /notebook
volumes:
- ./logs:/logs
- ./notebook:/notebook
- ./helium:/zeppelin/helium
@Addono
Addono / add-yaml-lint.sh
Last active October 4, 2020 20:35
Installs yaml-lint as a dependency and creates a pre-commit hook which invokes it using husky.
#!/bin/sh
# Add yaml-lint as a dependency
yarn add -D yaml-lint
# Add a lint script
npx json -I -f package.json -e "this.scripts.lint='yamllint *.{yaml,yml}'"
# Add husky as a dependency
yarn add -D husky
{
"errors": [
{
"message": "Request failed with status code 404",
"locations": [
{
"line": 2,
"column": 3
}
],