Skip to content

Instantly share code, notes, and snippets.

View michmzr's full-sized avatar

Mike michmzr

View GitHub Profile
@michmzr
michmzr / cancel_workflows.zsh
Created July 15, 2024 14:20
Cancel all queued/in_progress github runs associated with branch
#!/usr/bin/env zsh
# Script Name: cancel_github_workflows.zsh
# Description: This script cancels GitHub Actions workflows for a specific branch
# that are either queued or in progress.
#
# Usage: ./cancel_github_workflows.zsh <branch_name>
#
# Arguments:
# <branch_name>: The name of the branch for which to cancel workflows
@michmzr
michmzr / script.sh
Created June 20, 2024 13:21
Remove Github Actions disabled workflows and runs
org=<your org>
repo=<your repo>
# Get workflow IDs with status "disabled_manually"
workflow_ids=($(gh api repos/$org/$repo/actions/workflows --paginate | jq '.workflows[] | select(.["state"] | contains("disabled_manually")) | .id'))
for workflow_id in "${workflow_ids[@]}"
do
echo "Listing runs for the workflow ID $workflow_id"
run_ids=( $(gh api repos/$org/$repo/actions/workflows/$workflow_id/runs --paginate | jq '.workflow_runs[].id') )

FWIW: I (@Rondy) am not the author of the content presented here, which is an outline from Edmond Lau's book. I've just copy-pasted it from somewhere and saved as a personal gist, before it got popular on newsnews.ycombinator.com. I don't remember where exactly the original source is from and neither could find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

FWIW: I (@Rondy) am not the author of the content presented here, which is an outline from Edmond Lau's book. I've just copy-pasted it from somewhere and saved as a personal gist, before it got popular on newsnews.ycombinator.com. I don't remember where exactly the original source is from and neither could find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

Chai BDD assertions provide a more expressive and readable syntax compared to the assert library in Node.js.
The BDD-style syntax resembles natural language, making the tests easier to understand and maintain.
// Using Chai BDD assertions
expect(foo).to.be.a('string');
expect(foo).to.have.lengthOf(3);
expect(foo).to.equal('bar');
// Using Node.js assert library
assert.strictEqual(typeof foo, 'string');
@michmzr
michmzr / api.test.js
Created June 15, 2023 10:41
Mocha + chai - rest api template
const chai = require('chai');
const chaiHttp = require('chai-http');
const { afterEach, describe, it } = require('mocha');
chai.use(chaiHttp);
const expect = chai.expect;
// Server URL
const serverUrl = 'http://localhost:3000';
@michmzr
michmzr / ipranges
Last active February 3, 2023 11:35
komunikacja
Scenario Outline: Convert IP address range to CIDR notation
Given a range of IP addresses "<start_ip>" to "<end_ip>"
When I convert the IP address range to CIDR notation
Then the CIDR notation should be "<cidr_notation>"
Examples:
| start_ip | end_ip | cidr_notation |
| 192.168.0.1 | 192.168.0.5 | 192.168.0.1/31 |
| 10.0.0.0 | 10.0.0.255 | 10.0.0.0/24 |
| 172.16.0.0 | 172.31.255.255 | 172.16.0.0/12 |
@michmzr
michmzr / pom.xml
Created August 16, 2022 12:25
maven - surefire & failsafe config
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<excludes>
<exclude>**/*IT</exclude>
<exclude>**/*ITTest</exclude>
<exclude>**/*ITTests</exclude>
</excludes>
<reportFormat>plain</reportFormat>
@michmzr
michmzr / Examples.java
Created July 13, 2022 13:15
WireMock - examples
/*
* Copyright (C) 2012-2021 Thomas Akehurst
*
* source: https://github.com/wiremock/wiremock/blob/master/src/test/java/ignored/Examples.java#374
*/
package ignored;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.common.DateTimeTruncation.FIRST_DAY_OF_MONTH;
import static com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED;
# Generates a JSON with valid format of Azure App Service enviroment variables - https://docs.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal
# Script uses json with env variables in format {"ENV_NAME": "ENV_VALUE",...}
import json
# Opening JSON file
f = open("env.json")
# returns JSON object as
# a dictionary