<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Arpit Kumar</title>
    <description>The latest articles on DEV Community by Arpit Kumar (@arpitsr).</description>
    <link>https://dev.to/arpitsr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F567546%2Fb3e08f6b-b08d-43a1-a24d-1a70782a1e82.png</url>
      <title>DEV Community: Arpit Kumar</title>
      <link>https://dev.to/arpitsr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arpitsr"/>
    <language>en</language>
    <item>
      <title>Writing a Local Password Generator in Zig and Storing it in a Config File</title>
      <dc:creator>Arpit Kumar</dc:creator>
      <pubDate>Wed, 21 Jun 2023 03:22:51 +0000</pubDate>
      <link>https://dev.to/arpitsr/writing-a-local-password-generator-in-zig-and-storing-it-in-a-config-file-1llc</link>
      <guid>https://dev.to/arpitsr/writing-a-local-password-generator-in-zig-and-storing-it-in-a-config-file-1llc</guid>
      <description>&lt;p&gt;Every time I have to change the mandatory password for web apps I have to go to an online solution and then store that password somewhere in notes. (I know tools like 1Password exist but I haven’t used them till now). So I decided to write a cli tool which can generate a password for me and store it in a file on my disk.&lt;/p&gt;

&lt;p&gt;I am currently learning the zig programming language and decided to use the same. The code for this would be simple and we will follow these steps -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ask user for username/email&lt;/li&gt;
&lt;li&gt;Ask user for domain for which to generate the password&lt;/li&gt;
&lt;li&gt;Generate the random password&lt;/li&gt;
&lt;li&gt;Store the username, domain and password combination in the file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will also learn some of the implementation details of zig while building this small cli tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we begin, make sure you have zig installed on your system. I have installed it with the help of asdf. I use asdf as it’s very convenient in maintaining various versions of tools I use.&lt;/p&gt;

&lt;p&gt;If you want to use asdf, install it using this link - &lt;a href="https://asdf-vm.com/guide/getting-started.html"&gt;https://asdf-vm.com/guide/getting-started.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or you can follow the official zig guide for installation. &lt;a href="https://ziglang.org/learn/getting-started/#installing-zig"&gt;https://ziglang.org/learn/getting-started/#installing-zig&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;On mac - brew install zig should do the trick.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;To get started create a directory in your development folder - zpassword&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir zpassword
# Then cd to zpassword
$ cd zpassword 
# Now let’s initialise a new project in ziglang
$ zig init-exe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The directory structure should look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|---build.zig
|---src
|---|---main.zig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2 directories, 2 files&lt;br&gt;
Let’s start changing the main.zig. Delete all the content of main.zig and leave this basic structure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const std = @import("std");

pub fn main() !void {

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I would like only these 62 characters be part of the password so let's add charset for base62&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const std = @import("std");
const allocator = std.heap.page_allocator;
const RndGen = std.rand.DefaultPrng;

const charset: [62]u8 = [_]u8{ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

pub fn main() !void {

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s add code to take input from the user. Here I have restricted the username and domain input to be max size of 512.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const stdin = std.io.getStdIn().reader();

std.debug.print("Enter username: ", .{});
var usernameResult = try stdin.readUntilDelimiterOrEofAlloc(allocator, '\n', 512);
var username = usernameResult.?;
defer allocator.free(username);

// take domain as input
std.debug.print("Enter domain: ", .{});
var domainResult = try stdin.readUntilDelimiterOrEofAlloc(allocator, '\n', 512);
var domain = domainResult.?;
defer allocator.free(domain);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most of the languages won’t require manual memory management but in zig we have to manage memory ourselves. It gives some freedom to use a particular type of memory allocator for a particular use case. Read more about memory allocator in my earlier post What's a memory allocator anyway?&lt;br&gt;
Similar to golang, zig also provides defer which is used to execute a statement while exiting the current block. This will make sure that allocated memory gets free when current block of code exits.&lt;br&gt;
We will store the password in a file name zpass.conf inside the .conf folder under the home directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var homeDir = std.os.getenv("HOME").?;
var confDir = ".config";
var confFile = "zpass.conf";


// Allocate memory for the dynamic string
const fullPath = try std.fmt.allocPrint(allocator, "{s}/{s}/{s}", .{ homeDir, confDir, confFile });
defer allocator.free(fullPath);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will try to generate a random number using a seed value generated from slice of bytes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Generate random seed by picking randombyte from memory
var seed: u64 = undefined;
std.os.getrandom(std.mem.asBytes(&amp;amp;seed)) catch unreachable;
var rnd = RndGen.init(seed);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;std.mem.asBytes -  /// Given a pointer to a single item, returns a slice of the underlying bytes, preserving pointer attributes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s now generate a password of length 10.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Generate Password
var password: [10]u8 = undefined;
for (password) |*char| {
    var some_random_num = rnd.random().intRangeLessThan(usize, 0, charset.len);
    char.* = charset[some_random_num];
}
std.debug.print("Password: {s}\n", .{password});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will open the file to write the password with username and domain. Here we are seeking to file to position 0 so that we can append the content at the beginning of the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Open file to write username, domain and password
const openFlags = std.fs.File.OpenFlags{ .mode = std.fs.File.OpenMode.read_write };
var file = try std.fs.openFileAbsolute(fullPath, openFlags);
defer file.close();

// seeking file position so that to append at beginning
try file.seekTo(0);

var fullText = try std.fmt.allocPrint(allocator, "Username: {s}, Domain: {s}, Password: {s}", .{ username, domain, password });
defer allocator.free(fullText);
_ = try file.writeAll(fullText[0..]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add a new line character to separate it from any earlier lines already stored in the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Adding new line char at end
const newline = [_]u8{'\n'};
_ = try file.write(newline[0..]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running the Program
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;$ zig build run&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You will be prompted to enter your username and domain. After entering the required information, the program will generate a password and store it, along with the username and domain, in the configuration file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter username: user@example.com
Enter domain: gmail.com
Password: 3zvSlZSUHL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Complete Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const std = @import("std");
const allocator = std.heap.page_allocator;
const RndGen = std.rand.DefaultPrng;

const charset: [62]u8 = [_]u8{ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

pub fn main() !void {
    const stdin = std.io.getStdIn().reader();

    std.debug.print("Enter username: ", .{});
    var usernameResult = try stdin.readUntilDelimiterOrEofAlloc(allocator, '\n', 512);
    var username = usernameResult.?;
    defer allocator.free(username);

    // take domain as input
    std.debug.print("Enter domain: ", .{});
    var domainResult = try stdin.readUntilDelimiterOrEofAlloc(allocator, '\n', 512);
    var domain = domainResult.?;
    defer allocator.free(domain);

    var homeDir = std.os.getenv("HOME").?;
    var confDir = ".config";
    var confFile = "zpass.conf";

    // Allocate memory for the dynamic string
    const fullPath = try std.fmt.allocPrint(allocator, "{s}/{s}/{s}", .{ homeDir, confDir, confFile });
    defer allocator.free(fullPath);

    // Generate random seed by picking randombyte from memory
    var seed: u64 = undefined;
    std.os.getrandom(std.mem.asBytes(&amp;amp;seed)) catch unreachable;
    var rnd = RndGen.init(seed);

    // Generate Password
    var password: [10]u8 = undefined;
    for (password) |*char| {
        var some_random_num = rnd.random().intRangeLessThan(usize, 0, charset.len);
        char.* = charset[some_random_num];
    }
    std.debug.print("Password: {s}\n", .{password});

    // Open file to write username, domain and password
    const openFlags = std.fs.File.OpenFlags{ .mode = std.fs.File.OpenMode.read_write };
    var file = try std.fs.openFileAbsolute(fullPath, openFlags);
    defer file.close();

    // seeking file position so that to append at beginning
    try file.seekTo(0);

    var fullText = try std.fmt.allocPrint(allocator, "Username: {s}, Domain: {s}, Password: {s}", .{ username, domain, password });
    defer allocator.free(fullText);
    _ = try file.writeAll(fullText[0..]);

    // Adding new line char at end
    const newline = [_]u8{'\n'};
    _ = try file.write(newline[0..]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  GitHub Repository
&lt;/h2&gt;

&lt;p&gt;You can find the complete code for the password generator in Zig on the following GitHub repository: &lt;a href="https://github.com/arpitsr/zpassword"&gt;Zig Password Generator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please note that storing passwords in plain text files is not secure and should not be used in real-world scenarios. This demonstration is solely for educational purposes.&lt;/p&gt;

&lt;p&gt;Originally posted on &lt;a href="https://sumofbytes.com/writing-a-local-password-generator-in-zig-and-storing-it-in-a-config-file-2"&gt;https://sumofbytes.com/writing-a-local-password-generator-in-zig-and-storing-it-in-a-config-file-2&lt;/a&gt;&lt;/p&gt;

</description>
      <category>zig</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to test https on localhost with help of Caddy</title>
      <dc:creator>Arpit Kumar</dc:creator>
      <pubDate>Thu, 29 Dec 2022 14:20:38 +0000</pubDate>
      <link>https://dev.to/arpitsr/how-to-test-https-on-localhost-with-help-of-caddy-2jlc</link>
      <guid>https://dev.to/arpitsr/how-to-test-https-on-localhost-with-help-of-caddy-2jlc</guid>
      <description>&lt;p&gt;In this post I am going to talk about testing https on localhost. Testing https on localhost is difficult of ssl certificates issue.&lt;/p&gt;

&lt;p&gt;If you want to test integration of https cookies, public webhooks etc you need https enabled web endpoint. Also any browser based https flows become difficult while testing on localhost.&lt;/p&gt;

&lt;p&gt;Today we are going to use an awesome open source tool &lt;a href="https://caddyserver.com/"&gt;Caddyserver&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Assuming we are running a server at localhost:3000&lt;/p&gt;

&lt;p&gt;To use CaddyServer with reverse proxy to port 3000 for HTTPS on localhost, follow these steps:&lt;br&gt;
Find install instructions for Caddy on - &lt;a href="https://caddyserver.com/docs/install"&gt;https://caddyserver.com/docs/install&lt;/a&gt;&lt;br&gt;
Once installed open up a terminal and run below command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;caddy reverse-proxy  --to :3000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;CaddyServer will generate a self-signed certificate for localhost and enable HTTPS on port 443.&lt;/p&gt;

&lt;p&gt;To access the HTTPS version of your localhost website, enter &lt;a href="https://localhost"&gt;https://localhost&lt;/a&gt; in your web browser. CaddyServer will reverse proxy all requests to port 3000.&lt;/p&gt;

</description>
      <category>https</category>
      <category>webdev</category>
      <category>localhost</category>
      <category>caddyserver</category>
    </item>
    <item>
      <title>Powerful options in cURL</title>
      <dc:creator>Arpit Kumar</dc:creator>
      <pubDate>Tue, 11 Jan 2022 17:29:15 +0000</pubDate>
      <link>https://dev.to/arpitsr/powerful-options-in-curl-1o4g</link>
      <guid>https://dev.to/arpitsr/powerful-options-in-curl-1o4g</guid>
      <description>&lt;p&gt;Most of us use cURL for GET requests.&lt;/p&gt;

&lt;p&gt;Few less used but powerful options in cURL. A curly thread 🧵&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Verbose output with -v&lt;br&gt;
&lt;code&gt;curl -v www.cnn.com&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hb2xRMeP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4ba6FVIAI3vrw%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hb2xRMeP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4ba6FVIAI3vrw%3Fformat%3Djpg%26name%3Dmedium" alt="verbose" width="880" height="624"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Follow redirects with -L&lt;br&gt;
&lt;code&gt;curl -L www.cnn.com&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uvH9NTz_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bbJFVkAISTxo%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uvH9NTz_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bbJFVkAISTxo%3Fformat%3Djpg%26name%3Dmedium" alt="redirect" width="880" height="384"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Download a file with a new name with -o&lt;br&gt;
&lt;code&gt;curl -o myfile.csv https://example.com/file.csv&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BovKh08_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bbVtUcAEa8eO%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BovKh08_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bbVtUcAEa8eO%3Fformat%3Djpg%26name%3Dmedium" alt="download" width="880" height="419"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resume an interrupted download with -C -&lt;br&gt;
&lt;code&gt;curl -C - -O https://images.unsplash.com/photo-1641762256336-16cb15d5850a&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ci-UMRi---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bbiyVIAEYKAX%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ci-UMRi---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bbiyVIAEYKAX%3Fformat%3Djpg%26name%3Dmedium" alt="resume-download" width="880" height="412"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Store website cookie in file with --cookie-jar&lt;br&gt;
&lt;code&gt;curl --cookie-jar cnncookies.txt https://www.cnn.com/index.html -O&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KsQuS5Wa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bbwrUcAUUkp_%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KsQuS5Wa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bbwrUcAUUkp_%3Fformat%3Djpg%26name%3Dmedium" alt="cookie jar" width="880" height="406"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send website cookies with --cookie&lt;br&gt;
&lt;code&gt;curl --cookie cnncookies.txt https://www.cnn.com/index.html&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hMtyCl3O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bb_cVcAAitIS%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hMtyCl3O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bb_cVcAAitIS%3Fformat%3Djpg%26name%3Dmedium" alt="send cookie" width="880" height="405"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Retry on failure with --retry&lt;br&gt;
&lt;code&gt;curl --retry 5 --retry-max-time 120 https://www.cnn.com/index.html&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ORVReE1S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bcMvVgAMrBVP%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ORVReE1S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bcMvVgAMrBVP%3Fformat%3Djpg%26name%3Dmedium" alt="retry" width="880" height="371"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use proxy for curl with or without authentication with -x and -U&lt;br&gt;
&lt;code&gt;curl -x proxy.yourdomain.com:8080 -U user:password -O https://yourdomain.com/yourfile.tar.gz&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HG6pJG5L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bcaRVIAMsXPK%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HG6pJG5L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bcaRVIAMsXPK%3Fformat%3Djpg%26name%3Dmedium" alt="proxy" width="880" height="480"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modify Name Resolution with --resolve&lt;br&gt;
&lt;code&gt;curl --resolve www.example.com:80:localhost https://www.example.com&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nozp38Ct--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bcr7UUAUTUWl%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nozp38Ct--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bcr7UUAUTUWl%3Fformat%3Djpg%26name%3Dmedium" alt="name resolution" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Retrieve particular byte range with -r&lt;br&gt;
&lt;code&gt;curl -r 0-20000 -o myfile.png https://images.unsplash.com/photo-1641762256336-16cb15d5850a&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lw5WkiS---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bc4cVgAEfmRj%3Fformat%3Djpg%26name%3Dmedium" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lw5WkiS---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/FI4bc4cVgAEfmRj%3Fformat%3Djpg%26name%3Dmedium" alt="byte range" width="880" height="374"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Want to know more. There's an actual gitbook you can refer -&lt;/p&gt;

&lt;p&gt;Read &lt;a href="https://everything.curl.dev"&gt;https://everything.curl.dev&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any other powerful cURL usage which we should know ?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>curl</category>
    </item>
  </channel>
</rss>
