Skip to content

Instantly share code, notes, and snippets.

View jxxcarlson's full-sized avatar

James Carlson jxxcarlson

View GitHub Profile
@jxxcarlson
jxxcarlson / openai-stuff.md
Created May 11, 2023 14:45
The code needed in an Elm + Lamdera app to use OpenAI's API to generate images

Intro

The code below is the core functionality used in the app gpt-lab.lamdera.app. It is based on choonkeat/elm-openai, which I highly recommend. The other reference is the api-reference/images part of OpenAI's docs.

— jxxcarlson

@jxxcarlson
jxxcarlson / output.txt
Created March 24, 2021 20:46
Testing elm-embed
➜ tests git:(master) ✗ python3 characterization-test.py
Could not find the elm-embed binary in PATH.
Specify the location of elm-embed like this:
characterization-test.py /path/to/elm-embed
Traceback (most recent call last):
File "/Users/carlson/dev/elm/experimental/elm-embed/tests/characterization-test.py", line 125, in <module>
main()
File "/Users/carlson/dev/elm/experimental/elm-embed/tests/characterization-test.py", line 51, in main
{-
The idea behind module Db is to imitate part of the functionality of a
relation database which may have a number of indexes for fast searches.
In this example, the fundamental data structure is
type alias Db =
{ data : Dict Uuid Document
, authorDict : MultiBiDict Author Uuid
, titleDict : BiDict Title Uuid
==> cmake /private/tmp/llvm-4.0-20200929-65376-ty8vvi/llvm-4.0.1.src -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/llvm-4.0/4.0.1/lib/llvm-4.0 -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_OPTIM
==> cmake --build .
Last 15 lines from /Users/jxxcarlson/Library/Logs/Homebrew/llvm-4.0/02.cmake:
cd /tmp/llvm-4.0-20200929-65376-11hv0ii/lib/CodeGen && /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++ -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/tmp/llvm-4.0-20200929-65376-11hv0ii/lib/CodeGen -I/tmp/llvm-4.0-20200929-65376-ty8vvi/llvm-4.0.1.src/lib/CodeGen -I/tmp/llvm-4.0-20200929-65376-11hv0ii/include -I/tmp/llvm-4.0-20200929-65376-ty8vvi/llvm-4.0.1.src/include -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Werror=date-time -std=c++11 -isysroot /Library/Developer/CommandLineTools/S
# Elm Warrior: Notes
## Overall comments
The Dev.to article is very clear. Just a few very minor suggestions/comments below.
I did get some errors running `npm` (what's new?). The second error was
especially misleading/disconcerting, but it turns out that if you ignore it,
all is good. I was able to play the game.
module Parse exposing (AST(..), toAST)
{-
Parse a string of Lisp text, return Just AST if it is legal, Nothing if not.
-}
import Parser exposing (..)
import ParserHelpers exposing (..)
@jxxcarlson
jxxcarlson / gist:2af50265f66d822eb933d323140be5ec
Created June 1, 2020 16:31
Deno - CORS problem with this function
export const addDocument = async ({
request,
response,
}: {
request: any
response: any
}) => {
response.headers.set('Access-Control-Allow-Origin', '*')
console.log("processing POST request")
@jxxcarlson
jxxcarlson / gist:024724704390623efa7d93daa736b7bd
Created May 15, 2020 06:53
Lamdera error message on deploy of chattest
emote: It appears you're all set to deploy v32 of 'chattest'.
remote:
remote: There are no Evergreen type changes for this version.
remote: [============================================ ] - 16 / 18-- TYPE MISMATCH --------------------------------- src/Evergreen/Migrate/V31.elm
remote:
remote: Something is off with the body of the `frontendModel` definition:
remote:
remote: 23|> ModelMigrated
remote: 24|> ( { key = old.key
remote: 25|> , userId = ""
@jxxcarlson
jxxcarlson / gist:b0fa7ac257a7005332636eea0f36aa3e
Last active April 27, 2020 07:13
Issue depolying svgChat
Made the changed indicated below
newAttributes : Random.Seed -> Float -> Float -> ClientStatus -> (ClientAttributes, Random.Seed)
newAttributes seed maxX maxY clientStatus =
let
(handle, seed1) = map String.toUpper (word 3 seed)
(x, seed2) = Random.step (Random.float 0 maxX) seed1
(y, seed3) = Random.step (Random.float 0 maxY) seed2
(k, seed4) = Random.step (Random.int 0 11) seed3
(color, fontColor) = getColors k
@jxxcarlson
jxxcarlson / server.py
Last active March 29, 2020 10:17
Get hardware generated random number via HTTP. Uses /dev/random
#!/usr/bin/env python3
"""
I have hacked the code at
https://gist.github.com/bradmontgomery/2219997#file-dummy-web-server-py
to make a server that responds to get requests by returning
a random integer generated using the /dev/random hardware
random number generator. Assuming that this file is named
"server.py", just do