Basic curl curl https://example.com Display headers and the response body curl -i https://example.com Make it verbose curl -vvv -i https://example.com Save the output into a file curl http://alexrabocse.me -o curl-test.txt Sends a HEAD request curl -I https://example.com Sets a User Agent curl https://example.com -A 'Mozilla/5.0' Sets a Header curl -H 'Authorization: Basic YWRtaW46ABCtaW3=' http://alexrabocse.xyz Sets a Username and Password curl -u admin:admin http://xxxxxxxxxxx Sends a POST url -X POST -d 'username=admin&password=admin' http://xxxxxxxxxxxxxx Sets a Cookie curl -b 'ABCDE=c00ck13exampl3' http://xxxxxxxxxxx Sets a Cookie (another way) curl -H 'Cookie: ABCDE=c00ck13exampl3' http://xxxxxxxxxxx Sends POST + Sets a Cookie + Defines the data format of payload curl -X POST -d '{"subject":"test123"}' -b 'Cookie: ABCDE=c00ck13exampl3' -H 'Content-Type: application/json' http://xxxxxxxxxxxxx Sends PUT curl -X PUT http://xxxxxx/xxxx/xxxxx -d '{"subject":"test123"}' -H 'Content-Type: application/json' Sends DELETE curl -X DELETE http://xxxxxx/xxxx/xxxxx
Contents Contents Why Am I Doing All this? Lab Info in CLI Requirements TLDR (Execution with Source Code) Current State Execution Flow Caveats Progress and Roadmap What Did I Learn? What Is Next? Why Am I Doing All this? Some time ago I decided to try to decrease my context(task) switching between different tools and programs when I am working.
I see that most of my colleagues rely on the browser or third party applications heavily for certain tasks.
Contents Contents WARNING: Why Was I Doing All this? Salesforce Backlog CLI Requirements TLDR (Execution with Docker) Current State Script’s Data Flow Caveats Progress and Roadmap What Did I Learn? What Is Next? WARNING: Dear non existing reader, I am not going to bullshit you. If, for any strange reason, you checked my Github repo or my DockerHub some time ago, you will realize that I am copying and pasting most of that content here.
Below is the main.go file for a program that counts words or lines from Standard Input. A flag is used to specific what to count:
package main import ( "bufio" "flag" "fmt" "io" "os" ) func count(r io.Reader, countLines bool) int { scanner := bufio.NewScanner(r) if !countLines { scanner.Split(bufio.ScanWords) } wc := 0 // For every word of line scanned, add 1 to the counter for scanner.Scan() { wc++ } return wc } func main() { // Defining a boolean flag -l to count lines instead of words lines := flag.
Below is the main.go file to with a function to count words:
package main import ( "bufio" "fmt" "io" "os" ) func count(r io.Reader) int { // A scanner is used to read text from a Reader (such as files) scanner := bufio.NewScanner(r) // Define the scanner split type to words (default is split by lines) scanner.Split(bufio.ScanWords) // Defining a counter wc := 0 // For every word scanned, increment the counter for scanner.