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
#!/bin/zsh | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run with sudo." >&2 | |
exit 1 | |
fi | |
if [[ "$1" == "-h" || "$1" == "--help" ]]; then | |
echo "Usage: sudo ./script.sh <interface> <MAC_addr>" | |
echo "Sets the MAC address for the specified network interface." | |
echo "Arguments:" |
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 Image, { ImageProps } from "next/image"; | |
import { ReactNode, useState } from "react"; | |
interface ISkeletonImageProps extends ImageProps { | |
skeleton: ReactNode; | |
} | |
const SkeletonImage = ({ skeleton, ...props }: ISkeletonImageProps) => { | |
const [showSkeleton, setShowSkeleton] = useState<boolean>(true); | |
const { alt, width, height, src, className } = props; |
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"; | |
export function useDebounce<T>(value: T, delay?: number): T { | |
const [debouncedValue, setDebouncedValue] = useState<T>(value); | |
useEffect(() => { | |
const timer = setTimeout(() => setDebouncedValue(value), delay || 500); | |
return () => { | |
clearTimeout(timer); |
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
const BOT_TOKEN = process.env.BOT_TOKEN; | |
const CHANNEL_ID = process.env.CHANNEL_ID; | |
export const sendMessage = async (message) => { | |
const options = { | |
method: "POST", | |
headers: { | |
accept: "application/json", | |
"User-Agent": | |
"Telegram Bot SDK - (https://github.com/irazasyed/telegram-bot-sdk)", |
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 { RefObject, useEffect } from 'react' | |
const useClickOutside = (ref: RefObject<any>, callback: Function) => { | |
useEffect(() => { | |
const listener = (e: MouseEvent | TouchEvent) => { | |
if (!ref.current || ref.current.contains(e.target)) { | |
return | |
} | |
callback(e) |
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 { useState, useEffect } from "react"; | |
const useMediaQuery = (query: string) => { | |
const [matches, setMatches] = useState(false); | |
useEffect(() => { | |
const media = window.matchMedia(query); | |
if (media.matches !== matches) { | |
setMatches(media.matches); |
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 people from "./data"; | |
const SearchBar = () => { | |
const [searchValue, setSearchValue] = useState(""); | |
const searchResults = | |
searchValue.trim().length > 0 | |
? people.filter((person) => { | |
const name = person.name; |
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 { useState, useEffect } from 'react' | |
const useFetch = (url, options = {}) => { | |
const [loading, setLoading] = useState(true) | |
const [data, setData] = useState() | |
const [error, setError] = useState() | |
useEffect(() => { | |
const controller = new AbortController() | |
setLoading(true) |
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
<?php | |
/** | |
* Return a file's size in human readable form | |
* | |
* @param int $bytes File's size in bytes | |
* @param int $decimals How many decimals on the returned value | |
* | |
* @return string The file's size in human readable form | |
*/ |
NewerOlder