-
Change
apiVersion
from:- apiVersion: v1
(or
apiVersion: apps.openshift.io/v1
)to:
This file contains hidden or 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
Solution: | |
sinon.stub(presigner.prototype, 'presign').returns(Promise.resolve(new HttpRequest(parseUrl(Key)))); | |
----------------------- | |
Tests: | |
import assert from 'assert'; | |
import sinon from 'sinon'; | |
import { GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3"; |
This file contains hidden or 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
Question from: https://thedailybyte.dev/ | |
// You are given a two-dimensional matrix that represents the grades of a class of students. Each grade is represented as an array where the first index is the student’s ID and the second student is a grade (0 - 100) that the student has received. Given these grades, calculate the average of each student’s top five scores and return the result. | |
// Note: Each student is guaranteed to have at least 5 scores. Student IDs start from zero and increase by one. Your return variable should be sorted according to student ID. | |
My solution: | |
const grades = [[1, 100], [1, 50], [2, 100], [2, 93], [1, 39], [2, 87], [1, 89], [1, 87], [1, 90], [2, 100], [2, 76]] | |
const averageGrade = (grades) => { |
This file contains hidden or 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
> docker run --rm -it -d --name localstack -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack | |
> docker ps | |
> docker exec -it <containerId> /bin/bash | |
> aws configure | |
AWS Access Key ID [None]: example-key | |
AWS Secret Access Key [None]: example-secret-key | |
Default region name [None]: us-east-1 | |
Default output format [None]: |
This file contains hidden or 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
wsl.exe -u root -e sh -c "service docker status || service docker start" |
This file contains hidden or 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 { parseString, Builder } from "xml2js"; | |
// Convert string/XML to JSON | |
function toJson(xml: string) { | |
parseString(xml, { explicitArray: false }, function(error, result) { | |
console.log(result); | |
}); | |
} |
This file contains hidden or 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
#!/bin/bash | |
sudo add-apt-repository -y ppa:git-core/ppa | |
sudo apt-get update | |
sudo apt-get install git -y |
This file contains hidden or 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
export const alphanumeric = (len) => { | |
const str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | |
return [...Array(len)].reduce( | |
(a) => a + str[~~(Math.random() * str.length)], | |
"" | |
); | |
}; | |
console.log(alphanumeric(6)); // HNF2RU |
This file contains hidden or 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
// https://stackoverflow.com/a/1431113/11842937 | |
const replaceAt = function(str, index, replacement) { | |
return str.substring(0, index) + replacement + str.substring(index + replacement.length); | |
} | |
https://regexr.com/ - regex matches between symbol | |
regex = new RegExp(`^\\${symbol}(.*)\\${symbol}$`, 'gm') | |
g = global | |
m = multiline |
This file contains hidden or 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
function centuryFromYear(year) { | |
return Math.ceil(year / 100) | |
} |