CODE SNIPPETS for Reference

CODE SNIPPETS

A couple of code snippets, tools, and reminders I find helpful to keep noted.

Here’s an example of a content selector that uses a vertical menu to show/hide content based on the selection made:

This example uses HTML, CSS, and JavaScript to create a vertical menu (menu) with three items (Item 1, Item 2, Item 3). Each item is associated with a corresponding content section (content1, content2, content3) that is initially hidden (display: none).

When a menu item is clicked, the showContent() JavaScript function is called with the ID of the corresponding content section. This function hides all content sections and then displays the selected content section by setting its display property to block (display: block).

You can add additional menu items and content sections by duplicating the HTML code for each item and section, and updating the IDs accordingly.

Read more >>

Essential Terminal Commands Every Web Developer Should Remember

As a web developer, the command line interface (CLI) is an indispensable tool for streamlining your workflow and executing various tasks efficiently. The terminal provides a powerful and flexible environment that allows you to interact with your operating system and perform a wide range of operations. In this article, we will explore some essential terminal commands that every web developer should remember. Whether you’re a beginner or an experienced developer, mastering these commands will boost your productivity and make your development process more seamless.

Change Directory

The “cd” command is fundamental for navigating through the file system. It allows you to change the current directory in the terminal. For example, to navigate to the “Documents” folder, you would type “cd Documents.”

Command: cd

Example: cd “path/to/directory/”

List

The “ls” command lists the files and directories in the current directory. Adding options such as “-l” (long format) or “-a” (including hidden files) provides more detailed information. For instance, “ls -l” displays the files and directories with their permissions, size, and modification dates.

Command: ls

Example: ls “path/to/directory/”

Open File

The “open” command allows you to open files, directories, or applications using their default programs. For example, “open index.html” will open the HTML file in the default browser.

Command: open

Example: open “filename”

Copy a file to another directory

The “cp” command is used to copy files and directories. To copy a file named “style.css” to another location, use the command “cp style.css /path/to/destination.” Similarly, “cp -r directory /path/to/destination” copies a directory and its contents recursively.

Command: cp

Example: cp “filename” “newfilename”

Move file

The “mv” command is used to move files and directories from one location to another or rename them. To move a file named “image.jpg” to a different directory, use the command “mv image.jpg /path/to/destination.” To rename a file, simply provide the new name as the destination, like “mv oldname.html newname.html.”

Command: mv

Example: mv “filename” “path/to/new/file/location”

Create file

The “touch” command is used to create new files. It creates an empty file or updates the modification timestamp of an existing file. To create a file named “index.html,” use the command “touch index.html.”

Command: touch

Example: touch myfile.txt

Remove nested directories

The “rmdir” command is specifically designed for removing empty directories. Unlike “rm -R,” it only works on directories that have no files or subdirectories within them. To remove an empty directory named “folder,” simply type “rmdir folder” in the terminal.

Command: rm -R

Example: rm -R “/path/to/root/directory”

Create directory

The “mkdir” command enables you to create new directories. Simply type “mkdir” followed by the name of the directory you want to create. For example, “mkdir website” creates a directory named “website.”

Command: mkdir

Example: mkdir “path/to/new/directory”

Additional Tips:

  • When using the “rm” or “rmdir” commands, exercise caution and double-check your commands before executing them, as these operations can permanently delete files or directories.
  • For added safety, consider using the “-i” flag with the “rm” command, which prompts for confirmation before deleting each file or directory.
  • Be mindful of the permissions and ownership of the files and directories you are attempting to remove. Some operations may require administrative privileges using the “sudo” command.

Execute commands with superuser privileges

The “sudo” command allows you to execute commands with administrative privileges. It is often used to perform system-level operations or modify restricted files. For example, “sudo apt-get install packageName” installs a package on Linux systems using administrator privileges.

Command: sudo

Example: sudo “command”

List actively running computer processes

Command: top

Example: top

grep (Global Regular Expression Print)

The “grep” command is a powerful text-searching tool. It allows you to search for specific patterns or text within files. For example, “grep ‘error’ logfile.txt” searches for the word “error” in the file “logfile.txt.”

Command: grep

Example: grep ‘error’ logfile.txt

Quit sub-screen and return to Terminal

The “q” command is particularly useful when you need to exit a program or tool that runs in the terminal. Whether you’re viewing logs, browsing manuals, or working with version control systems, typing “q” allows you to quickly quit and return to the command prompt.

Command: q

Example: After executing a command, such as top to view active processes, press “q” to exit.

Clear the Terminal screen of all previous commands

The “clear” command clears the terminal screen, providing a clean slate to work with. It is useful when the terminal output becomes cluttered, and you want to start fresh.

Command: clear

Example: clear

ditto

The “ditto” command is particularly useful for macOS developers. It allows you to create a new directory by copying an existing directory. For example, “ditto source_directory destination_directory” will create a duplicate of the source directory at the specified destination.

Command: ditto

Example: ditto -V MyFolder MyNewFolder

Get one-line description for a command

The “whatis” command provides a concise description of a specific command. It is ideal for quickly refreshing your memory or gaining a basic understanding of a command’s purpose. By typing “whatis command_name,” you can obtain a brief summary of the command’s functionality and usage.

Command: whatis

Example: whatis “command”

Show manual page for a command

The “man” command is used to access the manual pages for other commands. It provides detailed information about a command’s usage, options, and examples. For instance, typing “man cp” will display the manual page for the “cp” command.

Command: man

Example: man “command”

The “exit” command

The “exit” command allows you to close the current terminal session or exit a specific program. Typing “exit” will terminate the current session and return you to the command prompt.

Command: exit

Example: exit

Change file owner

The “chmod” command is used to change the permissions of files and directories. It allows you to control who can read, write, or execute a file. For instance, “chmod +x script.sh” grants executable permission to the script named “script.sh.”

Command: chown

Example: chown owner_name file_name

Modify this permission

The “chmod” command is used to change file permissions. It allows you to control who can read, write, or execute a file. For instance, “chmod +x script.sh” grants executable permission to the script named “script.sh.”

Command: chmod

Example: chmod [options] [mode] [File_name]

SSH

The “ssh” command establishes a secure remote connection to another machine. It enables you to log in to a remote server and execute commands remotely. For example, “ssh user@hostname” connects to the remote server with the specified username and hostname.

Command: ssh

Example: ssh user@hostname

Mastering the command line interface is essential for web developers as it empowers you to perform various tasks quickly and efficiently. The commands mentioned in this article are just a starting point, and there are many more commands to explore. As you continue your journey as a web developer, invest

Read more >>

Content Selector Module

This Content selector show/hides content through a vertical menu that can select images and text to display based on the selection made.

Read more >>

Image Hover Caption Effect

These hover effects are great for captions or text overlaying images.

View code and result below:

Read more >>

Css Text Hover Effects

CSS hover effects for text elements

These CSS hover effects is great for interactions on websites with links and other elements

View full code below:

Read more >>

Flip Card Effect

CSS Flip Card Effect using transform

This CSS effect creates an effect that appears to make the div container flip on hover. There is content on both the front and the back of the container.

View full code below:

Read more >>

Be new item on test

Yeah this is

Read more >>
33

22

11