View horizontal-center-no-width.css
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
.center { | |
postion: absolute; | |
left: 50%; | |
transform: translateX(-50%); | |
} |
View stringifySafely.ts
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
// Adapted from the Axios HTTP library | |
// https://github.com/axios/axios/blob/76f09afc03fbcf392d31ce88448246bcd4f91f8c/lib/defaults.js#L29 | |
/** | |
* Trim excess whitespace off the beginning and end of a string | |
* | |
* @param {String} str The String to trim | |
* @returns {String} The String freed of excess whitespace | |
*/ | |
const trim = (str) => { |
View video-pip-bookmarklet.js
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
javascript:let video=document.getElementsByTagName('video')[0];video.removeAttribute('disablePictureInPicture');video.requestPictureInPicture() |
View sdout.ts
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
process.stdout.write('hello world') |
View gcp-docker-k8s-jenkins.sh
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
## This script covers | |
# * Running Docker containers on a host. | |
# * Storing Docker images in the Google Container Repository (GCR). | |
# * Deploying GCR images on Kubernetes. | |
# * Pushing updates onto Kubernetes. | |
# * Automating deployments to Kubernetes using Jenkins. | |
GCP_PROJECT_ID="qwiklabs-gcp-04-17810074a304" | |
# Clone a repository from the Google Cloud Shell |
View index.html
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
<p>Hello | |
<script> | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', '/stream'); | |
xhr.seenBytes = 0; | |
xhr.onreadystatechange = function() { | |
console.log("state change.. state: "+ xhr.readyState); |
View docker-cmd.sh
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
# Stop all containers | |
docker stop $(docker ps -q) | |
# Remove all containers | |
docker rm $(docker ps -aq) | |
# Remove all images | |
docker rmi $(docker images -aq) | |
# See logs of a container |
View gcp.sh
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
## General commands | |
# Get active account name | |
gcloud auth list | |
# List the project ID | |
gcloud config list project | |
# Find default zone | |
gcloud compute project-info describe --project <GCP Project ID> |
View aws-lambda-edge.json
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": [ | |
"lambda.amazonaws.com", | |
"edgelambda.amazonaws.com" | |
] |
View rejection-based-retry.ts
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
// General purpose Rejection-based retrying | |
// Source: https://advancedweb.hu/how-to-implement-an-exponential-backoff-retry-strategy-in-javascript/ | |
const wait = (ms) => new Promise((res) => setTimeout(res, ms)); | |
const maybeFail = (successProbability, result, error) => new Promise((res, rej) => Math.random() < successProbability ? res(result) : rej()); | |
const maybeFailingOperation = async () => { | |
await wait(10); | |
return maybeFail(0.1, "result", "error"); | |
} |
NewerOlder