Skip to content

Instantly share code, notes, and snippets.

View nestarz's full-sized avatar
🏠
Working from home

Elias Rhouzlane nestarz

🏠
Working from home
View GitHub Profile
@nestarz
nestarz / sibyl_monitoring.js
Created December 5, 2023 17:47
sibyl_monitoring.js
const appName = "[Sibyl Monitoring System]";
const endpointRaw = new URL(import.meta.url).searchParams.get("endpoint");
const endpoint = endpointRaw ? decodeURIComponent(endpointRaw) : null;
const isBrowser = typeof window !== "undefined";
const isLocal =
!isBrowser ||
["localhost", "127.0.0.1", "[::1]"].includes(location.hostname) ||
location.hostname.includes("192.");
const isRobot = /bot|googlebot|crawler|spider|robot|crawling/i.test(
isBrowser ? navigator.userAgent : ""
import { MeshTransmissionMaterial } from "@react-three/drei";
import { types } from "@theatre/core";
import { useCurrentSheet } from "@theatre/r3f";
import { useEffect, useRef, useState } from "react";
const EditableMeshTransmissionMaterial: typeof MeshTransmissionMaterial & {
theatreKey: string;
} = ({ theatreKey, ...props }) => {
const ref = useRef<JSX.IntrinsicElements["meshTransmissionMaterial"]>(null!);
const sheet = useCurrentSheet();
@nestarz
nestarz / server.ts
Last active October 27, 2023 07:49
/// <reference lib="deno.unstable" />
import { denoPlugins } from "https://deno.land/x/esbuild_deno_loader@0.8.2/mod.ts";
import * as esbuild from "https://deno.land/x/esbuild@v0.19.4/wasm.js";
import {
collectAndCleanScripts,
getHashSync,
scripted,
storeFunctionExecution,
} from "https://deno.land/x/scripted@0.0.3/mod.ts";
@nestarz
nestarz / events.ts
Created September 15, 2023 14:43
Events
export const CLICK_PLAY_VIDEO = "click_play_video";
export const CLICK_POSTER = "click_poster";
export const CLICK_GALLERY_IMAGE = "click_gallery_image";
export const CLICK_NAV_INFO = "click_nav_info";
export const CLICK_NAV_SHOWTIMES = "click_nav_showtimes";
export const CLICK_NAV_OTHER = "click_nav_other";
export const CLICK_QUIZ_ANSWER = "click_quiz_answer";
export const CLICK_SHOWTIME = "click_showtime";
export const CLICK_SHOWTIME_BOOK = "click_showtime_book";
export const CLICK_SHOWTIME_PHONE = "click_showtime_phone";
export default () => <div>OK</div>;
@nestarz
nestarz / islands.ts
Last active May 22, 2023 10:58
rotten test
import { fromFileUrl, join } from "https://deno.land/std@0.188.0/path/mod.ts";
import * as esbuild from "https://deno.land/x/esbuild@v0.17.19/wasm.js";
import { denoPlugins } from "https://deno.land/x/esbuild_deno_loader@0.7.0/mod.ts";
import {
getHashSync,
scripted,
collectAndCleanScripts,
} from "https://deno.land/x/scripted@0.0.2/mod.ts";
export { scripted } from "https://deno.land/x/scripted@0.0.2/mod.ts";
@nestarz
nestarz / Register.tsx
Last active May 16, 2023 12:22
Rotten 2
import { register } from "./islands.ts";
export default ({ proxy: C, specifier, name, children, ...props }) => (
<C
{...props}
className={[register(specifier, props, name), props.className].filter((v) => v).join(" ")}
>
{children}
</C>
);
@nestarz
nestarz / useTable.ts
Created April 20, 2023 14:27
useTable
import {
type TableOptions,
type TableOptionsResolved,
type RowData,
createTable,
} from "@tanstack/table-core";
export * from "@tanstack/table-core";
import { useComputed, useSignal } from "@preact/signals";
export type Renderable<TProps> = React.ReactNode | React.ComponentType<TProps>;
import { h } from "preact";
import { createContext, ComponentChildren } from "preact";
import { useContext } from "preact/hooks";
import { Signal } from "@preact/signals";
interface ComboboxProps {
children: ComponentChildren;
value: string | Signal<string>;
onChange: (value: string | null) => void;
nullable?: boolean;
export const getHashSync = (str: string) =>
String(
str.split("").reduce((s, c) => (Math.imul(31, s) + c.charCodeAt(0)) | 0, 0)
).replace(/-/g, "");
const scriptStore: [Map<string, string>, Map<string, string>] = [
new Map(),
new Map(),
];
export const cleanShalimar = () => scriptStore.forEach((map) => map.clear());