Skip to content

Instantly share code, notes, and snippets.

@lutter
lutter / 00-digest.md
Last active Apr 16, 2020
JSON digests
View 00-digest.md

Digesting JSON data

This is a description of how we can compute a Digest of the subset of JSON data that we care about.

The JSON subset puts the following restrictions on JSON values:

  • the names of object properties must be printable ASCII characters (i.e., UTF-8 code points 0x20 ' ' through 0x7e '~')
  • JSON numbers must be representable as 32 bit signed integers
@lutter
lutter / composition.org
Last active Apr 16, 2020
Subgraph composition
View composition.org

GraphQL schema

type _Schema_
  @import(
    types: ["Address", { name: "Account", as: "EthAccount" }],
    from: { id: "Qmsubgraph" })

A string entry in types is shorthand for { name: STRING, as: STRING }

@lutter
lutter / views.sql
Last active Mar 14, 2019
Useful `graph-node` views
View views.sql
--
-- subgraphs schema
--
drop schema if exists meta cascade;
create schema meta;
create view meta.subgraphs as
select id,
data->'name'->>'data' as name,
(data->'createdAt'->>'data')::int as created_at,
@lutter
lutter / Cargo.toml
Last active Feb 27, 2019
serde_json regression from 1.0.25 to 1.0.38
View Cargo.toml
[package]
name = "json"
version = "0.1.0"
authors = ["David Lutterkort <lutter@watzmann.net>"]
edition = "2018"
[dependencies]
serde_json = { version = "=1.0.38", features = ["arbitrary_precision"] }
#serde_json = { version = "=1.0.25", features = ["arbitrary_precision"] }
serde_derive = "1.0.88"
@lutter
lutter / fedora.sh
Created Jan 24, 2019
Installation instructions for Graph CLI
View fedora.sh
#! /bin/bash
# Run these as root or sprinkle sudo in here as appropriate
dnf install -y gcc-c++ make libsecret-devel git
curl --silent --location https://rpm.nodesource.com/setup_11.x | bash -
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
dnf install -y yarn
yarn global add @graphprotocol/graph-cli
View .gitignore
node_modules/
yarn.lock
@lutter
lutter / Dockerfile
Created Oct 17, 2018
HAProxy container for loadbalancing between Puppet masters/compilers
View Dockerfile
FROM haproxy:latest
# HAProxy management port
EXPOSE 8765
# Puppetserver
EXPOSE 8140
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
COPY docker-entrypoint.sh /
View lines.sh
#! /bin/bash
# Use as 'lines.sh /some/file'
# The file we want to manipulate
src=/tmp/lines.txt
# The line we are looking for (including quotes !)
line="'Include $1'"
View gist:916731a5503fd5967da7124eb344267b
for typ in $(puppet resource -t); do echo $typ; puppet resource $typ > /dev/null; done
augeas
Error: Could not run: Provider augeas has not defined the 'instances' class method
computer
cron
exec
file
Error: Could not run: Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc
filebucket
@lutter
lutter / test.yaml
Last active Mar 31, 2017
Provider testing
View test.yaml
---
# Test the behavior of a specific provider.
#
# The tests will generally be destructive; there's no good way to mock what
# external providers do (we could try and intercept execve and/or open, but
# that would still leave lots of ways in which providers can alter a
# system)
desc: check sysv provider
# The name of the provider to test