Showing posts with label Software. Show all posts
Showing posts with label Software. Show all posts

Friday, September 12, 2025

How to remove the bash history from a Linux Terminal



Removing bash history in the terminal can be done in several ways, depending on whether you want to clear the current session's history, remove specific entries, or clear the entire history file.


1. Clear the current session's history:

To clear the history of commands in the currently running shell session, use:

ಕೋಡ್

history -c

This command clears the in-memory history for the current session but does not affect the ~/.bash_history file until the session exits (and even then, it will only write the current, now empty, history).

2. Remove specific entries from history:

To remove a specific command from the history, first, identify its line number using the history command. Then, use:

ಕೋಡ್

history -d <line_number>

Replace <line_number> with the actual line number of the command you wish to remove. To make this change permanent in the ~/.bash_history file, you need to write the current history to the file afterwards:

ಕೋಡ್

history -w

3. Clear the entire bash history file:

To completely clear the ~/.bash_history file, which stores your command history across sessions, you can use:

ಕೋಡ್

cat /dev/null > ~/.bash_history

This command effectively truncates the ~/.bash_history file, making it empty. For the changes to take effect immediately in the current session and in future sessions, it is also recommended to clear the current session's history:

ಕೋಡ್

history -c && cat /dev/null > ~/.bash_history

4. Temporarily disable history saving for the current session:

If you want to prevent commands from being saved to history for the current session, you can unset the HISTFILE environment variable:

ಕೋಡ್

unset HISTFILE

Commands executed after this will not be recorded in the ~/.bash_history file until a new shell session is started or HISTFILE is set again.

Friday, July 4, 2025

How to configure passwordless login in Mac OS X and Linux




Overview


This article walks through configuring your website user's SSH connection to your DreamHost server so you will no longer have to enter your password.

Background

Once you set up a shell user and try to log in via SSH, you'll find you must enter your password each time. If you’d like to avoid entering your password every time, you can set up Passwordless Login. This way, you'll be able to automatically log in immediately without needing to enter your password.
How to configure passwordless login

The following instructions configure Passwordless Login for any Unix, Linux, OSX, or Cygwin machine.


In this article, username@server.dreamhost.com is used as the login example.Make sure to replace username with your actual shell username.
Make sure to replace the servername with your DreamHost servername.

Additionally, you can use the default key name of id_ed25519 or create a custom key name. Make sure you use the key name you choose in Step #3 throughout the remaining steps.

Configuring a shell user

See this article for instructions on changing your website user to an SSH (shell user) in your panel. This is required to run the SSH commands in this article.

Creating the .ssh directory on your server (DreamHost server)

This step confirms if the .ssh directory already exists on your DreamHost server, which is needed to copy your local SSH key to your server.

Log into your server via SSH and run the following commands to confirm the ~/.ssh directory exists under your username.
cd ~ ls -la | grep .ssh
If you see the .ssh directory listed, proceed with the next step.
If you do not see it, run the following command to create this directory:
mkdir ~/.ssh


Generating the key pair (home computer)

On your home computer:Open an SSH terminal.
Generate an ed25519 private key using ssh-keygen under your username:
ssh-keygen -t ed25519 Generating a public/private ed25519 key pair. Enter the file in which you wish to save they key (i.e., /Users/username/.ssh/id_ed25519):



Custom key name

If you press Enter, the key will be created with the default name of id_ed25519.

You can name this anything you like, but if you choose a custom name, you'll need to let your SSH client know about the new key name in Step #6 below. Also, if you choose to use a custom name, make sure to specify the full path to your user's .ssh directory. If you do not, the new key pair is created in the directory you're running the command. For example:
ssh-keygen -t ed25519 Generating a public/private ed25519 key pair. Enter the file in which you wish to save they key (i.e., /Users/username/.ssh/id_ed25519): /Users/username/.ssh/customkey_ed25519

Proceed through the prompts that appear.
Enter a passphrase (leave empty for no passphrase).



You do not need to enter a passphrase, but it's highly recommended as it protects your private key if compromised. If so, someone would still need your passphrase in order to unlock it. The exception to this is if you're running an automated process such as as cron job. You should then leave the password out. From ssh-copy-id:"Generally all keys used for interactive access should have a passphrase. Keys without a passphrase are useful for fully automated processes."
Press Enter to continue.
Enter same passphrase again:

Press Enter to continue.The following message appears:
Your identification has been saved in /Users/username/.ssh/custom_ed25519 Your public key has been saved in /Users/username/.ssh/custom_ed25519.pub The key fingerprint is: SHA256:7pNvrznUREXWY2r1otEwUWo40aKfZDFsUVDac3YuzrI The key's randomart image is: +--[ED25519 256]--+ | o+*+=| | X..o| | @.= +| | o #.* | | Q o @oB o| | . *.C.+ | | ..S.+ | | .o . .o | | .+..+. | +----[SHA256]-----+


Copying the public key to your DreamHost server (home computer)Run the following command to copy the public key on your local computer to DreamHost's server.
cat ~/.ssh/id_ed25519.pub | ssh username@server.dreamhost.com "cat >> ~/.ssh/authorized_keys"
This command responds with the following:
The authenticity of host 'server.dreamhost.com can't be established. ED25519 key fingerprint is SHA256:dhw3mJELPEz0i5Hzu/9lJR9FiJkK5EtiiPKAw/0zwuU. Are you sure you want to continue connecting (yes/no)? yes

Confirm the fingerprint in your panel on the SSH Keys page.
Type out the word yes to continue.
Enter your ssh username password when prompted.

The commands above create a new file named authorized_keys under your DreamHost user in the ~/.ssh directory.

Update the directory and file permissions (DreamHost server)

You must now update the permissions for the .ssh directory and authorized_keys file to further secure your keys.

Log into your server via SSH and run the following commands:
chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys


Adding your custom key to your ssh client (home computer)


This step is only necessary if you give your key a custom name in Step #3.1 above. You must then let your SSH client know what the new name is using ssh-agent.Run the following command to start ssh-agent. Make sure you use the backquote ` character and not a single quote – this backquote character is usually on the top left of your keyboard on the tilde ~ key:
eval `ssh-agent`

Run the following command to add your custom key.
ssh-add ~/.ssh/customkey_ed25519 Identity added: /Users/username/.ssh/customkey_ed25519

Confirm it's been added by running the following. It will respond with your private key's fingerprint.
ssh-add -l 256 SHA256:7pNvrznUREXWY2r1otEwUWo40aKfZDFsUVDac3YuzrI (ED25519)

Confirm that fingerprint by generating a fingerprint from your custom key's public file.
ssh-keygen -l -f ~/.ssh/customkey_ed25519.pub 256 SHA256:7pNvrznUREXWY2r1otEwUWo40aKfZDFsUVDac3YuzrI (ED25519)


Confirming the SSH connection (DreamHost server)

If everything is configured properly, you should now be able to access your DreamHost account through SSH without a password. Try logging in again.
ssh username@server.dreamhost.com


You should now be able to log in without using a password.
Specifying a key pair for SSH to use

By default, your client will use the identity (private key) named id_ed25519. However, if you've created more than one key, you can specify which one to use when connecting using the -i flag. For example:
ssh -i ~/.ssh/customkey_ed25519 username@server.dreamhost.com

See alsoSSH overview
SSH client software
Set up passwordless login in PuTTY
Courtesy: dreamhost.com

Wednesday, May 14, 2025

PostgreSQL list of commands

PostgreSQL, or Postgres, is an object-relational database management system that utilizes the SQL language. PSQL is a powerful interactive terminal for working with the PostgreSQL database. It enables users to execute queries efficiently and manage databases effectively.

Here, we highlight some of the most frequently used PSQL commands, detailing their functionalities to enhance your PostgreSQL experience.
Top PSQL Commands in PostgreSQL

Here are the top 22 PSQL commands that are frequently used when querying a PostgreSQL database:
Serial No.CommandDescription1 psql -d database -U user -W Connects to a database under a specific user
2 psql -h host -d database -U user -W Connect to a database that resides on another host
3 psql -U user -h host "dbname=db sslmode=require" Use SSL mode for the connection
4 \c dbname Switch connection to a new database
5 \l List available databases
6 \dt List available tables
7 \d table_name Describe a table such as a column, type, modifiers of columns, etc.
8 \dn List all schemes of the currently connected database
9 \df List available functions in the current database
10 \dv List available views in the current database
11 \du List all users and their assign roles
12 SELECT version(); Retrieve the current version of PostgreSQL server
13 \g Execute the last command again
14 \s Display command history
15 \s filename Save the command history to a file
16 \i filename Execute psql commands from a file
17 \? Know all available psql commands
18 \h Get help
19 \e Edit command in your own editor
20 \a Switch from aligned to non-aligned column output
21 \H Switch the output to HTML format
22 \q Exit psql shell

Additional Information:
The -d option in psql commands is used to state the database name.
The -U option specifies the database user.
The -h option indicates the host on which the database server resides.
The \h ALTER TABLE can be used to get detailed information on the ALTER TABLE statement.

Friday, May 9, 2025

How to deply Ollama & open web-ui on your laptop

How to deploy Ollama
 Installation:
  • Download Ollama: Get the Ollama package from the GitHub repository. 
  • Install Dependencies: Ensure you have any required dependencies, including libraries for your specific model. 
  • Verify Installation: Use ollama --version to confirm Ollama is installed correctly. 
2. Model Deployment and Usage:
  • Pull the Model: Use the ollama pull <model_name> command to download the desired model. 
  • Run the Model: Use ollama run <model_name> to initiate the model's execution. 
  • Interacting with the Model: Ollama provides an API at http://localhost:11434/api/generate for interacting with the model. 
  • Optional: Web UI: Explore Open WebUI for a user-friendly interface to manage and interact with models. 
  • Optional: Custom Applications: Build custom applications using libraries like FastAPI and Gradio to integrate Ollama models into your workflows. 

How to deploy open-webui

Open WebUI is an extensible, feature-rich, and user-friendly self-hosted AI platform designed to operate entirely offline. It supports various LLM runners like Ollama and OpenAI-compatible APIs, with built-in inference engine for RAG, making it a powerful AI deployment solution.

How to Install 🚀

Installation via Python pip 🐍

Open WebUI can be installed using pip, the Python package installer. Before proceeding, ensure you're using Python 3.11 to avoid compatibility issues.

  1. Install Open WebUI: Open your terminal and run the following command to install Open WebUI:

    pip install open-webui
  2. Running Open WebUI: After installation, you can start Open WebUI by executing:

    open-webui serve

This will start the Open WebUI server, which you can access at http://localhost:8080



To upgrade the Open-webui components

pip install open-webui --upgrade

Sunday, April 20, 2025

pivot_root vs chroot vs switch_root

The chroot command modifies the root directory for a process, limiting its access to the rest of the filesystem. This is useful for security, containerization, or testing purposes. The process running under chroot has no knowledge of anything outside its jail, making it appear as if it is running on the root filesystem.

123

In Linux, pivot_root, chroot, and switch_root are commands used to change the root filesystem of a process. Each has its specific use cases and functionalities.

pivot_root

The pivot_root command is used to change the root filesystem of the current process and its children. It swaps the current root filesystem with a new one, making the old root accessible at a specified location. This command is typically used during the boot process when the system transitions from an initial ramdisk (initrd) to the real root filesystem
1.

Example:

mount /dev/hda1 /new-root
cd /new-root
pivot_root . old-root
exec chroot . sh <dev/console >dev/console 2>&1
umount /old-root

In this example, the root filesystem is changed to /new-root, and the old root is accessible at /old-root3.

chroot

The chroot command changes the root directory for the current process and its children to a specified directory. Unlike pivot_root, chroot does not swap the root filesystem but simply changes the reference point for the current process. This command is often used to create isolated environments, such as chroot jails.

2.

Example:
chroot /new-root /bin/bash
In this example, the root directory for the current shell is changed to /new-root, and /bin/bash is executed within this new root2.

switch_root

The switch_root command is used to switch from an initial ramdisk (initramfs) to the real root filesystem. It is similar to pivot_root but is specifically designed for use with initramfs. switch_root performs additional cleanup tasks, such as moving common mount points (/dev, /proc, /sys, etc.) into the new root and attempting to delete everything in the old root
1.

Example:
switch_root /new-root /sbin/init

In this example, the root filesystem is switched to /new-root, and /sbin/init is executed as the new init process
1.

Key Differences

pivot_root: Swaps the current root filesystem with a new one, making the old root accessible. Used during the boot process with initrd.

chroot: Changes the root directory for the current process without swapping the root filesystem. Used for creating isolated environments.

switch_root: Switches from initramfs to the real root filesystem, performing additional cleanup tasks. Used during the boot process with initramfs.

Use Cases

pivot_root: Used when you need to preserve the original root for some purpose, such as during the boot process with initrd1.


chroot: Used to create isolated environments, such as chroot jails, for security or testing purposes2.


switch_root: Used to switch from initramfs to the real root filesystem during the boot process, performing additional cleanup tasks1.

By understanding the differences and use cases of these commands, you can choose the appropriate one for your specific needs in managing the root filesystem of a process.

Friday, February 14, 2025

Vim Copy & Paste Terminology

The keyboard shortcuts to copy, cut, and paste can be boiled down into three characters that utilize Vim-specific terminology.

Understanding these terms will help you recall the correct keyboard shortcut.

Y stands for “yank” in Vim, which is conceptually similar to copying.

D stands for “delete” in Vim, which is conceptually similar to cutting.

P stands for “put” in Vim, which is conceptually similar to pasting.

I deliberately use the phrase “conceptually similar to” because these actions are not one and the same. If you want to dive deeper into this explanation, scroll down to the section below titled “What Happens Under the Hood?”

Copy, Cutting, and Pasting in Vim/Vi - The Basics

1.Press esc to return to normal mode. Any character typed in normal mode will be interpreted as a vim command.

2.Navigate your cursor to the beginning of where you want to copy or cut.

3.To enter visual mode, you have 3 options. We suggest using visual mode because the selected characters are highlighted, and it’s clearer to see what’s happening. However, we have the keyboard shortcuts for normal mode (which achieve the exact same effect) in the section below.

4.Press v (lowercase) to enter visual mode. This will start selecting from where your cursor is.

5.Press V (uppercase) to enter visual line mode. This will select the entire line.

6.Press CTRL+V to enter visual block mode.

7.Move your cursor to the end of where you want to copy or cut.

8.Press y to copy. Press d to cut.

9.Move the cursor to where you want to paste your selection.

10.Press P (uppercase) to paste before your cursor. Press p (lowercase) to paste after your cursor.

Move the cursor to where you want to paste your selection.

Press P (uppercase) to paste before your cursor. Press p (lowercase) to paste after your cursor.


Vim Keyboard Shortcuts

Using arrow keys (or if you are an expert Vim user - h, j, k, and l) to move around in your vim file can take a long time.

Here are vim keyboard shortcuts for copying and cutting if you want to be even more efficient than the basic steps outlined above.

Copying (Yanking)

yy: Copy the current line in vi

3yy: To yank multiple lines in vim, type in the number of lines followed by yy. This command will copy (yank) 3 lines starting from your cursor position.

y$: Copy everything from the cursor to the end of the line

y^: Copy everything from the start of the line to the cursor.

yiw: Copy the current word.

Cutting (Deleting)

dd: Cut the current line

3dd: Cut 3 lines, starting from the cursor

d$: Cut everything from the cursor to the end of the line

Putting (Pasting)

P (uppercase): Paste before your cursor

p (lowercase): Paste after your cursor

What Happens Under the Hood?

Vim terms are slightly different from their conceptual counterparts that we mentioned above because these actions by default do not interact with the OS clipboard. For example, you can't paste yanked text from Vim into a different application with CMD + V.


Yank, delete, and put interact with Vim's notion of “registers”, which are basically Vim -specific clipboards. Each register is named with a character, which you can use to interact with that register. For example, you might yank line 50 of the current file to register “a” and yank line 14 of the same file to register “b”, because you intend to paste both line 50 and line 14.

To learn more about vim registers, check out this Stack Overflow page.

Conclusion

This should be everything you need to get started to copy, cut and paste in Vi. If you didn’t find what you were looking for, it may be worth checking out the official vim docs.

Monday, November 4, 2024

What is avahi in Linux?



avahi is a Linux implementation of a protocol also known as "Rendezvous" or "Bonjour"). Its goal is to let devices, connected to the local network, broadcast their IP-address together with their function. Hence the printer can from time to time broadcasts : My IP is 192.168.23.45 and I can print any postscript document with ipp prottocol; a NAS can say: My IP is 192.168.23.88 and I can stream music, save your backups, and act as a fileserver.

If it is not what you want to hear on your network you can stop / disable the avahi daemon with the standard systemctl command, but if you run a cups-broadcast daemon, it will start the avahi itself.

Linux uses fictive users usually for security reasons, not to give the attacker any chance to hack a process owned by root. So you can see a postfix or mail, and postgres or mysql users. The daemon, owned by such unprivileged user, gives less chance for the attacker to get the superuser rights.

Wednesday, August 14, 2024

Interview preparation Guide for Software Engineers


- Designing Data-Intensive Applications by Martin Kleppmann
Amazon: https://amzn.to/4dlfPed

- Database Internals by Alex Petrov
Amazon: https://amzn.to/3YI515e

- System Design Interview (Volume 1) by Alex Xu
Amazon: https://amzn.to/3WJzwVV 

- System Design Interview (Volume 2) by Alex Xu
Amazon: https://amzn.to/3M7zEtv 

- Grokking the System Design Interview
https://lnkd.in/ebEwFWbP

- Grokking the Advanced System Design Interview
https://lnkd.in/e_c2CWge

- Donne Martin's System Design Primer
https://github.com/krmadhukar/system-design-primer

- Site Reliability Engineering: How Google Runs Production Systems
https://lnkd.in/edYzQwXW

- The Site Reliability Workbook: Practical Ways to Implement SRE
https://lnkd.in/e9tKypna

- Understanding Distributed Systems
https://amzn.to/4fGzg2H

- Fundamentals of Software Architecture - Mark Richards & Neal Ford
https://amzn.to/3Xdozxv

- Software Architecture: The Hard Parts - Mark Richards & Neal Ford
https://amzn.to/4cp3NyX

- System Design Interview by Lewis Lin
- Hacking the System Design Interview by Stanley Chiang
- Distributed Systems by Tanenbaum
- Building Microservices by Sam Newman

► YouTube Channels

- The Facebook E6 Guy
https://lnkd.in/ehwMYjeD

- ByteByteGo (Alex Xu)
https://lnkd.in/emgA9inH

- InfoQ
https://lnkd.in/eicU_fx3
covers Facebook's TAO architecture: https://lnkd.in/eryi_ZTT

- Jordan Has No Life
https://lnkd.in/ePUshbhX

- Usenix
https://lnkd.in/e5A5s4Xv
https://lnkd.in/ersgNbfg

- MIT Distributed Systems Course
https://lnkd.in/eDjvUJa7

- Amazon Principal Engineer's Channel (A Life Engineered)
https://lnkd.in/egxKHJxU

- Fireship : https://lnkd.in/esqeG7T9

- Martin Kleppmann
https://lnkd.in/eQQ8f2aX

- DistSys Reading Group
https://lnkd.in/ec9FZUbs

- Leslie Lamport's Video Series on Learning TLA+
https://lnkd.in/eFFABEgW

- Carnegie Mellon's Distributed Databases Course
https://lnkd.in/eTdJqU3b


P.S: Image Credits: https://lnkd.in/eAt-mmZF

LinkedIn Credits - https://www.linkedin.com/in/karan-saxena-466b07190



Thursday, May 23, 2024

𝐅𝐑𝐄𝐄 𝐂𝐨𝐮𝐫𝐬𝐞𝐬 𝐲𝐨𝐮 𝐰𝐢𝐥𝐥 𝐫𝐞𝐠𝐫𝐞𝐭 𝐧𝐨𝐭 𝐭𝐚𝐤𝐢𝐧𝐠 𝐢𝐧 𝟐𝟎𝟐𝟒


1 Introduction Generative Al
imp.i384100.net/5gNjVj

2. Generative AI with Large Language Models
imp.i384100.net/k0qRez

2 a) React Fundamentals
imp.i384100.net/9gYeRW

2 b) Angular: imp.i384100.net/eKWR9r

2 c) SEO: imp.i384100.net/xkGnW5

3. Generative Adversarial Networks (GANs) Specialization
imp.i384100.net/DKNLPn

4. Introduction to Artificial Intelligence (AI)
imp.i384100.net/QyQKoA

5. AI Engineering
imp.i384100.net/9gYeRy

6. Natural Language Processing Specialization
imp.i384100.net/rQPgZR

7. Deep Learning Specialization
imp.i384100.net/jrL1k5

8. Generative AI for Data Scientists Specialization
imp.i384100.net/k0qReN

9. IBM Data Science Professional Certificate
imp.i384100.net/AWNK91

10. Introduction to Data Science
imp.i384100.net/GmNDek

11. Learn SQL Basics for Data Science
imp.i384100.net/Vm54E3

12. Excel for Business
imp.i384100.net/g1EojB

13. Python for Everybody
imp.i384100.net/B0MKrL

14. Machine Learning Specialization
imp.i384100.net/WqkYnM

15. SQL for Data Science
imp.i384100.net/Vm54E3

Like and Share with your friends and Help Them 😊

#oops #c++ #cpp #interviewquestions #interview #prep #it #cse #cs #systemdesign

Thursday, January 4, 2024

Golden rule of Programming - Don’t code today what you can’t debug tomorrow.

 One of the golden rule of programming is :


💡 Don’t code today what you can’t debug tomorrow.

Below some advices to improve yourself every day :

👉Master Your Tools: Become proficient in the programming languages, frameworks, and tools relevant to your field.

👉Problem-Solving Skills: Develop strong problem-solving skills to efficiently tackle coding challenges.

👉Debugging Proficiency: Sharpen your debugging skills to identify and fix issues quickly.

👉Algorithmic Understanding: Develop a strong understanding of algorithms and data structures for efficient problem-solving.

👉Code Readability: Write clean and readable code; it helps you and others understand and maintain it.

👉Time Management: Prioritize tasks, set deadlines, and manage your time effectively to stay productive.

👉Continuous Learning: Stay updated with industry trends, new technologies, and best practices to enhance your skills.

👉Testing: Embrace testing methodologies to ensure the reliability and correctness of your code.

👉Communication Skills: Effectively communicate with team members, stakeholders, and document technical decisions.

👉Collaboration: Foster a collaborative mindset, sharing knowledge and learning from your peers.

👉Stay Organized: Keep your codebase organized, use consistent naming conventions, and structure your projects logically.

👉Attention to Detail: Pay attention to details to avoid introducing errors and to produce high-quality code.

Efficiency comes from a combination of technical expertise, good practices, and effective collaboration.

Source - Linkedin post

Sunday, July 30, 2023

how to setup password for an AWS EC2 running instance

The AWS EC2 Linux instance uses a .pem private key file to authenticate the default ubuntu user account.

Let us learn about how to set up a password on your running EC2 instance,

Prerequisites

  • You have ec2 instance running
  • You have root access to ec2 instance

Step 1

Connect to your Linux ec2 instance via putty (/ssh).

Step 2

Login to your running instance

Step 3

Execute below command:

sudo passwd ec2-user

And write the password

Step 4

Now it’s time to go to the directory

/etc/ssh

and follow below command

sudo vim sshd_config 

Step 5

After you apply the command, 

Press “i” and

Now go to the “passwordauthentication” and write “yes”

After change, it please save it

Perfect

Step 6

Last command is

sudo service sshd restart

and disconnect and login again using username and password 

Friday, April 28, 2023

How to debug Python code in VS Code with arguments passed from command line

 Debugging Python code in VS Code with arguments passed from the command line is a straightforward process. Here are the steps you can follow:


1. Open the Python file that you want to debug in VS Code.

2. Set breakpoints in the code where you want to pause and inspect variables.

3. Open the Debug panel in VS Code by clicking on the Debug icon in the Activity Bar or by pressing `Ctrl+Shift+D` on Windows or `Cmd+Shift+D` on Mac.

4. Click on the "create a launch.json file" button and select "Python" as the environment.

5. In the launch.json file that opens, modify the "args" attribute to include the command-line arguments you want to pass to the Python script. For example:


   ```

   "args": ["arg1", "arg2"]

   ```


   Replace "arg1" and "arg2" with the actual arguments you want to pass.

NOTE: Add the below property in the launch.json file.   

"purpose": ["debug-in-terminal"]

6. Save the launch.json file.

7. Start the debugging process by clicking on the "Start Debugging" button in the Debug panel or by pressing `F5`.

8. The code execution will pause at the first breakpoint. Use the Debug Console to inspect variables, and use the Debug toolbar to step through the code and continue the execution.


That's it! You can now debug your Python code with arguments passed from the command line in VS Code.

Thursday, March 30, 2023

Regular Expressions



Regular Expressions
List of meta characters:

. ---> Any one character
? ---> Zero or one
+ ---> One or more
* ---> zero or more
^ ---> at the beginning of the string
$ ---> at the end of the string
[abc] ---> any one of a b c
{m} ---> 'm' times
{m,n} ---> at least m times, at most n times
| ---> or
\ ---> escape sequence character
\s ---> a space
\d ---> a digit
\w ---> a word
\b ---> a word boundary

examples:
\d ---> a single digit number (0 to 9)
\d\d ---> a two digit number (0 to 99)
\d\d\d ---> a three digit number (000 to 999)

NOTE: ?, +, *, {} are used as Quantifiers (to represent quantity)

\d{3} ---> same as above
\d{3,5} ---> either 3 digit or 5 digit number

hell?o ---> helo | hello
hell+o ---> hello | helllo | helllllo | ...
hrll*o ---> helo | hello | helllo | helllllo | ...
he(ll)+o ---> hello | hellllo | hellllllo | ...

S = "hi hello how are hello"

hello ---> Yes
^hello ---> No
hello$ ---> Yes
\d+ ---> a number
[0123456789]+ ---> a number
[0-9]+ ---> a number
\d{3} ---> a 4 digit ODD number

\d+\s\w+ ---> a number then a space then a word
\d+\s[a-z]+ ---> a number then a space then lowercase word
\d+\s[A-K764]{5,10} ---> a number then a space then min 5 max 10 char uppercase word between A - K 764
\d{3}:\d{2}:\d{4} --->
(ABC)?\d{3}:\d{4}[XYZ]? --->

Sunday, March 26, 2023

Go error: go : go.mod file not found in current directory or any parent directory; (working on GOPATH/src)

As of Go 1.16, the GO111MODULE environment variable is treated as "on" by default, meaning Go expects to find a go.mod file, and no longer falls back to pre-module GOPATH behavior.

If you want to go back to the pre-1.16 behavior, you now have to explicitly specify GO111MODULE=auto, but you're far better off creating a go.mod file.

See https://golang.org/doc/go1.16#go-command and https://golang.org/ref/mod


Source - https://stackoverflow.com/questions/67929883/go-error-go-go-mod-file-not-found-in-current-directory-or-any-parent-director 

Featured

TechBytes on Linux

This is a growing list of Linux commands which might come handy for the of Linux users. 1. Found out i had to set the date like this: ...

Popular Posts