This file contains 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/bash | |
if [ -e $1 ] | |
then | |
echo "Podaj rozmiar jako pierwszy argument" | |
else | |
if [ -e $2 ] | |
then |
This file contains 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
<a href="http://allegro.pl/my_page.php?uid=0000000000000">O firmie</a> | |
<a href="http://allegro.pl/show_user.php?uid=0000000000000">Komentarze</a> | |
<a href="http://allegro.pl/listing/user/listing.php?us_id=0000000000000">Aukcje</a> | |
<a href="http://allegro.pl/myaccount/favourites/favourites_sellers.php/addNew/?userId=0000000000000">Dodaj do ulubionych</a> | |
<a href="http://allegro.pl/email_to_user.php?uid=0000000000000">Kontakt</a> |
This file contains 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
document.body.addEventListener('keydown', (event) => { | |
if(event.key === "Enter" && (event.metaKey || event.ctrlKey)) { | |
event.target.form?.submit(); | |
} | |
}); |
This file contains 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
#!/usr/bin/env bash | |
notify-send --icon=info "$(xsel -o)" "$(wget -U "Mozilla/5.0" -qO - "http://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=pl&dt=t&q=$(xsel -o | sed "s/[\"'<>]//g")" | sed "s/,,,0]],,.*//g" | awk -F'"' '{print $2, $6}')" |
This file contains 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
interface FormData { | |
message: string | |
email: string | |
} | |
const App = () => { | |
const { submitHandler, values, updateFieldValue, touchField, getFieldError } = useForm<FormData>( | |
{ | |
message: required('Message is required'), | |
email: pipe( |
This file contains 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
/* | |
Copy this into the console of any web page that is interactive and doesn't | |
do hard reloads. You will hear your DOM changes as different pitches of | |
audio. | |
I have found this interesting for debugging, but also fun to hear web pages | |
render like UIs do in movies. | |
*/ | |
const audioCtx = new (window.AudioContext || window.webkitAudioContext)() |
This file contains 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 { DependencyList, Dispatch, SetStateAction, useEffect, useRef, useState } from 'react' | |
/** | |
* `useState` with dependency list, similar to `useMemo` but you can change state | |
* | |
* @example const [error, setError] = useStateEffect(!url, [url]); | |
* @example const [table, setTable] = useStateEffect(() => makeTable(data), [data]); | |
*/ | |
export const useStateEffect = <T>( | |
value: T | (() => T), |
This file contains 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 { MutableRefObject, useEffect } from 'react' | |
export const useOnClickOutside = (refs: MutableRefObject<any>[], handler: () => void) => { | |
useEffect(() => { | |
const listener = (event: any) => { | |
const someElContainsTarget = refs.some((ref) => | |
ref.current?.contains(event.target), | |
) | |
if (!someElContainsTarget) handler() | |
} |
This file contains 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 { uniq, xor } from 'lodash' | |
import { useMemo, useState } from 'react' | |
export const useSet = <T>(initial: T[] | (() => T[]) = []) => { | |
const [state, setState] = useState(initial) | |
return useMemo( | |
() => ({ | |
values: state, | |
size: state.length, |
This file contains 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 { createContext, PropsWithChildren, useContext, useState } from 'react' | |
import { createPortal } from 'react-dom' | |
const PortalContext = createContext<HTMLDivElement | null>(null) | |
export const PortalContextProvider = ({ children }: PropsWithChildren) => { | |
const [element, setElement] = useState<HTMLDivElement | null>(null) | |
return ( | |
<> |
OlderNewer