Skip to content

Instantly share code, notes, and snippets.

View mseemann's full-sized avatar
🌴
On vacation

Michael Seemann mseemann

🌴
On vacation
View GitHub Profile
@mseemann
mseemann / MongoStats.java
Created September 3, 2021 15:03
MongoStats
Query tailQ = new Query().addCriteria(Criteria.where("ns").is("streams.user"));
reactiveMongoTemplate.tail(tailQ, OplogEntry.class, "oplog.rs")
.retryWhen(Retry.indefinitely().doAfterRetryAsync(signal -> Mono.delay(Duration.ofSeconds(10)).then()))
.subscribe(entry -> {
log.info("tailed entry: {}", entry);
lastOplogAt.set(entry.ts().getTime() * 1000L);
});
@mseemann
mseemann / MongoStats.java
Created September 3, 2021 15:10
MongoStats -> Prometheus
Gauge.builder("sync.last.seen.oplog.at", this, mongoStats -> mongoStats.lastOplogAt.get())
.strongReference(true)
.register(Metrics.globalRegistry);
@mseemann
mseemann / UserCollectionChangeStreamService.java
Created September 3, 2021 15:23
UserCollectionChangeStreamService
Gauge.builder("sync.last.seen.doc.at", this, listener -> listener.lastSeenAt.get())
.strongReference(true)
.register(Metrics.globalRegistry);
Gauge.builder("sync.last.processed.doc.at", this, listener -> listener.lastProcessedAt.get())
.strongReference(true)
.register(Metrics.globalRegistry);
@mseemann
mseemann / promql
Created September 4, 2021 10:32
sync lag
max_over_time(sync_last_seen_oplog_at[24h]) - ignoring(instance, job) max_over_time(sync_last_seen_doc_at[24h])
@mseemann
mseemann / process_lag.promql
Created September 4, 2021 10:34
process_lag.promql
max_over_time(sync_last_processed_doc_at[24h]) - max_over_time(sync_last_seen_doc_at[24h])
@mseemann
mseemann / SampleContract.sol
Created January 6, 2022 15:45
SampleContract
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
contract SampleContract {
uint storedData;
function set(uint x) public {
storedData = x;
}
const SampleContract = artifacts.require("SampleContract");
contract("SampleContract", function (accounts) {
it("...should store the value 89.", async function () {
const simpleStorageInstance = await SampleContract.deployed();
// Set value of 89
await simpleStorageInstance.set(89, {from: accounts[1]});
// Get stored value
{
"compilerOptions": {
"lib": ["ES2018", "DOM"],
"module": "CommonJS",
"moduleResolution": "node",
"strict": true,
"target": "ES2018",
"sourceMap": true,
"esModuleInterop": true
}
import React, {useEffect, useState} from "react";
import "./App.css";
import Web3 from "web3";
import SampleContractCompiled from "backend/build/contracts/SampleContract.json";
import {SampleContract} from "backend/types/web3-v1-contracts/SampleContract";
import {AbiItem} from "web3-utils";
function App() {
const [storageValue, setStorageValue] = useState(null as string | null);
import {
Directive,
Input,
OnDestroy,
OnInit,
TemplateRef,
ViewContainerRef,
} from '@angular/core';
import { Store } from '@ngrx/store';
import { User } from './user';