This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jack Herrington | |
The Blue Collar Coder 👋 | |
github.com/jherr | |
youtube.com/JackHerrington |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chalk = require('chalk'); | |
const COLOR_CORRECT_SPOT = 'green'; | |
const COLOR_WRONG_SPOT = 'yellow'; | |
const COLOR_NOT_ANY_SPOT = 'gray'; | |
// From https://codereview.stackexchange.com/a/274334 | |
function guessColor(word, guess, index) { | |
// correct (matched) index letter | |
if (guess[index] === word[index]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// A simple program that call a Joke API and prints out the joke | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zx | |
const choice = await question("How do you script? ", { | |
choices: ["zx 💪", "bash 😵"], | |
}); | |
console.log(`Now scripting in ${choice}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zx | |
const url = "https://sv443.net/jokeapi/v2/joke/Programming?type=single"; | |
const res = await fetch(url); | |
console.log((await res.json()).joke); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zx | |
console.log(`Hello ${argv.name} 👋`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect, test } from "@oclif/test"; | |
describe("hello", () => { | |
test | |
.stdout() | |
.command(["hello", "world", "--from=clidevs"]) | |
.it("runs hello cmd", (ctx) => { | |
expect(ctx.stdout).to.contain("hello world from clidevs!"); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inquirer from 'inquirer' | |
import sinon from 'sinon' | |
const stubPrompts = (results) => { | |
const stub = sinon.stub(inquirer, 'prompt') | |
for (const [index, result] of results.entries()) { | |
stub.onCall(index).resolves({ result }) | |
} | |
return stub | |
} |
NewerOlder