Avatar

@horatiothomas

2 likes3 public vals
Joined March 24, 2024
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
export default async function handler(request: Request) {
if (request.method === "GET") {
return new Response(
`<!DOCTYPE html>
<html>
<head>
<title>Dream Interpreter</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.0.3/dist/tailwind.min.css" rel="stylesheet">
<script>
function handleSubmit(event) {
event.preventDefault();
var dreamInput = document.getElementById('dreamInput');
var dream = dreamInput.value;
var interpretationDiv = document.getElementById('interpretation');
var loadingDiv = document.getElementById('loading');
interpretationDiv.textContent = '';
loadingDiv.style.display = 'block';
fetch(window.location.href, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ dream }),
})
.then(response => response.json())
.then(data => {
interpretationDiv.textContent = data.dream;
})
.catch(error => {
console.error('Error:', error);
})
.finally(() => {
loadingDiv.style.display = 'none';
});
}
</script>
<style>
body {
background-color: #1a1a2e;
color: #e0e1dd;
}
.bg-purple-500 {
background-color: #6a4c93;
}
#loading {
display: none;
}
input{
color: black;
}
</style>
</head>
<body class="p-4">
<h1>Dream Interpreter</h1>
<form onsubmit="handleSubmit(event)">
<input id="dreamInput" type="text" placeholder="Enter your dream" class="border-2 border-gray-200 p-2 rounded-md w-full" />
<button type="submit" class="bg-purple-500 text-white p-2 rounded-md mt-2">Interpret Dream</button>
</form>
<div id="loading" class="mt-4">Loading...</div>
<div id="interpretation" class="mt-4"></div>
</body>
</html>`,
{
headers: {
"Content-Type": "text/html",
"Cache-Control": "public, max-age=10, stale-while-revalidate=0",
},
},
);
} else if (request.method === "POST") {
try {
const body = await request.json();
const dream = body.dream;
// Generate a random UUID
const randomUuid = () => {
let uuid = "";
for (let i = 0; i < 32; i++) {
const random = Math.random() * 16 | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) {
uuid += "-";
}
uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16);
}
return uuid;
};
// Create the request payload
const payload = {
dream,
lat: null,
long: null,
};
// Send the POST request
const response = await fetch("https://dreaminterpreteraibackend.com/dream", {
method: "POST",
headers: {

interpret your dream

Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
export default async function(interval) {
// Sample phrases and words that are likely to appear in dream descriptions
const introPhrases = [
"I was flying over",
"I found myself in a",
"suddenly appeared",
"I was chased by",
"I met a mysterious",
"I was lost in a",
"I discovered a hidden",
"I was trapped in a",
"I transformed into a",
"I was surrounded by",
"I encountered a",
"I was given a",
"I was searching for",
"I was haunted by",
"I was attending a",
"I was exploring a",
"I was climbing a",
"I was falling into",
"I was running away from",
"I was walking through",
];
const objects = ["castle", "forest", "stranger", "monster", "friend", "cave", "party", "mountain", "abyss", "garden"];
const actions = [
"and found a treasure",
"but got lost",
"and met a talking animal",
"but it was a dream within a dream",
"and discovered a new world",
"but realized I could not move",
"and escaped from danger",
"but it started to vanish",
"and found a secret passage",
"but then I woke up",
];
// Generate a random dream-like sentence
let randomSentence = introPhrases[Math.floor(Math.random() * introPhrases.length)] + " "
+ objects[Math.floor(Math.random() * objects.length)] + " "
+ actions[Math.floor(Math.random() * actions.length)];
// If the sentence is shorter than 250 characters, repeat the process to extend it
while (randomSentence.length < 250) {
randomSentence += ", " + introPhrases[Math.floor(Math.random() * introPhrases.length)] + " "
+ objects[Math.floor(Math.random() * objects.length)] + " "
+ actions[Math.floor(Math.random() * actions.length)];
}
// Generate a random UUID
const randomUuid = () => {
let uuid = "";
for (let i = 0; i < 32; i++) {
const random = Math.random() * 16 | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) {
uuid += "-";
}
uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16);
}
return uuid;
};
console.log(randomSentence.trim());
// Create the request payload
const payload = {
dream: randomSentence.trim(),
lat: null,
long: null,
};
// Send the POST request
const response = await fetch("https://dreaminterpreteraibackend.com/dream", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.9",
"Country": "US",
"Language": "en",
"Origin": "https://www.dreaminterpreter.ai",
"Referer": "https://www.dreaminterpreter.ai/",
"Sec-Ch-Ua": "\"Google Chrome\";v=\"123\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"macOS\"",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
"Uid": randomUuid(),
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
},
body: JSON.stringify(payload),
});
// Handle the response
const data = await response.json();

stevekrouse.com - my personal website

This val hosts my personal website. The view data is stored in Val Town SQLite - @std/sqlite.

It used to live on Github Pages, which is why I proxy over requests to certain blog posts over to the Github Pages site still.

Todos

  • Speed up page load by loading sqlite data later like in @healeycodes/steve_web
  • Store more (legally storable) analytics data, and maybe make a sparkline!
  • Add some sort of way to contact me
  • Move over all my blog posts from Github Pages (maybe into @std/blob as a CMS?)
Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsxImportSource https://esm.sh/react */
import { email } from "https://esm.town/v/std/email?v=11";
import { sqlite } from "https://esm.town/v/std/sqlite?v=5";
import { ReloadScriptReactElement } from "https://esm.town/v/stevekrouse/ReloadScript";
import tailwindURL from "https://esm.town/v/stevekrouse/tailwindURL";
import { renderToString } from "npm:react-dom/server";
const linkClass = "text-blue-500 hover:underline";
const Link = (
{ children, href }: {
children?: React.ReactNode;
href: string;
},
) => <a className={linkClass} href={href}>{children}</a>;
const dateClass = "text-xs text-gray-400 font-mono mr-1 hidden sm:inline-block";
async function getHits() {
const [, , { rows: [[allHits]] }, { rows: [[todayHits]] }] = await sqlite.batch([
"CREATE TABLE IF NOT EXISTS stevekrouse_com_hits (timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)",
"INSERT INTO stevekrouse_com_hits DEFAULT VALUES",
"SELECT COUNT(*) FROM stevekrouse_com_hits where timestamp > datetime('now', '-28 day')",
"SELECT COUNT(*) from stevekrouse_com_hits where timestamp > datetime('now', '-1 day')",
]);
if (allHits % 100 === 0) email({ subject: `You got ${todayHits} hits today! (${allHits} total)` });
return { allHits, todayHits };
}
export default async (request: Request) => {
const url = new URL(request.url);
console.log(url);
if (url.pathname === "/favicon.ico") return new Response(null, { status: 404 });
if (url.pathname !== "/")
return fetch(
`https://stevekrouse.github.io/${url.pathname}${url.search}`,
request as any as RequestInit,
);
const { allHits, todayHits } = await getHits();
return new Response(
renderToString(
<html>
<head>
<title>Steve Krouse</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<script src={tailwindURL} />
{url.searchParams.get("dev")
? <ReloadScriptReactElement vals={[{ valName: "dot_com", userHandle: "stevekrouse" }]} />
: null}
</head>
<body>
<div className="max-w-3xl p-10 space-y-4 mx-auto">
<h1 className="text-orange-600 text-2xl font-medium">Steve Krouse</h1>
<div>
👋 Hi, I'm Steve. I live in Prospect Heights, Brooklyn.
</div>
<div>
I build <Link href="https://val.town">Val Town</Link>, a social website to code in the cloud.
</div>
<div>
This site was{" "}
<Link href="https://www.val.town/v/stevekrouse/dot_com">built in Val Town</Link>. It was viewed{" "}
{todayHits} times today, and {allHits} times this month.
</div>
<div>
<h2 className="text-xl mb-1">Projects</h2>
<ul>
<li className="pb-2 sm:pb-1">
<span className={dateClass}>2022 Jul -</span>
<Link href="https://val.town">Val Town</Link>
</li>
<li className="pb-2 sm:pb-1">
<span className={dateClass}>2022 Sep -</span>
<Link href="https://dateme.directory">Date Me Directory</Link>
</li>
<li className="pb-2 sm:pb-1">
<span className={dateClass}>2022 Jan -</span>
<Link href="https://twitter.com/stevekrouse/status/1520162279899078657">Zaplib</Link>
</li>
<li className="pb-2 sm:pb-1">
<span className={dateClass}>2021 Mar -</span>
<Link href="http://updates.compose.run">Compose</Link>
</li>
<li className="pb-2 sm:pb-1">
<span className={dateClass}>2017 Jul -</span>
<Link href="https://futureofcoding.org/">Future of Coding</Link>
</li>
<li className="pb-2 sm:pb-1">
<span className={dateClass}>2016 May -</span>
<Link href="https://github.com/stevekrouse/woofjs">WoofJS</Link>
</li>
<li className="pb-2 sm:pb-1">
<span className={dateClass}>2015 Sep -</span>
<Link href="http://coding.space">The Coding Space Curriculum</Link>
</li>
<li className="pb-2 sm:pb-1">
<span className={dateClass}>2015 Jul -</span>
<Link href="http://thecodingspace.com">The Coding Space</Link>
</li>
<li className="pb-2 sm:pb-1">
<span className={dateClass}>2014 Jan -</span>Software Engineer @{" "}
<Link href="https://looker.com/">Looker</Link>
Next