Greenman999
Greenman999
Explore posts from servers
CCoder.com
Created by Greenman999 on 1/21/2025 in #help
Devcontainer starting is taking really long / multiple times building the Dockerfile?
Hi, I have created a template from the starter "Docker (Devcontainer)" one and just selected home assistant for testing purposes. Creating the workspace takes really long and from the logs it seems like its building the dockerfile multiple times? Is this intended?
17 replies
CCoder.com
Created by Greenman999 on 1/15/2025 in #help
Terminal Theme
Hi is there a way to change the terminal theme of workspaces?
7 replies
SSolidJS
Created by Greenman999 on 12/30/2024 in #support
Error Boundary does not catch errors of the resource
Hello, I have a resource created and access it inside a suspense inside an error boundary, but if the resource throws an error, e.g. no network, then the error boundary does not catch this and the suspense fallback gets displayed. Why?
<ErrorBoundary fallback={ErrorFallback}>
<Suspense
fallback={
<For each={Array(4).fill(0)}>
{(_, index) => (
<div class={index() == 0 ? "" : "mt-4"}>
<PetSkeleton></PetSkeleton>
</div>
)}
</For>
}
>
<For
each={
families()?.find(
(family) => family.id == selectedFamily()
)?.pets
}
>
<ErrorBoundary fallback={ErrorFallback}>
<Suspense
fallback={
<For each={Array(4).fill(0)}>
{(_, index) => (
<div class={index() == 0 ? "" : "mt-4"}>
<PetSkeleton></PetSkeleton>
</div>
)}
</For>
}
>
<For
each={
families()?.find(
(family) => family.id == selectedFamily()
)?.pets
}
>
const [families, { mutate: mutateFamilies }] = createResource(fetchFamilies);
const [families, { mutate: mutateFamilies }] = createResource(fetchFamilies);
export const fetchFamilies = async () => {
const response: Family[] = await sendApiRequest(
"/api/families",
"GET",
false
);
return response.sort((a, b) => a.name.localeCompare(b.name));
};
export const fetchFamilies = async () => {
const response: Family[] = await sendApiRequest(
"/api/families",
"GET",
false
);
return response.sort((a, b) => a.name.localeCompare(b.name));
};
32 replies
HHono
Created by Greenman999 on 10/23/2024 in #help
How to prevent Server Error if no req body?
Hi I have this code:
userRouter.patch("/self", async (c) => {
const reqUserId = c.get("authUser").user?.id;

if (reqUserId == null) {
throw new HTTPException(401);
}

const { name } = await c.req.json();

if (!name) {
throw new HTTPException(400, { message: "Please include a new name in body." });
}

return c.json({});
});
userRouter.patch("/self", async (c) => {
const reqUserId = c.get("authUser").user?.id;

if (reqUserId == null) {
throw new HTTPException(401);
}

const { name } = await c.req.json();

if (!name) {
throw new HTTPException(400, { message: "Please include a new name in body." });
}

return c.json({});
});
If no json is passed in the body i get this error: [ERROR] SyntaxError: Unexpected end of JSON input Is there anyway to replace this with my own error message? Like the one in my code ^ ?
5 replies
SSolidJS
Created by Greenman999 on 10/19/2024 in #support
custom css classes not applied somehow
Hi, i have this code:
<For each={alertsManager.getAlerts()}>
{(alert) => (
<div class={"flex alert alert-" + alert.type}>
<For each={alertsManager.getAlerts()}>
{(alert) => (
<div class={"flex alert alert-" + alert.type}>
alert.type is success and with daisyui and tailwindcss the div should have a green background color. However the div is colored like default just like alert-success wasnt there. If i manually add alert-success to the class prop it works. If I remove it after the concatinated version works somehow.. Can someone help me?
2 replies
SSolidJS
Created by Greenman999 on 10/19/2024 in #support
Display relative time as signal
Hi, I want to display the relative time of a date. I have this file:
const units: { unit: Intl.RelativeTimeFormatUnit; ms: number }[] = [
{ unit: "year", ms: 31536000000 },
{ unit: "month", ms: 2628000000 },
{ unit: "day", ms: 86400000 },
{ unit: "hour", ms: 3600000 },
{ unit: "minute", ms: 60000 },
{ unit: "second", ms: 1000 },
];
const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });

/**
* Get language-sensitive relative time message from Dates.
* @param relative - the relative dateTime, generally is in the past or future
* @param pivot - the dateTime of reference, generally is the current time
*/
export function relativeTimeFromDates(relative: Date | null, pivot: Date = new Date()): string {
if (!relative) return "";
const elapsed = relative.getTime() - pivot.getTime();
return relativeTimeFromElapsed(elapsed);
}

/**
* Get language-sensitive relative time message from elapsed time.
* @param elapsed - the elapsed time in milliseconds
*/
export function relativeTimeFromElapsed(elapsed: number): string {
for (const { unit, ms } of units) {
if (Math.abs(elapsed) >= ms || unit === "second") {
return rtf.format(Math.round(elapsed / ms), unit);
}
}
return "";
}
const units: { unit: Intl.RelativeTimeFormatUnit; ms: number }[] = [
{ unit: "year", ms: 31536000000 },
{ unit: "month", ms: 2628000000 },
{ unit: "day", ms: 86400000 },
{ unit: "hour", ms: 3600000 },
{ unit: "minute", ms: 60000 },
{ unit: "second", ms: 1000 },
];
const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });

/**
* Get language-sensitive relative time message from Dates.
* @param relative - the relative dateTime, generally is in the past or future
* @param pivot - the dateTime of reference, generally is the current time
*/
export function relativeTimeFromDates(relative: Date | null, pivot: Date = new Date()): string {
if (!relative) return "";
const elapsed = relative.getTime() - pivot.getTime();
return relativeTimeFromElapsed(elapsed);
}

/**
* Get language-sensitive relative time message from elapsed time.
* @param elapsed - the elapsed time in milliseconds
*/
export function relativeTimeFromElapsed(elapsed: number): string {
for (const { unit, ms } of units) {
if (Math.abs(elapsed) >= ms || unit === "second") {
return rtf.format(Math.round(elapsed / ms), unit);
}
}
return "";
}
but if i run the relativeTimeFromDates(new Date(2024, 9, 19, 14, 30)) inside of the html part it does not update when a minute more has passed and the output of the function should change. Solid does not react to this. How can i fix this? Do i need to wrap the function in something? Thanks!
7 replies
SSolidJS
Created by Greenman999 on 8/16/2024 in #support
Redirect on Client
Hi how can i redirect clientside? redirect("/home") doesnt work
3 replies
SSolidJS
Created by Greenman999 on 6/22/2024 in #support
this is undefined
No description
4 replies
DTDrizzle Team
Created by Greenman999 on 6/21/2024 in #help
`Argument of type 'SQL<unknown>' is not assignable to parameter of type 'IndexColumn'.`
Hello I am creating a schema like this guide (https://orm.drizzle.team/learn/guides/unique-case-insensitive-email) but i get the error in the title on .on(lower(table.email)). This is my code:
import { SQL, sql } from "drizzle-orm";
import {
AnyPgColumn,
pgTable,
timestamp,
uniqueIndex,
uuid,
varchar,
} from "drizzle-orm/pg-core";

export const users = pgTable(
"users",
{
id: uuid("id").defaultRandom().notNull().primaryKey(),
email: varchar("email", { length: 256 }).notNull(),
username: varchar("username", { length: 16 }).notNull(),
displayname: varchar("displayname", { length: 32 }).notNull(),
created_at: timestamp("created_at", { mode: "date" }).notNull(),
},
(table) => ({
emailUniqueIndex: uniqueIndex("emailUniqueIndex").on(lower(table.email)),
usernameUniqueIndex: uniqueIndex("usernameUniqueIndex").on(lower(table.username))
}),
);

export function lower(email: AnyPgColumn): SQL {
return sql`lower(${email})`;
}
import { SQL, sql } from "drizzle-orm";
import {
AnyPgColumn,
pgTable,
timestamp,
uniqueIndex,
uuid,
varchar,
} from "drizzle-orm/pg-core";

export const users = pgTable(
"users",
{
id: uuid("id").defaultRandom().notNull().primaryKey(),
email: varchar("email", { length: 256 }).notNull(),
username: varchar("username", { length: 16 }).notNull(),
displayname: varchar("displayname", { length: 32 }).notNull(),
created_at: timestamp("created_at", { mode: "date" }).notNull(),
},
(table) => ({
emailUniqueIndex: uniqueIndex("emailUniqueIndex").on(lower(table.email)),
usernameUniqueIndex: uniqueIndex("usernameUniqueIndex").on(lower(table.username))
}),
);

export function lower(email: AnyPgColumn): SQL {
return sql`lower(${email})`;
}
2 replies