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 openai from '/path/to/openai'; | |
const MAX_RETRIES_IN_CASE_UNKNOWN_ERROR = 5; | |
export default async function promptChatGPT( | |
data, | |
retriesLeft = MAX_RETRIES_IN_CASE_UNKNOWN_ERROR | |
) { | |
const completionRequest = buildCompletionRequest(data); // <-- insert your own logic |
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
function all(arrayOfPromises) { | |
return new Promise(function (resolve, reject) { | |
// initialize an array of results with length of the given array of promises | |
const results = Array.from(Array(arrayOfPromises.length)); | |
// since all promises are started in parallel (quickly one after the other) | |
// we are using a counter to keep track of when they all resolve because | |
// each promise can take a different amount of time to resolve | |
let resultsLeft = arrayOfPromises.length; |
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
// ---------------------------------------------- | |
// fake DB stuff | |
// ---------------------------------------------- | |
const logger = console; | |
let COUNTER_UNTIL_DB_IS_A_GOOD_BOY = 3; | |
const fakeDb = { | |
isConnected: false, |
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
) | |
type Tree struct { | |
Left *Tree | |
Value int |
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
{ | |
"type": "PLAYGROUND", | |
"text": "`PLAYGROUND`: Run a query to generate the titles of each movie.", | |
"setup_sql": "CREATE TABLE movies (Id INTEGER, Title TEXT(19), Director TEXT(14), Year INTEGER, Length_minutes INTEGER);;INSERT INTO movies (Id, Title, Director, Year, Length_minutes)VALUES (1, 'Toy Story', 'John Lasseter', 1995, 81);INSERT INTO movies (Id, Title, Director, Year, Length_minutes)VALUES (2, 'A Bug''s Life', 'John Lasseter', 1998, 95);INSERT INTO movies (Id, Title, Director, Year, Length_minutes)VALUES (3, 'Toy Story 2', 'John Lasseter', 1999, 93);INSERT INTO movies (Id, Title, Director, Year, Length_minutes)VALUES (4, 'Monsters, Inc.', 'Pete Docter', 2001, 92);INSERT INTO movies (Id, Title, Director, Year, Length_minutes)VALUES (5, 'Finding Nemo', 'Andrew Stanton', 2003, 107);INSERT INTO movies (Id, Title, Director, Year, Length_minutes)VALUES (6, 'The Incredibles', 'Brad Bird', 2004, 116);INSERT INTO movies (Id, Title, Director, Year, Length_minutes |
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 React from "react"; | |
import ReactDOM from "react-dom"; | |
class Async extends React.Component { | |
state = { isLoading: false }; | |
componentDidCatch(x) { | |
if (x instanceof Promise) { | |
this.setState({ isLoading: true }); | |
x.then(() => { |
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
let cache = new Map(); | |
let pending = new Map(); | |
function fetchTextSync(url) { | |
if (cache.has(url)) { | |
return cache.get(url); | |
} | |
if (pending.has(url)) { | |
throw pending.get(url); | |
} |
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
jobs: | |
install: | |
working_directory: ~/enki-project | |
docker: | |
- image: circleci/node:8.10.0 | |
steps: | |
- checkout | |
- restore_cache: | |
keys: | |
- v1-dependencies-{{ checksum "package.json" }} |
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
version: 2 | |
jobs: | |
build: | |
working_directory: ~/enki-project | |
machine: true | |
environment: | |
- ENKI: 'example' | |
steps: | |
- checkout |
NewerOlder