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
// ---------------------------------------------- | |
// 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
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
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
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
lint: | |
steps: | |
- checkout | |
- attach_workspace: | |
at: ~/my-workspace-path | |
- run: | |
name: Lint | |
# this will work because above we attach to the same workspace | |
# into which we previously persisted `node_modules` | |
command: ~/my-workspace-path/node_modules/.bin/eslint |
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
async function workflow() { | |
const workspace = await install(); | |
await Promise.all([build(workspace), lint(workspace)]); | |
if (isDeployBranch) { | |
await deploy(workspace); | |
} | |
} |
NewerOlder