Dimas Maulana

Dimas Maulana

Developer

Welcome to my website! I am a developer with a current focus on React and Go. My experience encompasses both front-end and back-end development, enabling me to design and develop seamless and efficient applications.

How to Port Forward Docker-Machine to Localhost

Port forwarding allows you to expose services running inside a virtual machine, such as Docker-Machine, to your local machine. In this example, we’ll use VirtualBox and Docker-Machine to forward port 8080 from the virtual machine to localhost.

Prerequisites

Before you begin, make sure you have the following:

Location of Cron Logs on Ubuntu 14.04

Cron logs on Ubuntu 14.04 are typically stored in the /var/log/syslog file. However, if you wish to separate cron-related logs into their own file, you can follow the steps you’ve provided to create a dedicated log file for cron messages. Here’s how you can do it:

  1. Open the 50-default.conf file in the /etc/rsyslog.d/ directory:

    1
    2
    
    cd /etc/rsyslog.d/
    sudo nano 50-default.conf
  2. Uncomment the line that corresponds to cron messages. Remove the “#” symbol at the beginning of the line:

Viewing All Git Diffs With Vimdiff

If you’re a developer using Git for version control and you’re looking for a powerful way to visualize the differences between different versions of your code, Vimdiff is a handy tool to have in your toolkit. Vimdiff is a feature-rich text editor that comes with built-in support for comparing and highlighting differences between files, making it an ideal choice for inspecting code changes. In this article, we’ll explore how to set up Vimdiff as a diff tool for Git and how to make the most of its features for effective code comparison.

Troubleshooting SSHD Connection Issues With Public Key in Cygwin

Cygwin provides a Unix-like environment for Windows, including an implementation of OpenSSH, which allows you to establish secure remote connections using the SSH (Secure Shell) protocol. However, connecting to Cygwin’s SSH server (sshd) using public key authentication can sometimes present challenges. This blog post will guide you through a troubleshooting process to resolve issues related to connecting to Cygwin sshd with public key authentication.

Step 1: Update /etc/sshd_config

  1. Open the Cygwin terminal and navigate to the Cygwin installation directory (typically C:\cygwin64 or C:\cygwin).
  2. Locate the “sshd_config” file in the etc directory. The full path should be something like C:\cygwin64\etc\sshd_config.
  3. Open the “sshd_config” file using a text editor (e.g., Notepad++).
  4. Look for the “StrictModes” option and set it to “no.” This allows more relaxed permission checking for the authorized_keys file.
  5. Save the changes and close the text editor.

Step 2: Generate SSH Key Pair

  1. If you haven’t already done so, generate an SSH key pair on the client machine using the “ssh-keygen” command. Make sure to choose a strong passphrase to protect your private key.
  2. By default, the key pair will be saved in the “.ssh” directory in the user’s home directory (e.g., C:\Users\YourUsername.ssh).

Step 3: Copy Public Key to Cygwin Server

  1. In the Cygwin terminal, navigate to the user’s home directory (e.g., cd ~).
  2. Create the “.ssh” directory if it doesn’t exist: mkdir .ssh
  3. Use the “scp” command to copy the public key to the Cygwin server: scp <public_key_file> user@server:/home/user/.ssh/authorized_keys Replace “<public_key_file>” with the path to your public key file. Replace “user” with your username on the Cygwin server. Replace “server” with the hostname or IP address of the Cygwin server.

Step 4: Restart SSHD Service

  1. In the Cygwin terminal, run the following command to restart the sshd service: net stop sshd && net start sshd

Step 5: Test SSH Connection

  1. On the client machine, open a new terminal or command prompt.
  2. Run the following command to connect to the Cygwin server using SSH: ssh user@server Replace “user” with your username on the Cygwin server. Replace “server” with the hostname or IP address of the Cygwin server.
  3. If the connection is successful and prompts for the passphrase, enter the passphrase associated with your private key.

Conclusion

By following the troubleshooting steps outlined in this blog post, you should be able to connect to the Cygwin sshd server using public key authentication. Remember to ensure that the “StrictModes” option in the sshd_config file is set to “no” to allow more flexible permission checking for the authorized_keys file. Generating an SSH key pair, copying the public key to the Cygwin server, and restarting the sshd service are critical steps in establishing a successful SSH connection.

Add Command Line Interface (CLI) Args on PhantomJS

To add a command-line interface (CLI) and command-line arguments (args) to PhantomJS when using Selenium WebDriver in Node.js, you can modify your existing code as follows. I’ll provide you with a step-by-step guide and also explain the changes made:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const webdriver = require('selenium-webdriver');
const { Builder } = webdriver;
const phantomjs = require('phantomjs-prebuilt');

// Define your PhantomJS command-line arguments here
const phantomjsArgs = [
  '--load-images=false',
  // Add any other arguments you need here
];

// Set up capabilities with the CLI arguments
const capabilities = webdriver.Capabilities.phantomjs();
capabilities.set('phantomjs.cli.args', phantomjsArgs);

// Set the path to the PhantomJS executable
const phantomjsPath = phantomjs.path;
capabilities.set('phantomjs.binary.path', phantomjsPath);

// Create a WebDriver instance with the configured capabilities
const driver = new Builder()
  .withCapabilities(capabilities)
  .build();

// Example usage: navigate to a webpage
driver.get('https://example.com')
  .then(() => {
    console.log('Page title:', driver.getTitle());
  })
  .catch(error => {
    console.error('Error:', error);
  });

// Don't forget to quit the driver when done
driver.quit();

Here are the changes made to your original code:

Check Whenever Wifi Is Connected and Send Email When Its Connected

Thank you for providing the information and the modified Bash script. Below, I’ll provide a breakdown of the script’s functionality and highlight the changes made for clarity. This will be presented in Markdown format as requested.


Bash Script: Check WiFi Connection and Send Email

This Bash script checks whether the WiFi connection is active and sends an email when it reconnects. Here’s an overview of the script’s key points and improvements:

0%