This snippet creates a pagination UI using Smarty templating syntax. It displays previous/next links, highlights the current page, and adds ellipsis if there are many pages.
This PHP function calculates the distance between two geographical coordinates using the Haversine formula and supports kilometers, nautical miles, and miles.
This script kills all processes matching the name 'stats_snapshot' using `pkill`, and then checks if any matching processes are still running using `ps` and `grep`.
This command removes carriage return (`\r`) characters from a file (typically from Windows-formatted files) and writes the cleaned content to a new file. Useful when converting Windows line endings to Unix format.
sed 's/\r$//' docker/docker-compose.yml > docker/docker-compose2.yml
This command recursively searches for files that contain a specific word ('article' in this case) and lists their paths. It's useful for quickly locating where a word appears in a codebase or document directory.
This PHP snippet checks if a 'query' parameter is present in the request and initializes a search criteria array using the `$or` operator. This setup allows for flexible querying across multiple fields and can be extended to support special characters or advanced search patterns.
This Docker command clears the log file of a running container (e.g., `photoprism`) by redirecting an empty input (`:`) to the log path retrieved via `docker inspect`. It's a quick way to reduce disk usage without stopping the container, but use with caution to avoid losing important logs.
This command forcefully terminates all running processes with a specific name—in this case, `rsync`—using `kill -9` and `pidof`. It's useful for stopping multiple instances at once, but `-9` sends SIGKILL, which immediately stops the process without cleanup, so use it carefully.
This command uses `du` to calculate the disk usage of items in the current directory (non-recursively), displaying sizes in megabytes. It then pipes the output to `sort` to list them in descending order by size. Useful for identifying space hogs.
This command inspects a Docker container and filters the output using `grep` to show the `working_dir` label. It tells you the directory on the host machine from which the container was launched. Useful for debugging container origins in Docker Compose setups.
This Bash script automates the process of creating a monorepo by combining multiple existing repositories. It creates a main directory, initializes Git, clones each repo, moves contents into separate subfolders, renames tags, merges everything into the monorepo while preserving Git history, and updates a README with links to each merged repo.
#!/bin/bash
# List of repository names (update with actual repository names)
repos=("repo-1" "repo-2" "repo-3" "repo-4" "repo-5" "repo-6" "repo-7" "repo-8" "repo-9" "repo-11" "repo-12" "repo-13" "repo-14" "repo-15" "repo-16" "repo-17" "repo-18" "repo-19" "repo-20" "repo-21" "repo-22" "repo-23" "repo-24" "repo-25" "repo-26" "repo-27")
# Step 1: Create the monorepo
mkdir monorepo
cd monorepo
git init
echo "# Monorepo" > README.md
echo -e "\n## Included Repositories\n" >> README.md
git add README.md
git commit -m "Initial commit with README.md structure"
cd ..
mkdir repos
# Step 2: Clone each repo, move files into its own folder, and rename tags
for reponame in "${repos[@]}"; do
cd repos
git clone https://github.com/yourgithubaccount/$reponame.git
cd $reponame
mkdir -p $reponame
find . -maxdepth 1 ! -name .git ! -name . -exec mv {} $reponame/ \;
git add .
git commit -m "Moved repo content into folder $reponame"
git tag -l | xargs -I {} git tag "$reponame-{}"
cd ..
cd ..
done
# Step 3: Add each repository as a remote, merge into the monorepo, and update README.md
cd monorepo
count=1
for reponame in "${repos[@]}"; do
git remote add -f $reponame ../repos/$reponame
git merge $reponame/master --allow-unrelated-histories --no-edit
echo "$count. [$reponame](./$reponame)" >> README.md
((count++))
done
git add README.md
git commit -m "Updated README.md with links to merged repositories"