This file contains hidden or 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 { useEffect, useState } from 'react'; | |
| /** | |
| * `ScriptOnly` is the opposite of HTML's `<noscript>` tag. | |
| * It only renders its children when JavaScript is enabled and running. | |
| * | |
| * Think of it as the cool cousin of `<noscript>` — the one who *does* show up when JS is in the house. | |
| * | |
| * ## Use case | |
| * Use this when you want to display something *only* if JavaScript is working. |
This file contains hidden or 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 requests | |
| from bs4 import BeautifulSoup | |
| import json | |
| url = "https://www.miles.no/vi-er-miles/ansatte" | |
| response = requests.get(url) | |
| if response.status_code == 200: | |
| soup = BeautifulSoup(response.content, 'html.parser') |
This file contains hidden or 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 fs from "fs"; | |
| import path from "path"; | |
| import { fileURLToPath } from "url"; | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = path.dirname(__filename); | |
| const appDir = path.join(__dirname, "..", "app"); | |
| const routesDir = path.join(appDir, "routes"); | |
| const backupDir = path.join(appDir, "routes_backup"); |
This file contains hidden or 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 { ref, UnwrapRef, watch } from "vue"; | |
| export function useLocalPropSync<T>(propValueGetter: () => T) { | |
| const localValue = ref(propValueGetter()); | |
| watch(propValueGetter, (value) => { | |
| localValue.value = value as UnwrapRef<T>; | |
| }); | |
| return localValue; |
This file contains hidden or 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 { LRUCache } from "lru-cache"; | |
| import type { XLedgerGraphQLTimesheetQueryResponse } from "~/services/getTimesheet.server"; | |
| /** | |
| * LRU Cache for caching things like API responses. | |
| * For example, we use this cache to prevent spamming Xledger with requests and to improve application performance. | |
| * | |
| * Note: This cache is not a replacement for a database. | |
| * It is meant to be used for caching API responses. | |
| * |
This file contains hidden or 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
| export function normalizeCamelCase(text?: string): string { | |
| // If the input is not defined or is an empty string, return an empty string | |
| if (!text || text.length === 0) return ""; | |
| // Replace capital letters with a space followed by the letter | |
| // | |
| // Todo: note We only want to split between lower and upper case, not between upper and upper | |
| let spaced = text.replace(/([A-Z])/g, " $1"); | |
| // Convert the text to lowercase and trim any leading or trailing spaces |
This file contains hidden or 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 { useRouter } from "next/router"; | |
| // Use your url-route as a key-value store | |
| export function useRouterState( | |
| key: string, | |
| defaultValue: string | |
| ): [string, (value: string | string[]) => void] { | |
| const router = useRouter(); | |
| const value: string = (router.query[key] as string) || defaultValue; |
This file contains hidden or 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
| .text-inner-shadow { | |
| background-color: #565656; | |
| color: transparent; | |
| text-shadow: 2px 2px 3px rgba(255,255,255,0.5); | |
| -webkit-background-clip: text; | |
| -moz-background-clip: text; | |
| background-clip: text; | |
| } |
This file contains hidden or 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
| export function Collapsible(props: { title: string; children: ReactNode }) { | |
| // This is a hack to control the visibility of some content using pure css | |
| // | |
| // The css needed: | |
| // .toggle:checked ~ .control-me{ | |
| // display: block; | |
| // visibility: visible; | |
| // } | |
| // .control-me { | |
| // display: none; |
NewerOlder