This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
const instance = axios.create({ | |
baseURL: "http://localhost:4000" | |
}) | |
export default instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
func words() -> Array<Substring> { | |
return self.split(separator: " ") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getType<T>(_ dataType: T) -> String { | |
return String(describing: type(of: dataType)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir test_dir && cd test_dir | |
cp test_dir/. && ls | |
echo "File directory created" | |
echo "Completed" | sed s/Completed/Done/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import graphene | |
import requests | |
class Address(graphene.ObjectType): | |
""" Type definition for Address """ | |
streetAddress = graphene.String() | |
city = graphene.String() | |
state = graphene.String() | |
zip = graphene.String() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { |
NewerOlder