Skip to content

Instantly share code, notes, and snippets.

import pprint
import dateutil.relativedelta
from datetime import datetime
import glob
import os
import sys
from web3 import Web3
from datetime import datetime
from python_graphql_client import GraphqlClient
import json
#!/bin/bash
function checkPorts {
echo -e '\n\e[42mCheck Ports\e[0m\n'
if ss -tulpen | awk '{print $5}' | grep -q ":3000$" ; then
echo -e "\e[31mInstallation is not possible, port 3000 already in use.\e[39m"
exit
else
echo "Port 3000 is OK"
fi
echo -e '\e[40m\e[92m'
echo -e ' '
echo -e '██████╗ █████╗ ██╗ ██╗ █████╗ ██╗ ██╗███╗ ███╗███╗ ██╗███████╗'
echo -e '██╔══██╗██╔══██╗██║ ██║██╔══██╗╚██╗ ██╔╝████╗ ████║████╗ ██║██╔════╝'
echo -e '██║ ██║███████║██║ ██║███████║ ╚████╔╝ ██╔████╔██║██╔██╗ ██║█████╗ '
echo -e '██║ ██║██╔══██║╚██╗ ██╔╝██╔══██║ ╚██╔╝ ██║╚██╔╝██║██║╚██╗██║██╔══╝ '
echo -e '██████╔╝██║ ██║ ╚████╔╝ ██║ ██║ ██║ ██║ ╚═╝ ██║██║ ╚████║███████╗'
echo -e '╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝'
echo -e ' '
echo -e '\e[0m'
#!/bin/bash
apt update && apt upgrade -y
apt install htop git httpie jq tmux bc net-tools smartmontools -y
useradd -rs /bin/false monitor
cd /opt
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
tar xvfz node_exporter-*.*-amd64.tar.gz && cp node_exporter-*.*-amd64/node_exporter . && chown monitor:monitor node_exporter
tee /etc/systemd/system/node_exporter.service <<"EOF"
[Unit]
Block: 12976254 Hash: 0xea4473b0bc3c632978b3ff11c2fe7f2c792366e4020620397c2b5e5e65fac9d2 POI: 0x89013ae99623fd61fa41e5d5806c06bd328b7f0f611a91d4b698b80cb220af45
Block: 12976255 Hash: 0x43c3de1ba1e2e80aeeafaedaddc927074d2e2a59a3cd5c7b92e1f0ffdb4b8d80 POI: 0xbd5230ddbe10020db4d22dc576fc9a180c8014d1809779876ed7b9f5c1f0232b
Block: 12976256 Hash: 0x8168a4fee6ecd17a2daca793c67b78a904ee2a4fc7801289eca82d25f3a7cdf2 POI: 0xca6d92eec9711bd5ad31843894b3d2768c6f728f26b25010d5f9c41d29b4beec
Block: 12976257 Hash: 0xa078afc6d94f7184a07e6b1d814d9791cadad3a500b860ea184365f4a7fb3a11 POI: 0x89238208ebf4b87f591afb27f9002736148aff402d161fb57e5a866400d09af3
Block: 12976258 Hash: 0x8d2f03d1ed379f98d128be7e08f051ed81a15b65d059db0adc88e233c00982b4 POI: 0xd2e30d3263546663a2abe1cd5fdd07a3b3718c879f1fabe7450b4e7866f502d1
Block: 12976259 Hash: 0xc66ac402824d61011bcfa1828c0d58af1f50b2a30c52871ec442d08229f76bb6 POI: 0xcdcc4ed01c31907dbe1cc631159da4d2415cf1037f60f0fac6beec93f13d64d0
Block: 12976260 Hash: 0xfc04b838505ca8
#!/usr/bin/env python3
# apt-get -y install python3-pip
# pip3 install base58
import base58
import argparse
import sys
import requests
import json
{
"__inputs": [
{
"name": "DS_GRAPHQL_DATA SOURCE",
"label": "GraphQL Data Source",
"description": "",
"type": "datasource",
"pluginId": "fifemon-graphql-datasource",
"pluginName": "GraphQL Data Source"
},
# Consumes json summary file
# output call count per subgraph
summaries=""
day=2020115
day_summary=$(jq -s 'group_by(.subgraph) |
map({"subgraph":(.[0].subgraph), "calls":(reduce .[].calls as $calls (0; . + $calls)), "date":("'$day'") }) |
map([.subgraph, .calls, .date] | join(", ")) | join(" \r\n ")' < $1)
summaries+="${day_summary//\"} \r\n"
printf "${summaries//\"}" > subgraph_daily_summary.csv
# Requires argument tsv file: b32 id name allocation
import sys
import subprocess
with open(sys.argv[1], 'r') as f:
for line in f:
print(line)
b32, id, name, allocation = line.strip().split('\t')
#print(id, model)
# graph indexer rules never $id
cmd = ['graph', 'indexer', 'rules', 'never', id]
# Script for bulk costmodel provisioning.
# Require: tsv file (fields tab separated)
# File format: 4 fields: name, id, full path to costmodel, variable string
# How to use: python3 set-bulk-costmodel.py my-costmodels.tsv
import sys
import subprocess
with open(sys.argv[1], 'r') as f:
for line in f:
print(line)
name, id, model, variables = line.split('\t')