01 February 2026

How to crop a video on Ubuntu?

ffmpeg -i input.mp4 -vf "crop=1200:626:279:89" -c:v libx264 -crf 20 -c:a copy output.mp4


To crop a video on Ubuntu, you use FFmpeg’s
crop filter. Cropping is different from resizing; it’s like taking a pair of scissors to the video frame to cut out a specific area (like removing a watermark or focusing on a specific person).

The logic for cropping is: crop=width:height:x:y


1. The Basic Crop Command

If you know the exact dimensions you want to keep, use this:

Bash
ffmpeg -i input.mp4 -vf "crop=1280:720:0:0" -c:a copy output_cropped.mp4
  • 1280: The width of the "box" you want to keep.

  • 720: The height of the "box" you want to keep.

  • 0: The X coordinate (distance from the left edge) where the box starts.

  • 0: The Y coordinate (distance from the top edge) where the box starts.


2. Common "Real World" Examples

To crop a square from the center (great for social media):

Bash
ffmpeg -i input.mp4 -vf "crop=ih:ih" -c:a copy output_square.mp4

(Note: ih stands for "Input Height." This tells FFmpeg to make the width equal to the height.)

To cut the video in half (keep only the right side):

Bash
ffmpeg -i input.mp4 -vf "crop=iw/2:ih:iw/2:0" -c:a copy output_right_half.mp4

3. How to find your coordinates (The Easy Way)

Trying to guess "X" and "Y" coordinates in a terminal is hard. Here is a trick to do it visually:

  1. Open your video in VLC.

  2. Go to Tools > Effects and Filters.

  3. Go to Video Effects > Crop.

  4. Type in numbers until the video looks exactly how you want it.

  5. Write down those numbers (Left, Right, Top, Bottom) and use them in this FFmpeg command:

Bash
# If you found: Left=100, Top=50, Width=800, Height=600
ffmpeg -i input.mp4 -vf "crop=800:600:100:50" -c:a copy output_cropped.mp4

Important Tips:

  • Re-encoding: Because you are changing the actual picture, FFmpeg has to re-encode the video. I didn't include quality flags above to keep it simple, but for the best result, add -crf 20: ffmpeg -i input.mp4 -vf "crop=w:h:x:y" -c:v libx264 -crf 20 -c:a copy output.mp4

  • Even Numbers: Just like before, H.264 (MP4) loves even numbers. If you get an error, make sure your width and height are divisible by 2.


How to convert a .webm video into a .mp4 one?

ffmpeg -i output_trimmed.webm -c:v libx264 -crf 23 -preset medium -c:a aac output.mp4

How to trim a video on Ubuntu?

ffmpeg -i toAi.webm -ss 02:42 -to 05:59 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis output_trimmed.webm

30 January 2026

How to move all the files in a directory to another directory on Linux

Gemini, I used the command -

$ ls -alhSp | grep -v /

, and got a list of files in the current directory.

What command can I use to move the files in the above list to another directory, please?


That is a very specific (and clever) command! You're using ls to list all files, sorting them by size (-S), adding a trailing slash to directories (-p), and then using grep to filter out anything with a slash.

Essentially, you've isolated just the regular files in your current folder, ranked from largest to smallest.

To move that specific list to another directory, you have a few options depending on how "clean" you want the process to be.


Method 1: The "Xargs" Approach (Recommended)

This is the most efficient way to take the output of one command and pipe it into another. We use the -I flag to create a placeholder (often {}) for the filenames.

Bash
ls -alhSp | grep -v / | awk '{print $9}' | xargs -I {} mv {} /path/to/destination/
  • awk '{print $9}': This is necessary because your original command uses -l (long format). awk grabs just the filename (the 9th column) so mv doesn't try to move the file permissions or timestamps.

  • xargs -I {}: This tells the system: "Take each filename and put it where the {} is in the next command."

Method 2: The Simple "Wildcard" (If you don't need the sort order)

If your goal is simply to move all files but no folders and you don't actually care about the size sorting from your original command, a simple loop is often safer:

Bash
for file in *; do [ -f "$file" ] && mv "$file" /path/to/destination/; done

⚠️ A Note on File Names

If any of your files have spaces in their names, the ls | grep method can get messy. When dealing with complex file movements, using find is generally the "Gold Standard" because it handles hidden characters and spaces much better:

Bash
find . -maxdepth 1 -type f -exec mv {} /path/to/destination/ \;
  • -maxdepth 1: Prevents it from looking into subfolders.

  • -type f: Ensures only files are moved (ignoring directories).


Which one should you use?

If you want...Use...
To keep using your ls logicMethod 1 (with awk)
The safest/fastest wayThe find command
To avoid complex syntaxMethod 2 (The loop)

Would you like me to explain how to modify that command to only move files over a certain size?


Yes, please. Thank you.

 

 

Since you are already using ls -S (sort by size), we can refine your pipeline to filter for specific size thresholds.

To do this effectively, we’ll swap ls for the find command. While ls is great for looking at files, find is a powerhouse for filtering them by attributes like size, age, or type.


Using find for Specific Sizes

This is the most reliable method. You can specify "greater than" (+) or "less than" (-) a certain size.

To move files larger than 100MB:

Bash
find . -maxdepth 1 -type f -size +100M -exec mv {} /path/to/destination/ \;

To move files smaller than 50KB:

Bash
find . -maxdepth 1 -type f -size -50k -exec mv {} /path/to/destination/ \;

Breakdown of the logic:

  • .: Look in the current directory.

  • -maxdepth 1: Don't go digging into subfolders.

  • -type f: Only look for files (this replaces your grep -v / logic).

  • -size +100M: The filter. Use k for Kilobytes, M for Megabytes, or G for Gigabytes.

  • -exec mv {} ...: The "action" part that moves every file found.


The "Quick & Dirty" Way (Using your original command)

If you prefer to stick to your ls command and just want to "eyeball" it, you can use head to move only the top largest files.

To move the top 5 largest files:

Bash
ls -pS | grep -v / | head -n 5 | xargs -I {} mv {} /path/to/destination/

Note: This version removes the -alh flags. When piping to mv, we don't want the "human-readable" sizes or permissions (like 1.2G or -rw-r--r--) included in the text, otherwise mv will get confused and think those are the filenames!


Comparison of Size Units

When using the -size flag in find, keep these suffixes in mind:

SuffixMeaningExample
kKilobytes-size +50k (Over 50 KB)
MMegabytes-size +10M (Over 10 MB)
GGigabytes-size +1G (Over 1 GB)
cBytes-size +100c (Over 100 Bytes)

Would you like me to show you how to do a "dry run" first, so you can see exactly which files will be moved before actually moving them?

 Yes, please. Thank you.

 

Performing a dry run is a pro move. It allows you to verify your logic without actually changing any files—saving you from that "oh no" moment when you accidentally move the wrong thing.

The simplest way to do a dry run is to replace the mv command with echo. This will print the command to your terminal instead of executing it.


1. Dry Run with the find Command

This is the safest way to test your size filters.

Bash
find . -maxdepth 1 -type f -size +100M -exec echo "Moving:" {} \;
  • What happens: The terminal will list every file larger than 100MB preceded by the word "Moving:". It won't actually move anything.

2. Dry Run with your ls Pipeline

If you are using the pipe method with xargs, just put echo before mv.

Bash
ls -pS | grep -v / | head -n 5 | xargs -I {} echo mv {} /path/to/destination/
  • What happens: You will see a list of commands like mv file1.zip /dest/. If the paths look correct, you can just hit the "Up" arrow on your keyboard and remove the echo to run it for real.


Comparison of Workflows

StepActionCommand Key
1. IdentifyList and filterfind or ls | grep
2. VerifyThe Dry Runecho
3. ExecuteFinal Movemv

A Quick Pro-Tip: The "Verbose" Flag

If you want to see the files moving while they are actually being moved (a middle ground between a dry run and flying blind), use the -v flag with mv:

Bash
mv -v source_file destination/
# Output: 'source_file' -> 'destination/source_file'

Would you like to know how to undo a move if you realize you sent files to the wrong folder?

 Yes, please. Thank you.

 

Moving files is instantaneous on the same disk, so there isn't a "Ctrl+Z" or "Undo" button in the terminal. However, you can effectively "reverse" the move by flipping the logic of your command.

Here are the best ways to handle an accidental move:

1. The "Reverse Move" (The Manual Fix)

If you just moved a specific group of files into a folder, the quickest way back is to go into that folder and move them back to the parent directory (represented by ..).

Bash
cd /path/to/destination/
mv * ../
  • Warning: Only do this if the destination folder was empty before you moved your files into it. Otherwise, you'll end up moving the original contents of that folder back to your source directory too!


2. The "By Time" Undo (The Precision Fix)

If you moved files into a folder that already had other files in it, you can use find to identify only the files that arrived in the last few minutes.

To move files out that arrived in the last 5 minutes:

Bash
find /path/to/destination/ -maxdepth 1 -type f -cmin -5 -exec mv {} ./ \;
  • -cmin -5: Finds files whose status changed (moved) less than 5 minutes ago.

  • ./: Moves them back to your current working directory.


3. Preventing Accidents: The "Interactive" Flag

To prevent needing an "undo" in the future, you can use the -i (interactive) flag. This forces the terminal to ask for your permission before overwriting any files at the destination.

Bash
mv -i source_file destination/
# Terminal: overwrite destination/source_file? (y/n)

Best Practices Summary

SituationSafety Strategy
Before movingUse echo for a Dry Run.
During the moveUse mv -v (Verbose) to see what's happening.
Potential OverwritesUse mv -n (No-clobber) to prevent overwriting existing files.
The "Undo"Use find with -cmin to isolate recently moved files.

Would you like me to show you how to create an "alias" so you can run these complex size-filtering moves with a single short command in the future?

 

 

 

 

25 January 2026

The list of all the format options of the gq command in vim?

In Vim, the
'formatoptions' setting controls how automatic text formatting is performed. It accepts a string of single-character flags, each enabling a specific behavior. You can view the current value in your Vim session with the command :set fo? or get a detailed explanation of all flags using the Vim help documentation via :help fo-table. 
The common and widely recognized formatoptions flags are:
  • t: Auto-wrap text at the width specified by the 'textwidth' option.
  • c: Auto-wrap comments at 'textwidth', automatically inserting the current comment leader character(s) (defined by 'comments' or 'commentstring').
  • q: Allow formatting with the gq operator.
  • r: Automatically insert the current comment leader after pressing <Enter> in Insert mode.
  • o: Automatically insert the current comment leader after pressing o or O in Normal mode.
  • n: Recognize numbered lists when formatting, using the pattern defined in 'formatlistpat'. This helps avoid joining list items into a single paragraph.
  • b: Auto-wrap text (backwards) when a line grows longer than 'textwidth'. The line is broken at the last white space before 'textwidth'.
  • v: Vi-compatible auto-wrapping (wraps at 'textwidth' in Insert mode).
  • j: Delete comment characters when joining lines using the J command.
  • l: Leave long lines as they are when entering Insert mode; only format if a line explicitly exceeds 'textwidth' due to typing.
  • m: Join with a space between the joined lines if there isn't one already.
  • p: Do not auto-wrap paste. When pasting text in Insert mode, do not apply auto-wrapping based on 'textwidth'.
  • u: Undo separate; make an undo command revert one line at a time instead of the entire paragraph formatting operation.
  • 2: Keep the indent of the second line when a paragraph is formatted (useful for some programming styles).
  • 1: Do not break a line after a single character (e.g., prevent single-letter words from being alone on the next line). 
  • a: Automatic formatting of paragraphs (changes are immediately reformatted). 
The default value is typically tcq. To add an option, you can use :set formatoptions+=<char>, and to remove one, use :set formatoptions-=<char>. 

Vim global command - how to apply 2 or more patterns?

:g/====\|----/-1p

Prints the line above all the lines with '====', and the line above all the lines with '----'

20 January 2026

How to convert a PDF file into a Markdown file or HTML file?

To convert a PDF into a Markdown file using the Python-based tool called Marker on Ubuntu, you need to set up the environment, install the
marker-pdf package, and then use the command-line interface. 
Prerequisites
Before installing Marker, ensure your Ubuntu system meets the following prerequisites:
  • Python: Version 3.10 or higher is required.
  • PyTorch: Marker needs PyTorch to run, as it relies on deep learning models.
  • System Libraries: You may need additional system libraries for advanced features like OCR with ocrmypdf or tesseract. 
Step-by-Step Guide
  1. Open your terminal on Ubuntu.
  2. Install system dependencies (optional, but recommended for full functionality, including OCR):
    bash
    # Install required apt packages
    sudo apt-get update
    sudo apt-get install -y build-essential libssl-dev libffi-dev python3-dev
    # Install tesseract and ghostscript related dependencies
    sudo apt-get install -y libleptonica-dev libtesseract-dev pkg-config
    sudo apt-get install -y ocrmypdf ghostscript
    
  3. Create a virtual environment to avoid conflicts with other Python projects (recommended):
    bash
    python3 -m venv marker_env
    source marker_env/bin/activate
    
  4. Install PyTorch by following the instructions on the official PyTorch website for your specific system configuration (CPU or GPU). A typical CPU-only installation command might look like:
    bash
    pip install torch torchvision torchaudio
    
  5. Install Marker using pip. You can install the basic PDF package or the full version for other document types:
    bash
    # For PDF conversion only
    pip install marker-pdf
    
    # For full functionality (PDFs, images, etc.)
    # pip install 'marker-pdf[full]'
    
  6. Convert a PDF file to Markdown using the command line tool marker_single.

    $ marker_single /path/to/file.pdf  

    --output_format [markdown|json|html|chunks]: Specify the format for the output results.
    --output_dir PATH: Directory where output files will be saved. Defaults to the value specified in settings.OUTPUT_DIR.

    https://github.com/datalab-to/marker

How to recognise a song?

SongRec

How to sync files among different devices?

https://syncthing.net/

16 January 2026

transform a single HTML list into a double column layout using modern CSS methods

You can transform a single HTML list into a double column layout using modern CSS methods like
column-count (part of the CSS multi-column layout module), CSS Grid, or Flexbox. 
Method 1: Using column-count (Recommended for simple lists)
This is the simplest method and requires the least amount of CSS. The browser automatically breaks the list items into the specified number of columns as needed. 
HTML:
html
<ul class="two-columns">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
  <li>Item 4</li>
  <li>Item 5</li>
  <li>Item 6</li>
  <li>Item 7</li>
  <li>Item 8</li>
</ul>
CSS:
css
.two-columns {
  column-count: 2; /* Specifies the number of columns */
  /* Optional: Adds a gap between columns */
  column-gap: 20px;
  /* Optional: keeps list items from breaking across columns (browser support varies) */
  break-inside: avoid; 
}
Method 2: Using CSS Grid
CSS Grid offers more control over the layout, especially for responsive design and managing equal column heights. 
HTML:
html
<div class="grid-container">
  <div>
    <ul>
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
      <!-- ... more items for the first column ... -->
    </ul>
  </div>
  <div>
    <ul>
      <li>Item 4</li>
      <li>Item 5</li>
      <li>Item 6</li>
      <!-- ... more items for the second column ... -->
    </ul>
  </div>
</div>
Note: This method is best if you can separate your list items into two distinct containers in your HTML structure. 
CSS:
css
.grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr; /* Creates two equal-width columns */
  gap: 20px; /* Adds spacing between columns */
}
Method 3: Using Flexbox
Flexbox is also a great option, particularly when managing how items wrap and display on different screen sizes. 
HTML:
(Same as Method 1, applying the class to the <ul> element) 
CSS:
css
.two-columns {
  display: flex;
  flex-direction: column; /* Stacks items vertically first */
  flex-wrap: wrap; /* Allows items to wrap into a new column */
  height: 200px; /* A fixed height is required for flex-wrap to work in this way */
}

.two-columns li {
  width: 50%; /* Each item takes up 50% width to create two columns */
}
Note: The fixed height can be an issue if the content is dynamic. The column-count method is often better suited for dynamic list lengths. 
For more examples and information, the MDN Web Docs and CSS-Tricks Flexbox Guide are excellent resources. 

09 January 2026

Automatically reminds me when recipient did not reply in a week

Google Workspace itself doesn’t have a built-in feature to automatically remind you (the sender) to follow up if the recipient doesn’t reply—but you can achieve this using a combination of Gmail features and Google Calendar or third-party tools. Here’s how you can set it up:


✅ Option 1: Use Gmail + Google Calendar (Manual but Reliable)


1. Send your email as usual.

2. Right after sending, create a Google Calendar event:

   - Title: “Follow up with [Customer Name] – Payment Reminder”

   - Set the date/time for 7 days from now.

   - Add a description with a link to the sent email (copy the URL from Gmail—see tip below).

3. Enable notifications for the event (e.g., email or pop-up 15 minutes before).


💡 Tip: To get a direct link to your sent email in Gmail:

- Open the email in your “Sent” folder.

- Click the three-dot menu → “Copy link to message” (you may need to enable this in Gmail Labs first, or use a workaround like noting the subject/date).


✅ ** Option 2: Use Gmail’s “Nudge” Feature (Limited Control)**


Gmail has a built-in “Nudge” feature that can remind you about important emails you’re waiting on—but it only works if the conversation is in your inbox (not Sent mail), and it’s not fully customizable.


To try:

- After sending the email, BCC yourself or ask the customer to reply (so their reply keeps the thread in your inbox).

- Gmailmight auto-nudge you if there’s no reply in a few days—but this isn’t guaranteed or precise.


✅ Option 3: Use a Free Third-Party Tool (Recommended for Reliability)


Tools like Boomerang for Gmail (boomeranggmail.com) let you:

- Schedule a follow-up reminder only if the recipient doesn’t reply.

- Set it right from your compose window.


Steps with Boomerang:

1. Install the Boomerang extension for Chrome.

2. After composing your payment reminder email, click “Boomerang” → “Remind me if no reply”.

3. Choose 1 week → Done!


Boomerang offers ~10 free reminders/month—enough for occasional use.


Summary

- For simple & free: Use Google Calendar with a manual reminder.

- For automated & smart: Try Boomerang for Gmail.


Would you like step-by-step instructions for any of these options?


Step-by-step instructions for boomerang, please 


Absolutely! Here’s a clear, step-by-step guide to using Boomerang for Gmail to remind you to follow up only if your customer doesn’t reply within a week.


🛠️ Step 1: Install Boomerang for Gmail


1. Open Google Chrome (Boomerang works best as a Chrome extension).

2. Go to the Boomerang for Gmail website or the Chrome Web Store page.

3. Click “Add to Chrome” → “Add extension”.

4. Once installed, you’ll see a small Boomerang icon (↩️) in your Gmail compose window.


✅ You’ll need to sign up for a free Boomerang account the first time you use it. The free plan includes 10 “remind me if no reply” messages per month—perfect for occasional reminders like this.


✉️ Step 2: Compose Your Payment Reminder Email


1. In Gmail, click “Compose”.

2. Write your email as usual:

   - To: your.customer@example.com  

   - Subject: Friendly Reminder: Outstanding Invoice #123  

   - Body: Include payment details, due date, and a polite request.


⏰ Step 3: Set Up the “Remind Me If No Reply” Feature


1. With your email ready (but before clicking Send), look for the Boomerang button at the bottom of the compose window. It looks like a curved arrow: ↩️  

  (If you don’t see it, refresh Gmail or check that the extension is enabled.)

2. Click the Boomerang button.

3. From the dropdown, select:  

   “Remind me if no reply…”

4. Choose the time frame:  

   → Select “In 1 week” (or pick a custom date/time if needed).

5. Click “Boomerang” (or “Set”).


✅ That’s it! Boomerang will:

- Send your email immediately.

- Monitor your inbox for a reply from that customer.

- If no reply arrives within 7 days, Boomerang will resurface the email in your inbox with a notification so you can follow up.


🔔 What Happens Next?


- If the customer replies before 7 days: Nothing happens—you won’t get a reminder.

- If they don’t reply: On day 8, the original email (with your sent message and any replies) will reappear in your inbox with a note like“Boomerang: Following up on this message.”


You can then send a stronger reminder, call them, or take next steps.


💡 Pro Tips


- You can edit or cancel pending Boomerang reminders by clicking the Boomerang icon in the top right of Gmail → “Pending” tab.

- Use “Snooze” (another Boomerang feature) to temporarily remove non-urgent emails from your inbox and bring them back later.


Let me know if you’d like help drafting a polite payment reminder email template too!