Skip to content

Instantly share code, notes, and snippets.

View wojtekmaj's full-sized avatar

Wojciech Maj wojtekmaj

View GitHub Profile
@wojtekmaj
wojtekmaj / update-dependencies.sh
Created January 5, 2023 00:05
Update all your dependencies in /, /sample, /sample/*, /test directories
#!/bin/bash
# Define function
update_dependencies() {
rm -rf yarn.lock
touch yarn.lock
yarn
yarn dedupe
}
@wojtekmaj
wojtekmaj / update-year-in-licence.sh
Created January 4, 2023 23:58
Find all Git repositories recursively and update year in LICENSE if commit was made in current year
#!/bin/bash
current_year=$(date +%Y)
# Find all Git repositories, skipping node_modules directories
find . -type d -name .git -not -path '*/node_modules/*' -print0 | while read -d $'\0' repo; do
# Go to the repository directory
cd "${repo%/.git}"
# Check the year of the last commit
@wojtekmaj
wojtekmaj / feature-detection.js
Last active October 25, 2022 17:33
Image format feature detection
const isSafari = // ...
function getIsSupported(src) {
return new Promise((resolve) => {
const image = new Image();
image.onload = () => {
const isSupported = image.width > 0 && image.height > 0;
resolve(isSupported);
};
@wojtekmaj
wojtekmaj / github-actions-dashboard.html
Last active October 19, 2022 12:42
GitHub Actions Dashboard
<!DOCTYPE html>
<html>
<title>GitHub Actions dashboard</title>
<style>
:root {
font-size: 14px;
--background-color: rgb(246 248 250);
--canvas-background-color: rgb(255 255 255);
--canvas-border-color: rgb(216 222 228);
--canvas-shadow: rgba(140 149 159 / 15%) 0 3px 6px 0;
@wojtekmaj
wojtekmaj / migrate-package-to-typescript.sh
Last active September 28, 2022 12:10
Convert package to TypeScript automatically
# Create tsconfig.json
echo "{
\"compilerOptions\": {
\"declaration\": true,
\"esModuleInterop\": true,
\"isolatedModules\": true,
\"moduleResolution\": \"node\",
\"outDir\": \"dist\",
\"strict\": true
},
@wojtekmaj
wojtekmaj / react-add-word-break.js
Created January 25, 2022 11:08
Add word breaks to text in React
const pattern = /_/g;
function addWordBreaks(text) {
const splitText = text.split(pattern);
if (splitText.length <= 1) {
return text;
}
const matches = text.match(pattern);
@wojtekmaj
wojtekmaj / install-eslint-with-eslint-config-wojtekmaj-and-prettier.sh
Last active January 27, 2022 13:52
Install ESLint with eslint-config-wojtekmaj & Prettier
git fetch
git checkout main
git pull
git checkout -b prettier
yarn add eslint@^8.5.0 eslint-config-wojtekmaj prettier@^2.5.0 --dev
yarn dedupe
echo "{
\"printWidth\": 100,
\"singleQuote\": true,
@wojtekmaj
wojtekmaj / install-husky-and-commitlint.sh
Last active December 27, 2021 10:00
Install Husky & commitlint with conventional config using Yarn Berry
git fetch
git checkout main
git pull
git checkout -b husky
yarn add @commitlint/config-conventional @commitlint/cli husky@^7.0.0 --dev
yarn dedupe
echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
# if you're on windows, check EOL sequence in the file created
yarn husky install
@wojtekmaj
wojtekmaj / names-to-test-app.txt
Last active July 10, 2021 09:37
List of names to test your app with
Enrico Fermi
Cecilia Payne-Gaposchkin
Gertrude B. Elion
Patricia S. Goldman-Rakic
Łucja Światowska
Francisca de Oliveira
Ada María Guerrero de Hernández
侯既明
شیرین مینایی
@wojtekmaj
wojtekmaj / react-add-links.js
Created May 2, 2021 21:33
Add links to text in React