Skip to content

Instantly share code, notes, and snippets.

@dima2306
dima2306 / compare.sh
Created September 4, 2025 13:19
This bash script searches for PHP and HTML files in the two defined directories and lists differences
#!/bin/bash
# Define the two directories
dir1=""
dir2=""
# Find and compare .php and .html files
find "$dir1" -name '*.php' -o -name '*.html' | while read -r file; do
# Get the relative path of the file
relative_path="${file#$dir1/}"
@dima2306
dima2306 / duplicate finder.sh
Created April 1, 2024 09:29
How to find duplicate files?
#
# look for files of size 512Kb or more (for movies can be set to something large)
# if file size differs, files are different
# if file size is same, compare their MD5 hashes
# if hashes match, output these files as duplicates
#
# Author: https://www.reddit.com/r/synology/comments/10yxgjq/comment/j80p942
#
find . -not -empty -links 1 -type f -size +512k -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find . -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
@dima2306
dima2306 / convert_base64_to_image.php
Created June 3, 2023 16:40
Convert base64 encoded images to actual images
if (! function_exists('convert_base64_to_image')) {
/**
* Searches for base64 string in the text. Thanks Pentium10 for the regex pattern.
* Transforms to the image binary and saves to the specified path.
*
* @param string $source <p> Text containing base64 string </p>
* @param \App\Question $question <p>Question model</p>
* @return array|string|string[]|null This function returns a new text with replaced path to the image.
* @author Pentium10
* @link https://stackoverflow.com/a/11382564
<script>
$(document).ready(function(){
updateImage();
});
let schedule = {
morning: {start: '05:00', end: '11:59'},
noon: {start: '12:00', end: '16:59'},
evening: {start: '17:00', end: '20:59'},
night: {start: '21:00', end: '04:59'},
@dima2306
dima2306 / Import rows into Notion database
Created July 17, 2022 12:15
This file can import data into Notion. In this example, we import data from an HTML file exported from Firefox Pocket.
<?php
declare(strict_types=1);
/**
* Created by PhpStorm.
* User: dima23
* Date: 17.07.22
* Time: 13:55
*/
@dima2306
dima2306 / identify_large_files.sh
Created August 5, 2018 10:07 — forked from sahilseth/identify_large_files.sh
At times .git folder becomes much larger than the code base, and needs shrinking
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output