Skip to content

Instantly share code, notes, and snippets.

View MichelDiz's full-sized avatar
🎼
If I die before I wake, pray the lord my soul to take.

Michel Diz MichelDiz

🎼
If I die before I wake, pray the lord my soul to take.
View GitHub Profile
import pydgraph
import json
def do_query(query=None, mutation=None, cond=None):
client_stub = pydgraph.DgraphClientStub("localhost:9080")
client = pydgraph.DgraphClient(client_stub)
txn = client.txn()
try:
if mutation:
@MichelDiz
MichelDiz / git-extract-file.markdown
Created May 20, 2020 17:41 — forked from ssp/git-extract-file.markdown
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: traefik
namespace: kube-system
spec:
chart: traefik
repo: https://nanosapp.github.io/chart-releases/stable
targetNamespace: kube-system
set:
apiVersion: v1
kind: Namespace
metadata:
name: nginx-ingress
---
apiVersion: v1
kind: Secret
metadata:
name: default-server-secret
namespace: nginx-ingress
{
"__inputs": [
{
"name": "DS_DGRAPH",
"label": "localhost",
"description": "Datasource with Dgraph metrics",
"type": "datasource",
"pluginId": "Prometheus",
"pluginname": "Prometheus"
}
@MichelDiz
MichelDiz / README.md
Last active November 26, 2022 23:19 — forked from danielmai/README.md
Dgraph + Nginx Load Balancing

First thing

One thing that I have to mention is that this Gist is a personal test env. Some things can be configured in a way that you don't want it to be.

Add the host information in the host file to your system (or do some DNS config)

Go to http://grafana_http:3000/ and import the grafana_dgraph.json

You have HTTP and GRPC endpoints.

type Team {
name: string
}
type Player {
name: string
Seasons: [uid]
}
type Season {
// To parse this JSON data, do
//
// final stateResponse = stateResponseFromJson(jsonString);
import 'dart:convert';
StateResponse stateResponseFromJson(String str) => StateResponse.fromJson(json.decode(str));
String stateResponseToJson(StateResponse data) => json.encode(data.toJson());
upsert {
query {
getVals(func: has(products)) {
productsUid as uid
products @filter(eq(productId, 19610626)) {
productUid as uid
options @filter(eq(optionId, 32661491)) {
optionUid as uid
}
}
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/dgraph-io/dgo/v2"
"github.com/dgraph-io/dgo/v2/protos/api"