This file contains 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 * as faunadb from "faunadb"; | |
export const q = faunadb.query as any; | |
export const faunaClient = new faunadb.Client({ | |
domain: process.env.FAUNA_DOMAIN, | |
secret: process.env.FAUNA_SECRET as string, | |
}); |
This file contains 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 { createYoga, createSchema } from 'graphql-yoga' | |
import { faunaClient, q } from './db' | |
let stream: any = null; | |
const schema = createSchema({ | |
typeDefs: /* GraphQL */ ` | |
type Post { | |
id: ID! | |
title: String! |
This file contains 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
export default class Client { | |
constructor(key) { | |
this.key = key; | |
this.url = `https://us-dev.db.faunadb.net/query/1`; | |
} | |
_getKey() { | |
return this.key; | |
} |
This file has been truncated, but you can view the full file.
This file contains 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
-- | |
-- PostgreSQL database dump | |
-- | |
-- Dumped from database version 11.2 | |
-- Dumped by pg_dump version 12.1 | |
SET statement_timeout = 0; | |
SET lock_timeout = 0; | |
SET idle_in_transaction_session_timeout = 0; |
This file has been truncated, but you can view the full file.
This file contains 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
[{"_id":{"$oid":"57506d62f57802807471dcd1"},"grades":[2,6,10,9,14],"name":"Morris Park Bake Shop","contact":{"phone":"365-555-0134","email":"morrisparkbakeshop@example.org","location":[-73.856077,40.848447]},"stars":4,"categories":["Italian","Polynesian","Coffee"]}, | |
{"_id":{"$oid":"57506d62f57802807471dcd2"},"grades":[2,11,12,12],"name":"Dj Reynolds Pub And Restaurant","contact":{"phone":"492-555-0119","email":"djreynoldspubandrestaurant@example.org","location":[-73.98513559999999,40.7676919]},"stars":2,"categories":["Pancakes","Californian","African"]}, | |
{"_id":{"$oid":"57506d62f57802807471dcd3"},"grades":[8,23,12,12],"name":"Wendy'S","contact":{"phone":"152-555-0146","email":"wendy's@example.net","location":[-73.961704,40.662942]},"stars":4,"categories":["Fruits","Greek","Chinese"]}, | |
{"_id":{"$oid":"57506d62f57802807471dcd4"},"grades":[5,7,12,12],"name":"Riviera Caterer","contact":{"phone":"887-555-0124","email":"rivieracaterer@example.com","location":[-73.98241999999999,40.579505]},"stars":5,"categories":[" |
This file has been truncated, but you can view the full file.
This file contains 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
{"_id":{"$oid":"57506d62f57802807471dcd1"},"grades":[2,6,10,9,14],"name":"Morris Park Bake Shop","contact":{"phone":"365-555-0134","email":"morrisparkbakeshop@example.org","location":[-73.856077,40.848447]},"stars":4,"categories":["Italian","Polynesian","Coffee"]} | |
{"_id":{"$oid":"57506d62f57802807471dcd2"},"grades":[2,11,12,12],"name":"Dj Reynolds Pub And Restaurant","contact":{"phone":"492-555-0119","email":"djreynoldspubandrestaurant@example.org","location":[-73.98513559999999,40.7676919]},"stars":2,"categories":["Pancakes","Californian","African"]} | |
{"_id":{"$oid":"57506d62f57802807471dcd3"},"grades":[8,23,12,12],"name":"Wendy'S","contact":{"phone":"152-555-0146","email":"wendy's@example.net","location":[-73.961704,40.662942]},"stars":4,"categories":["Fruits","Greek","Chinese"]} | |
{"_id":{"$oid":"57506d62f57802807471dcd4"},"grades":[5,7,12,12],"name":"Riviera Caterer","contact":{"phone":"887-555-0124","email":"rivieracaterer@example.com","location":[-73.98241999999999,40.579505]},"stars":5,"categories":["Japa |
This file contains 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
const doubleEachElement = (arr) => { | |
return arr.map(element => element == 1 ? 2 : element * 2); | |
} | |
const squareEachElement = (arr) => { | |
return arr.map(element => element * element); | |
} | |
const printOriginalAndModify = (arr, fn) => { | |
console.log('☎️ original', arr); |
This file contains 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
class Observable { | |
constructor() { | |
this.fnArray = []; | |
} | |
subscribe() {} | |
emit() {} | |
} |
This file contains 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
// worker.js | |
const { Worker, workerData, isMainThread, parentPort } = require('worker_threads'); | |
if (isMainThread) { | |
const worker1 = new Worker(__filename, { workerData: 'Worker Data 1'}); | |
worker1.once('message', message => console.log(message)); | |
const worker2 = new Worker(__filename, { workerData: 'Worker Data 2' }); | |
worker2.once('message', message => console.log(message)); | |
} else { | |
parentPort.postMessage('I am ' + workerData); |
This file contains 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
// server.js | |
const { fork } = require('child_process'); | |
app.get('/endpoint', (request, response) => { | |
// fork another process | |
const process_ml_algo = fork('./process_data.js'); | |
const data = request.body.data; | |
// send send the data to forked process | |
process_ml_algo.send({ data }); | |
// listen to forked process |
NewerOlder