Skip to content

Instantly share code, notes, and snippets.

View BransonGitomeh's full-sized avatar
🏠
Working from home

_bran BransonGitomeh

🏠
Working from home
View GitHub Profile
@BransonGitomeh
BransonGitomeh / main.js
Last active October 12, 2017 21:13
Express router, graphql, GCP cloud function
import express from 'express';
import graphqlHTTP from 'express-graphql';
import { buildSchema } from 'graphql';
const router = express.Router();
const schema = buildSchema(`
type Query {
hello: String
}`);
mod africas_talking {
#[derive(Debug)]
pub struct Sms {
sent_time: &'static str,
}
#[derive(Debug)]
pub struct Message {
pub to: &'static str,
pub content: &'static str,
FROM node
RUN mkdir -p /usr/src/app
COPY index.js /usr/src/app
EXPOSE 8080
CMD [ "node", "/usr/src/app/index" ]
@BransonGitomeh
BransonGitomeh / client.js
Created January 28, 2018 07:12
seneca microservices and clients talking to each other in a mesh fassion,
var seneca = require('seneca')
seneca()
// send matching actions out over the network
.client({
host: "localhost",
type: 'tcp',
port: 10000,
pin: 'color:blue'
})
sudo groupadd docker
sudo usermod -aG docker $USER
docker build -t friendlyhello . ➜ build changes
docker run -p 4000:8080 friendlyhello ➜ run image in container to see changes
docker tag friendlyhello branie/get-started:part2 ➜ tag the image on docker.com
docker push branie/get-started:part2 ➜ push the image to docker.com
docker stack deploy -c docker-compose.yml getstartedlab ➜ start the swarm of containers that are load balanced
docker service ls ➜ view service task
docker service ps #service_name ➜ view containers inside a service
listening on 3210
calling hemera with { traceId: '0f616dd8a5077b9e' }
[2018-02-22T16:11:51.209Z] DEBUG (hemera-bran-pc-e09d40077e17487bbd2dd6905e6e95a8/11868 on bran-pc): sendClientSend
plugin: "hemera-zipkin"
traceData: {
"traceId": "0f616dd8a5077b9e",
"spanId": "98a8fb154eb44934b5a7bcbe461e8a63",
"sampled": true
}
meta: {
parity --jsonrpc-interface all --ui-interface all --ui-no-validation --dapps-hosts all --chain kovan --ws-interface all --unsafe-expose & disown
func (r *Router) convertToPatternSet(p interface{}) *PatternSet {
fields := structs.Fields(p)
ps := &PatternSet{}
ps.Fields = make(PatternFields)
ps.Pattern = p
ps.Weight = 0
for _, field := range fields {
if !strings.HasSuffix(field.Name(), "_") && !field.IsZero() {
const express = require('express');
const graphqlHTTP = require('express-graphql');
const { MongoClient } = require('mongodb');
const {
graphql,
GraphQLSchema,
GraphQLObjectType,
GraphQLString
} = require('graphql');
const request = require('request-promise')
const host = 'https://beta.braiven.io'
const base = 'ETH'
const alt = 'BVN'
const log = (json) => console.log(JSON.stringify(json, null, "\t"))
const login = async () => {