Wednesday, 19 February 2025

How to set up My Zsh and Oh My Zsh on Ubuntu, start by installing Zsh and some useful tools

Tools

  • Zsh: A powerful shell that operates as both an interactive shell and a scripting language interpreter.
  • curl: A command-line tool for transferring data with URLs, supporting various protocols.
  • autojump: A faster way to navigate your filesystem, learning your most frequently used directories.
  • fzf: A general-purpose command-line fuzzy finder, useful for searching files, command history, and more.
  • git: A distributed version control system for tracking changes in source code during software development.
  • bat: A `cat` clone with syntax highlighting and Git integration, enhancing the readability of code and text files.
sudo apt-get install zsh curl autojump fzf git bat -y

Then, install Oh My Zsh using the command:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Next, add some helpful plugins to enhance your Zsh experience. Clone the following repositories into your Oh My Zsh custom plugins directory:

Plugins

  • zsh-syntax-highlighting: This plugin provides syntax highlighting for commands typed in the Zsh prompt, making it easier to read and spot errors.
  • zsh-autosuggestions: This plugin suggests commands as you type based on your command history and completions, speeding up your workflow.
  • you-should-use: This plugin reminds you to use existing aliases and functions, helping you to optimize your command usage.
  • zsh-bat: This plugin integrates the `bat` command, a `cat` clone with syntax highlighting and Git integration, into your Zsh environment.
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/MichaelAquilina/zsh-you-should-use.git $ZSH_CUSTOM/plugins/you-should-use
git clone https://github.com/fdellwing/zsh-bat.git $ZSH_CUSTOM/plugins/zsh-bat

Open your .zshrc file with:

nano ~/.zshrc

Add the plugins to the plugins list:

plugins=(git zsh-syntax-highlighting zsh-autosuggestions you-should-use zsh-bat)

Finally, apply the changes by running:

source ~/.zshrc

Best Zsh Tools and Plugins

  • Zsh: A powerful and flexible shell.
  • Oh My Zsh: A framework for managing your Zsh configuration.
  • zsh-syntax-highlighting: Enhances readability with syntax highlighting.
  • zsh-autosuggestions: Boosts productivity with command suggestions.
  • you-should-use: Optimizes command usage by suggesting aliases.
  • zsh-bat: Integrates the `bat` command for better file viewing.

These tools and plugins are some of the best for enhancing your Zsh experience, making your terminal more powerful and efficient.

Friday, 14 April 2023

Unified HTTP and WebSocket Security

Unified HTTP and WebSocket Security

Thanks to the HTTP/WebSocket unified security model, the following is a list of some standard HTTP security methods that can be applied to a WebSocket connection. Remember this is not something you get for free: each WebSocket gateway/server needs to implement any of these they consider important. (Kaazing’s Gateway supports all of them, and more.)


Wednesday, 15 March 2023

Force Mark all Read Gmaill

 


 

If you are thinking, how can I force mark all Read Gmaill? We can do this using Google scripts (app scripts ) allows us to automate tasks that we can't be bothered to do; I had a really fucking annoying notification of an old as fuck email, so I wanted to force them all into read.

Monday, 30 May 2022

So you want to make your own docker-compose for PHP/NPM ?


So you want to make your own docker-compose for PHP and NPM ? I know you do. But you don't want any more headaches, do you? Well, then, this tutorial is for you.


 

 

 

Friday, 26 November 2021

This is the list of cool and awesome Linux things.

This is the list of cool and awesome Linux things. Using these can improve your productivity and may even save your day occasionally. I'm sure you've heard of some of these before, so I'll keep it short; this is still a good primer if you're new to the Linux command line and looking for advice.

 

Thursday, 20 April 2017

How to calculate if table rows are inserted consecutively in MySQL

As a developer, working with asynchronous code often means dealing with out-of-order timestamps. To report on such data, we need to validate the created date-time. Here, we will explore SQL parts beyond the SELECT statement, focusing on variables and the HAVING clause.

SELECT @a := 0;
SELECT invited, `date`, `date` - @a AS gap, @a := `date`
FROM INVOICES AS i
HAVING gap < 0

SQL Variables

SQL variables are used to store temporary data. They are particularly useful in complex queries where intermediate results need to be stored and reused.

SELECT @a := 0;
  • @a is a user-defined variable.
  • := is the assignment operator.
  • 0 is the initial value assigned to @a.

Using Variables in Queries

Variables can be used within queries to perform calculations or store intermediate results.

SELECT invited, `date`, `date` - @a AS gap, @a := `date`
FROM INVOICES AS i
HAVING gap < 0;
  • invited and date are columns from the INVOICES table.
  • date - @a AS gap calculates the difference between the current date and the value stored in @a, aliasing it as gap.
  • @a := date updates the variable @a with the current date value for the next row.

The HAVING Clause

The HAVING clause is used to filter results based on aggregate functions or calculated columns, similar to the WHERE clause but applied after the GROUP BY clause.

HAVING gap < 0;
  • This filters the results to include only rows where the gap is less than 0, indicating an out-of-order timestamp.

Full Query Explanation

  1. Initialize Variable:
    SELECT @a := 0;
    Initializes the variable @a to 0.
  2. Query with Variable:
    SELECT invited, `date`, `date` - @a AS gap, @a := `date`
    FROM INVOICES AS i
    HAVING gap < 0;
    • Selects invited and date from the INVOICES table.
    • Calculates the gap between the current date and the previous date stored in @a.
    • Updates @a with the current date.
    • Filters rows where gap is less than 0.

Monday, 20 March 2017

Linux Clipboard Text To Speech

Install festival and esound-clients.

To do so, follow this tutorial: https://help.ubuntu.com/community/TextToSpeech

Install xsel:

sudo apt-get install xsel

Create new file in your home folder, call it "clipboardtospeech.sh" or something.

nano ~/apps/clipboardtospeech.sh

edit it and paste the following line:

xsel --clipboard | festival --tts

Make the script executable

cmod +x ~/apps/clipboardtospeech.sh

Make the file executable make a hotkey that launches the shell script:

~/apps/clipboardtospeech.sh