Posts in category “Tips”

Windows Server 2022 RDP Connection Fix

Problem

  • Our IT security team has weird security setup, which successfully prevented the RDP client from remembering the password, and also caused the following annoying issue

    • RDP connection requires clicking "More choices" → "Use a different account" every time
    • Username not remembered despite saving in RDP file

Solution

Edit your .rdp file with these key settings:

full address:s:your-server-address, such as xetawsdev85.xemt.dev 
domain:s:XEMT 
username:s:your-username, such as David.Wei 
authentication level:i:2
enablecredsspsupport:i:0

Key Points

  1. Separate domain and username - don't use XEMT\David.Wei format in RDP file
  2. Set authentication level:i:2 - forces proper authentication
  3. Disable CredSSP support - enablecredsspsupport:i:0 is essential (tested)
  4. If you see a certificate warning on first connection - check "Don't ask me again"

Result

Username will be pre-filled correctly, only password entry required.

Fixing Claude Code (1.0.51/1.0.45) in Git Bash

for version 1.0.51 or newer, you can simply add a new environment variable with CLAUDE_CODE_GIT_BASH_PATH=C:\Program Files\git\bin\bash.exe using Edit environment variables for your account feature on windows.

However, I stick with v1.0.45 for now, as I noticed 1.0.51 no longer support paste image in gitbash, which is a pity!

I just noticed this hack only works with version 1.0.45, so please stick with version 1.0.45 for now until we found another hack :D

Claude Code fails in Git Bash with path errors like:

Error: /usr/bin/bash: line 1: C:UsersDavid.WeiAppDataLocalTemp/claude-shell-snapshot-6ea5: No such file or directory

Root cause: os.tmpdir() returns Windows paths, Git Bash expects Unix paths.

Solution: Patch the CLI directly with sed.

# Create ~/bin/c
#!/bin/bash
REAL_CLAUDE=$(which claude)
basedir=$(dirname "$REAL_CLAUDE")
case `uname` in
    *CYGWIN*|*MINGW*|*MSYS*)
        if command -v cygpath > /dev/null 2>&1; then
            basedir=`cygpath -w "$basedir"`
        fi
    ;;
esac

CLAUDE_DIR="$basedir/node_modules/@anthropic-ai/claude-code"
CLI_FILE="$CLAUDE_DIR/cli.js"
BACKUP_FILE="$CLI_FILE.original"

# Backup once
if [ ! -f "$BACKUP_FILE" ]; then
    cp "$CLI_FILE" "$BACKUP_FILE"
fi

# Patch and run
cp "$BACKUP_FILE" "$CLI_FILE"
sed -i 's/\b\w\+\.tmpdir()/\"\/tmp\"/g' "$CLI_FILE"

cd "$CLAUDE_DIR"
exec node "cli.js" "$@"
chmod +x ~/bin/c
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc

Now works:

c doctor
c --version  

The regex catches minified variable names. Patches fresh every run, so updates don't break it.

Running Claude Code on Windows Without WSL

This post is out-dated. Claude code has now officially supported GitBash, see https://docs.anthropic.com/en/docs/claude-code/setup for detail.

Got a Windows dev VM where you can't install WSL? Here's how to get Claude Code working with just Git Bash.

The Fix

Add these to your .bashrc:

export NPM_CONFIG_IGNORE_SCRIPTS=true
export SHELL=/c/Program\ Files/Git/bin/bash.exe

Then:

source ~/.bashrc
npm install -g @anthropic-ai/claude-code

Done.

Why It Works

Git Bash provides enough Unix-like environment for Claude Code. The SHELL export tells it where to find bash, and NPM_CONFIG_IGNORE_SCRIPTS prevents install script issues.

Caveats

This is a workaround, not official support. Works fine in my vm, let me know if it also works on your machine!

Tested on Windows Server 2022 with Git for Windows 2.50.0.windows.1

Stop the Whitespace Wars: How to Prevent Accidental Line Ending Changes in Large Teams

If you've ever had a code review rejected because of "whitespace-only changes," you're not alone. Nothing frustrates developers more than seeing a perfectly good pull request cluttered with meaningless line ending modifications that make the actual code changes harder to review.

The Problem

Large development teams often work across different operating systems - some on Windows, others on macOS or Linux. Each system has different default line endings (CRLF vs LF), and when developers use different editors with different configurations, innocent file saves can accidentally convert line endings throughout entire files.

The result? Pull requests that show hundreds of "changed" lines when only a few lines actually contain meaningful code changes. GitHub's "Hide whitespace changes" button helps reviewers, but it doesn't solve the root problem.

The Solution: Preserve What Exists

Instead of trying to enforce one line ending standard across a diverse team (which often fails), the better approach is to configure all tools to preserve whatever line endings already exist in each file.

Git Configuration

First, tell Git to stop converting line endings:

git config core.autocrlf false

This tells Git: "Don't touch line endings - leave them exactly as they are."

JetBrains Rider/IntelliJ Configuration

In your IDE settings:

  1. Go to File → Settings → Editor → Code Style → General
  2. Set "Line separator" to "System-dependent" or "Use existing"
  3. Disable Editor → General → On Save → "Ensure every saved file ends with a line break"

This makes Rider detect and preserve the existing line ending style in each file.

VS Code Configuration

Add to your settings.json:

{
  "files.eol": "auto",
  "files.insertFinalNewline": false,
  "files.trimTrailingWhitespace": false
}

The "files.eol": "auto" setting preserves existing line endings per file and only uses system defaults for completely new files.

Team-wide .editorconfig

Create an .editorconfig file in your repository root:

root = true

[*]
# Omit end_of_line to preserve existing line endings
insert_final_newline = false
trim_trailing_whitespace = false

By not specifying end_of_line, most editors will preserve whatever line endings already exist in each file.

Why This Works

This approach acknowledges the reality of mixed development environments while preventing the chaos of constant line ending changes. Files keep their original line endings, new files use sensible defaults, and most importantly - your pull requests only show actual code changes.

The Result

After implementing these settings across your team:

  • No more whitespace-only changes cluttering your diffs
  • Faster, cleaner code reviews
  • Happier team leads and reviewers
  • More focus on actual code quality instead of formatting battles

Your future self (and your code reviewers) will thank you for taking the time to set this up properly.


Have you dealt with similar whitespace issues in your team? What solutions worked for you? Share your experiences in the comments below.

Update your flutter app icons with a custom one

1. Prepare Your Icon Image

  • Create a square PNG image (preferably 1024x1024 pixels) for best quality

2. Use the flutter_launcher_icons Package

Add the package to your pubspec.yaml:

flutter pub add flutter_launcher_icons

3. Configure the Icons

Add this configuration to your pubspec.yaml file:

flutter_launcher_icons:
  android: true
  ios: true
  remove_alpha_ios: true
  image_path: "assets/icon/app_icon.png"  # Path to your icon image
  adaptive_icon_background: "#FFFFFF"  # For Android adaptive icons (optional)

4. Run the Package

Run this command in your terminal:

flutter pub get
dart run flutter_launcher_icons

done!