MoreRSS

site iconShinChvenModify

A full-stack TypeScript/JavaScript web developer, and also build mobile apps.
Please copy the RSS to your reader, or quickly subscribe to:

Inoreader Feedly Follow Feedbin Local Reader

Rss preview of Blog of ShinChven

Open Shared Document in Word App

2024-11-10 04:39:39

Introduction

You can definitely open shared online files directly in your local Microsoft Word application. This method allows you to access and edit documents seamlessly without the need for additional plugins or software. In this guide, we'll walk you through the steps to open shared online files in Microsoft Word.

How to Open a Shared Online File in Microsoft Word

  1. Open the Shared Link in Your Browser

    First, make sure you have access to the file by opening the shared link in your web browser. This step is essential to verify that the permissions are set correctly, allowing you to view the document.

  2. Access Your Word Application

    Once you've confirmed access, open your local Microsoft Word application.

  3. Navigate to the Open Menu

    Click on File in the top left corner of the Word window.

  4. Select Online Locations

    From the dropdown menu, select Open, and then look for Online Locations. Click on it to explore available online files.

  5. Open the Shared File

    You should see your shared file listed under the Shared section. Click on it to open the document directly in your local Word app.

By following these straightforward steps, you'll be able to access your shared online files without the hassle of dealing with plugins or compatibility issues. Enjoy seamless collaboration and enhanced productivity with Microsoft Word!

Batch ControlNet Task with WAS Node Suite

2024-10-28 23:30:17

Say you have a folder of images of poses you want to mimic using the ControlNet OpenPose model in ComfyUI. It's wise to load and process those images one by one in a batch task like automatic1111. The was-node-suite-comfyui has the custom node you need to load images from a folder, and you can use Auto Queue to iterate the image loading.

Here's a guide on how to do that:

  1. You need to add the Load Image Batch node from was-node-suite-comfyui.
    1. Draw index on the left to create an PrimitiveNode input, set value to 0 and control_after_generate to increment.
    2. Drag image on the right to your ControlNet node.
    3. Set mode to single_image.
    4. Set a random seed if you like.
    5. Set path to your image folder.
  2. Auto queue the Load Image Batch node.
    1. Click Extra options on the right of your ComfyUI.
    2. Check Auto Queue.
    3. Click the Queue Prompt button to go.

How to Share Ollama Server Through IP Address and Port

2024-10-24 22:04:42

Introduction

Recently, I encountered an issue where I was unable to share my Ollama server using IPAddress:port. After troubleshooting and following the official Ollama FAQ, I found a solution by configuring the OLLAMA_HOST environment variable. Here’s a step-by-step guide on how to resolve this problem.

The Issue

By default, Ollama binds to 127.0.0.1 on port 11434, which restricts access to the local machine. This means that even if you specify an IP address and port, other devices on the network will not be able to access the Ollama server.

Solution: Configuring OLLAMA_HOST

To make Ollama accessible from other devices on your network, you need to change the bind address from 127.0.0.1 to 0.0.0.0, which allows the server to listen on all available IP addresses. Follow these steps to configure OLLAMA_HOST:

Step 1: Set OLLAMA_HOST Environment Variable

You need to set the OLLAMA_HOST environment variable to 0.0.0.0:11434. The process for setting environment variables varies depending on your operating system:

On macOS

  1. Open the Terminal app.
  2. Use launchctl to set the environment variable:
   launchctl setenv OLLAMA_HOST "0.0.0.0:11434"
  1. Run Ollama as a server:
   ollama serve
  1. Verify the environment variable is set correctly by running:
   echo $OLLAMA_HOST

It should display 0.0.0.0:11434.

Make sure you exit the Ollama app before starting it as a server.

On Linux

  1. Edit the systemd service by calling systemctl edit ollama.service.

  2. Add the following line under the [Service] section:

   [Service]
   Environment="OLLAMA_HOST=0.0.0.0:11434"
  1. Save and exit the editor.

  2. Reload systemd and restart Ollama:

   sudo systemctl daemon-reload
   sudo systemctl restart ollama

On Windows

  1. Quit the Ollama application by clicking on it in the taskbar.

  2. Open the Settings (Windows 11) or Control Panel (Windows 10), and search for Environment Variables.

  3. Click on Edit environment variables for your account.

  4. Add or edit the variable for OLLAMA_HOST and set its value to 0.0.0.0:11434.

  5. Click OK/Apply to save the changes.

  6. Restart the Ollama application from the Start menu.

Step 2: Verify the Configuration

After setting the environment variable, you can check if the Ollama server is accessible from another device on the network.

  1. From another device, open a browser or use a tool like curl to access the server:
   http://<your_ip_address>:11434
  1. If everything is configured correctly, you should see a response from the Ollama server.

Additional Tips

  • Firewall Settings: Make sure that the firewall on your host machine allows incoming connections on port 11434.
  • Port Forwarding: If you are accessing the server from a different network, you may need to configure port forwarding on your router.

Conclusion

By changing the OLLAMA_HOST configuration to 0.0.0.0:11434, you can expose the Ollama server to other devices on your network. This solution allows for easier collaboration and remote access, enabling a wider range of use cases for your Ollama setup.

For more details on configuring the Ollama server, refer to the official FAQ.

Happy coding!

Chart Libraries for Data Visualization

2024-10-23 08:50:37

Library Language Description
AntV JavaScript A data visualization library by Alibaba Group offering a wide range of chart types and customization options.
Echarts JavaScript A powerful charting and visualization library by Baidu, supporting various chart types and interactive features.
D3.js JavaScript A JavaScript library for bespoke data visualization on the web, providing a flexible and powerful API for custom charts.
Mermaid.js JavaScript A JavaScript library for creating diagrams and flowcharts with a simple syntax, supporting various chart types and easy integration into web applications and documentation.
Plotly JavaScript, Python, R A popular charting library supporting multiple programming languages and offering interactive features for creating dashboards and visualizations.
Matplotlib Python A Python library for creating static, animated, and interactive visualizations, widely used for plotting data in various formats.
Seaborn Python A Python data visualization library based on Matplotlib, providing a high-level interface for creating attractive statistical graphics with built-in themes and color palettes.

Pull All Git Repositories with a Simple Bash Script

2024-10-19 20:00:00

Introduction

Managing multiple Git repositories can be a daunting task, especially when it comes to updating them all. Repetitive commands can lead to frustration and wasted time. Fortunately, with a simple Bash script, you can effortlessly pull updates from all your repositories at once. In this post, I'll share how to set up and use this script.

The Bash Script

Here's a straightforward script that allows you to pull all Git repositories within a given directory or the current directory if no path is specified.

#!/bin/bash

# Use the provided argument or default to the current directory
DIRECTORY=${1:-$(pwd)}

# Find .git directories and perform the operations
find "$DIRECTORY" -type d -name '.git' -execdir sh -c 'git --git-dir="{}" remote get-url origin && git --git-dir="{}" pull' \;

Explanation of the Script

  1. Directory Argument: The script accepts a directory path as an argument. If no argument is provided, it defaults to the current working directory using pwd.

  2. Finding Git Repositories:

    • It uses the find command to search for all .git directories within the specified path.
  3. Pulling Changes:

    • For each found repository, the script retrieves the origin URL and then performs a git pull to update it.

How to Use the Script

  1. Create the Script File:

    • Save the provided script into a file, for example, git_pull.sh.
  2. Make the Script Executable:

      chmod +x git_pull.sh
    
  3. Run the Script:

    • Without a Path: If you run the script without any arguments, it will pull updates from repositories in the current directory:

       ./git_pull.sh
      
    • With a Specific Path: You can also specify a directory path: bash ./git_pull.sh /path/to/your/directory

Conclusion

By using this simple Bash script, you can efficiently manage and update multiple Git repositories without manually running pull commands for each one. This is a small but powerful addition to your coding toolkit, particularly for developers and teams working with numerous projects.

Feel free to customize the script to fit your needs, and happy coding!

Deploying a Password-Protected Docker Registry Mirror

2024-09-28 00:36:41

You can deploy a password-protected Docker registry mirror and authenticate clients using basic authentication or, preferably, token-based authentication. Here's how to do it, focusing on the more secure token-based approach:

1. Deploying the Registry with Password Authentication (Token-Based):

We'll use the official Docker Registry image and configure it with a .htpasswd file for user authentication. However, this will only protect the registry itself; pushing and pulling images will leverage token-based authentication managed by the registry.

# Create a htpasswd file (replace 'username' and 'password' with your credentials)
htpasswd -B /auth/htpasswd username

# Start the registry with the authentication configuration
docker run -d \
  -p 5000:5000 \
  -v /auth:/auth \
  --name registry \
  registry:2

# Check logs to ensure it started correctly
docker logs registry

Explanation:

  • -v /auth:/auth: Mounts a volume containing the .htpasswd file into the container at /auth. The directory /auth on your host should contain the htpasswd file you created.
  • registry:2: Specifies the Docker Registry version 2.

2. Authenticating Clients:

Clients interact with a password-protected registry by obtaining a time-limited authentication token. This is done automatically by the Docker client when you try to push or pull. However, you need to login first:

docker login localhost:5000
# Enter username and password when prompted.

Behind the Scenes:

  • Login Process: When you docker login, the Docker client contacts the registry's authentication endpoint (configured automatically during registry startup). It sends the username and password (from the docker login command) for verification against the .htpasswd file.
  • Token Issuance: If authentication is successful, the registry issues a JSON Web Token (JWT) to the client.
  • Subsequent Requests: The Docker client includes this JWT in the Authorization header of all subsequent push and pull requests. The registry validates the token to authorize the operation.

3. Important Considerations for Production:

  • HTTPS: In a production environment, always use HTTPS. This encrypts communication between clients and the registry, protecting sensitive data like passwords and image layers. You'll need to configure SSL certificates for your registry. Let's Encrypt is a popular choice for free certificates.
  • Persistence: Use a volume to store registry data persistently, so you don't lose your images if the container restarts. Example: -v /var/lib/registry:/var/lib/registry
  • Authentication Backends: For more robust authentication and authorization, consider integrating the registry with an external authentication provider like LDAP, Active Directory, or a cloud-based identity service. The registry's configuration supports various auth backends.
  • Authorization: Authentication verifies who you are. Authorization determines what you can do. You might want to explore registry authorization solutions to fine-tune access control to specific images or repositories.

Example Docker Compose (with HTTPS and Persistence - replace placeholders):

version: "3.8"
services:
  registry:
    image: registry:2
    ports:
      - "5000:5000"  # Adjust port mappings as needed
    volumes:
      - /path/to/registry-data:/var/lib/registry
      - /path/to/certs:/certs
    environment:
      REGISTRY_HTTP_TLS_CERTIFICATE: /certs/your_certificate.crt
      REGISTRY_HTTP_TLS_KEY: /certs/your_certificate.key
      REGISTRY_AUTH_HTPASSWD_REALM: "Registry Realm"
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
    volumes:
      - /path/to/auth/dir:/auth # Directory with htpasswd file

Remember to generate your certificates and replace the placeholder paths and filenames. This enhanced example provides a more secure and robust setup for a production-like environment. Always prioritize security best practices when deploying a Docker registry.