Skip to content

Instantly share code, notes, and snippets.

View countzero's full-sized avatar
☠️
Under a black flag we sail and the sea shall be our empire!

Finn Kumkar countzero

☠️
Under a black flag we sail and the sea shall be our empire!
View GitHub Profile
@countzero
countzero / totp_generator.js
Last active May 20, 2022 09:15
Standalone JavaScript Time-Based One-Time Password (TOTP) generator
'use strict'
/**
* Standalone JavaScript implementation of a Time-Based One-Time Password (TOTP) generator
*
* It is optimized to be used directly in any JavaScript context (e.g., for test automation).
*
* @see https://datatracker.ietf.org/doc/html/rfc6238
*/
@countzero
countzero / bundle.js
Last active November 18, 2021 13:24
Example on how to load a deferred JavaScript bundle
alert('WOW!');
@countzero
countzero / node-js-memory-test.js
Created July 16, 2020 10:09
Code to test how much memory is available with Node.js
// Source: https://github.com/Data-Wrangling-with-JavaScript/nodejs-memory-test
//
// Small program to test the maximum amount of allocations in multiple blocks.
// This script searches for the largest allocation amount.
//
//
// Allocate a certain size to test if it can be done.
//
@countzero
countzero / catalog.json
Created July 10, 2019 10:45
dan_DNK/api/v1/catalog
{
"catalog": {
"name": "Dänemark",
"categories": [
{
"name": "Campingvogne",
"images": [
{
"name": "previewImage",
"url": "https://www.hobby-caravan.de/fileadmin/user_upload/03-CARAVANS/2016/freisteller-caravans.png?v=1562684686"
@countzero
countzero / parallel_jobs.ps1
Last active July 5, 2019 20:28
Execute PowerShell jobs in parallel.
for ($index=1; $index -le 23; $index++) {
$scriptBlock = {
Param (
[string] [Parameter(Mandatory=$true)] $id
)
$durationInMilliseconds = $(Get-Random -Minimum 500 -Maximum 1000)
Start-Sleep -Milliseconds $durationInMilliseconds
@countzero
countzero / parallel_jobs_max_concurrency_while_strategy.ps1
Created July 5, 2019 19:56
Execute PowerShell jobs in parallel with a max concurrency using the while loop polling strategy.
$maxConcurrentJobs = 5
$pollingFrequencyInMilliseconds = 50
for ($index=1; $index -le 23; $index++) {
while ($true) {
Get-Job -State Completed | Receive-Job | Remove-Job
$concurrencyLimitIsReached = $($(Get-Job -State Running).Count -ge $maxConcurrentJobs)
@countzero
countzero / parallel_jobs_max_concurrency_wait_strategy.ps1
Last active July 5, 2019 19:46
Execute PowerShell jobs in parallel with a max concurrency using the Wait-Job strategy.
$maxConcurrentJobs = 5
for ($index=1; $index -le 23; $index++) {
$runningJobs = $(Get-Job -State Running)
$concurrencyLimitIsReached = $($runningJobs.Count -ge $maxConcurrentJobs)
if ($concurrencyLimitIsReached) {
Write-Host "Reached concurrency limit of ${maxConcurrentJobs}, waiting for a job to complete..."