Skip to content

Instantly share code, notes, and snippets.

View Descartess's full-sized avatar

Paul Nyondo Descartess

  • Kampala
View GitHub Profile
import axios from 'axios'
const instance = axios.create({
baseURL: "http://localhost:4000"
})
export default instance
extension String {
func words() -> Array<Substring> {
return self.split(separator: " ")
}
}
func getType<T>(_ dataType: T) -> String {
return String(describing: type(of: dataType))
}
mkdir test_dir && cd test_dir
cp test_dir/. && ls
echo "File directory created"
echo "Completed" | sed s/Completed/Done/
func processResults(request: VNRequest, error: Error?) {
guard let results = request.results as? [VNClassificationObservation] else {
fatalError("Could not get results from ML Vision requests")
}
var bestPrediction = ""
var bestConfidence: VNConfidence = 0
for classification in results {
if classification.confidence > bestConfidence {
bestConfidence = classification.confidence
bestPrediction = classification.identifier
func numDescription(start: Int!, finish: Int!) {
for num in start...finish {
let remainder = num % 2
switch remainder {
case 0:
print("\(num) is an even number")
default:
print("\(num) is an odd number")
}
from flask_graphql import GraphQLView
from flask import Flask
from data.schema import schema
app = Flask(__name__)
app.debug = True
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
if __name__ =="__main__":
import graphene
import requests
class Address(graphene.ObjectType):
""" Type definition for Address """
streetAddress = graphene.String()
city = graphene.String()
state = graphene.String()
zip = graphene.String()
import express from 'express';
import { makeExecutableSchema } from 'graphql-tools';
import bodyParser from 'body-parser';
import { graphiqlExpress, graphqlExpress } from 'graphql-server-express';
import Schema from './data/schema';
import resolvers from './data/resolvers';
const app = express();
const executableSchema = makeExecutableSchema({
import axios from 'axios';
const resolvers = {
Query: {
users: () => axios.get('http://localhost:3000/users').then(resp => resp.data),
teams: () => axios.get('http://localhost:3000/teams').then(resp => resp.data),
team: (_, { id }) => axios.get(`http://localhost:3000/teams/${id}`).then(resp => resp.data),
user: (_, { id }) => axios.get(`http://localhost:3000/users/${id}`).then(resp => resp.data),
},
User: {