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
# Heavily inspired by https://haluk.github.io/posts-output/2020-10-19-linux/ | |
# Replace <IFNAME> with wifi device name | |
# Replace <IDENTITY> with student identity (i.e. <USERNAME>@ntnu.no) | |
# Replace <PASSWORD> with user password | |
nmcli con add \ | |
type wifi \ | |
ifname <IFNAME> \ | |
con-name eduroam \ | |
ssid eduroam \ |
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 const mockSearchParams = (params: Record<string, string>) => { | |
const baseURL = window.location.href.split(/[?#]/)[0]; | |
const formattedParams = Object.entries(params) | |
.map(([key, value]) => `${key}=${value}`) | |
.join('&'); | |
window.history.replaceState(null, '', formattedParams ? `${baseURL}?${formattedParams}` : baseURL); | |
}; | |
export const getSearchParam = (key: string) => new URLSearchParams(window.location.search).get(key); |
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 { useCallback, useEffect, useState } from 'react'; | |
const SEARCH_PARAMS_EVENT_KEY = 'SEARCH-PARAMS-UPDATED'; | |
interface UseSearchParams { | |
searchParams: URLSearchParams; | |
setSearchParam: (key: string, value: string) => void; | |
removeSearchParam: (key: string) => void; | |
} |
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
fun <T: Any, R> T.tap(tap: (T) -> R): T { | |
tap(this) | |
return this | |
} |
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 { fireEvent } from '@testing-library/react'; | |
function dragElementTo(element: HTMLElement, target: HTMLElement) { | |
fireEvent.dragStart(element); | |
fireEvent.dragEnter(target); | |
fireEvent.dragOver(target, { clientX: 1, clientY: 1 }); | |
fireEvent.dragEnd(element, { dataTransfer: { dropEffect: 'copy' } }); | |
} |