Skip to content

Instantly share code, notes, and snippets.

@mpandurovic
mpandurovic / dig_ocean_init.sh
Last active November 21, 2020 19:46
Creating deployable git repos with Digital Ocean
#!/bin/bash
# Prerequisites: user 'deploy'
# dirs:
# /var/www (owner deploy)
# /var/repo (owner deploy)
if [ $# -eq 0 ]; then
echo "Error: Must provide repository name!"
exit 1
fi

something

sudo groupadd deploy
sudo useradd -m deploy -p deploy -g deploy
sudo adduser deploy sudo
## Install docker and docker-compose
## https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
## https://docs.docker.com/compose/install/#install-compose
sudo usermod -aG docker deploy
## Optionally:
@mpandurovic
mpandurovic / jsconfig.json
Created February 19, 2019 22:39
json config file for VS Code that allows compiler options for dirs in root directory (paired with babel module-resolver). "exclude" can probably be ommitted
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"*": ["*"]
}
},
"exclude": [
"../node_modules"
]
@mpandurovic
mpandurovic / launch.json
Created February 19, 2019 22:41
Run configuration for nodemon app that allows debugging. Try it without second obj in array.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "la-website nodemon",
"runtimeExecutable": "${workspaceFolder}/la-website/node_modules/nodemon/bin/nodemon.js",
"program": "${workspaceFolder}/la-website/src/server/index.js",
"restart": true,

Debugging

It's not always things work as expected. There are a few ways to get help from k6 in order to find what happens while your script is running.

Logging

As is the case with JavaScript executed in the browser, k6 supports console.log and console.error functions. We can use them to output useful information or debug our script.

import http from "k6/http";
@mpandurovic
mpandurovic / my-test.js
Created June 13, 2024 12:45
browser script for RADS
import { browser } from 'k6/experimental/browser';
import { check, sleep } from 'k6';
import http from "k6/http";
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
const BASE_URL = 'https://quickpizza-k6-insights.grafana-dev.net'
export const options = {
cloud: {