Skip to content

Instantly share code, notes, and snippets.

@lutter
lutter / composition.org
Last active April 16, 2020 18:11
Subgraph composition

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 / 00-digest.md
Last active April 16, 2020 18:12
JSON digests

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 / views.sql
Last active March 14, 2019 21:14
Useful `graph-node` views
--
-- 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 February 27, 2019 23:49
serde_json regression from 1.0.25 to 1.0.38
[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 January 24, 2019 19:19
Installation instructions for Graph CLI
#! /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
@lutter
lutter / .gitignore
Last active January 22, 2019 19:09
issue-680
node_modules/
yarn.lock
@lutter
lutter / Dockerfile
Created October 17, 2018 20:58
HAProxy container for loadbalancing between Puppet masters/compilers
FROM haproxy:latest
# HAProxy management port
EXPOSE 8765
# Puppetserver
EXPOSE 8140
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
COPY docker-entrypoint.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'"
@lutter
lutter / gist:916731a5503fd5967da7124eb344267b
Created April 8, 2017 05:57
puppet resource for core types
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 March 31, 2017 19:51
Provider testing
---
# 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