Utility Coder
← Back to Blog
Development9 min read

Developer Utility Tools: Diff, Curl, and More

Essential developer utilities for comparing, testing, and debugging. Learn diff tools, cURL conversion, responsive testing, and more.

By Andy Pham

Developer Utility Tools: Diff, Curl, and More

A collection of essential tools for everyday development tasks. Compare text, convert code, test responsiveness, and more.

Text Diff Tool

What is Diff?

Diff compares two texts and shows differences. Essential for:

  • Code review
  • Version comparison
  • Content verification

Diff Output Types

Type Description
Side-by-side Two columns
Unified Single view with +/-
Inline Highlights changes

JavaScript Diff

function simpleDiff(text1, text2) {
  const lines1 = text1.split('
');
  const lines2 = text2.split('
');
  const diff = [];

  const maxLen = Math.max(lines1.length, lines2.length);

  for (let i = 0; i < maxLen; i++) {
    if (lines1[i] !== lines2[i]) {
      diff.push({
        line: i + 1,
        old: lines1[i] || '',
        new: lines2[i] || ''
      });
    }
  }

  return diff;
}

cURL to PHP Conversion

Why Convert?

  • Copy browser requests
  • Generate API client code
  • Document API usage

Example Conversion

# cURL
curl -X POST https://api.example.com/users   -H "Content-Type: application/json"   -d '{"name": "John"}'
<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.example.com/users');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['name' => 'John']));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);
?>

Responsive Testing

Common Breakpoints

Device Width
Mobile S 320px
Mobile M 375px
Mobile L 425px
Tablet 768px
Laptop 1024px
Desktop 1440px

Testing Strategy

  1. Test mobile-first
  2. Check all breakpoints
  3. Test touch interactions
  4. Verify landscape mode

JavaScript Obfuscation

What is Obfuscation?

Making code hard to read while keeping functionality.

Techniques

  • Variable renaming
  • String encoding
  • Control flow flattening
  • Dead code injection

Warning

Obfuscation is NOT security. Use for:

  • Discouraging casual copying
  • Reducing file size slightly
  • Hiding implementation details

Number Base Conversion

Common Bases

Base Name Digits
2 Binary 0-1
8 Octal 0-7
10 Decimal 0-9
16 Hexadecimal 0-F

JavaScript Conversion

// To different bases
const num = 255;
num.toString(2);  // "11111111" (binary)
num.toString(8);  // "377" (octal)
num.toString(16); // "ff" (hex)

// From different bases
parseInt('11111111', 2);  // 255
parseInt('377', 8);       // 255
parseInt('ff', 16);       // 255

Try Our Developer Tools

Conclusion

These utility tools streamline common development tasks and improve productivity.

Share this article